Re: [PATCH v2] lib: string.c: Added a funktion function strzcpy

2014-10-16 Thread Rickard Strandqvist
2014-10-16 23:17 GMT+02:00 Andrew Morton : > On Thu, 16 Oct 2014 23:09:00 +0200 Rickard Strandqvist > wrote: > >> 2014-10-16 0:15 GMT+02:00 Andrew Morton : >> > On Sun, 5 Oct 2014 15:06:17 +0200 Rickard Strandqvist >> > wrote: >> > >> >> Added a function strzcpy which works the same as strncpy

Re: [PATCH v2] lib: string.c: Added a funktion function strzcpy

2014-10-16 Thread Andrew Morton
On Thu, 16 Oct 2014 23:09:00 +0200 Rickard Strandqvist wrote: > 2014-10-16 0:15 GMT+02:00 Andrew Morton : > > On Sun, 5 Oct 2014 15:06:17 +0200 Rickard Strandqvist > > wrote: > > > >> Added a function strzcpy which works the same as strncpy, > >> but guaranteed to produce the trailing null ch

Re: [PATCH v2] lib: string.c: Added a funktion function strzcpy

2014-10-16 Thread Rickard Strandqvist
2014-10-16 0:15 GMT+02:00 Andrew Morton : > On Sun, 5 Oct 2014 15:06:17 +0200 Rickard Strandqvist > wrote: > >> Added a function strzcpy which works the same as strncpy, >> but guaranteed to produce the trailing null character. >> >> There are many places in the code where strncpy used although

Re: [PATCH v2] lib: string.c: Added a funktion function strzcpy

2014-10-15 Thread Andrew Morton
On Sun, 5 Oct 2014 15:06:17 +0200 Rickard Strandqvist wrote: > Added a function strzcpy which works the same as strncpy, > but guaranteed to produce the trailing null character. > > There are many places in the code where strncpy used although it > must be zero terminated, and switching to str

[PATCH v2] lib: string.c: Added a funktion function strzcpy

2014-10-05 Thread Rickard Strandqvist
Added a function strzcpy which works the same as strncpy, but guaranteed to produce the trailing null character. There are many places in the code where strncpy used although it must be zero terminated, and switching to strlcpy is not an option because the string must nonetheless be fyld with zero

[PATCH v2] lib: string.c: Added a funktion function strzcpy

2014-10-05 Thread Rickard Strandqvist
I've added a strzcpy to make it easier to not do wrong when you use the function strncpy. Often one needs the zero padding, but must still have a guaranteed zero character terminat. Then you end up writing code like this: strncpy(to, src, sizeof(to)); to[sizeof(to) - 1] = '\0'; This is solved