Re: [TRIVIAL] kstrdup

From: Jeff Garzik (
Date: Fri Apr 18 2003 - 13:44:25 EST

Linus Torvalds wrote:
> On Fri, 18 Apr 2003, Jeff Garzik wrote:
>>Linus Torvalds wrote:
>>>On Fri, 18 Apr 2003, Jeff Garzik wrote:
>>>>You should save the strlen result to a temp var, and then s/strcpy/memcpy/
>>>No, you should just not do this. I don't see the point.
>>strcpy has a test for each byte of its contents, and memcpy doesn't.
>>Why search 's' for NULL twice?
> No, my point is that kstrdup() _itself_ just shouldn't be done. I don't

Ah, indeed :)

> see it as being worthy of kernel support. Most of the kernel string data
> structures are NOT random zero-ended strings anyway: they are either
> strictly limited in some ways ("ends in '\0', but limited to PATH_MAX), or
> they are explicitly sized ("struct qstr").

Quite true


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Wed Apr 23 2003 - 22:00:24 EST