On Mon, Nov 17, 2014 at 20:01, Mark Kettenis wrote:
>> Date: Sun, 16 Nov 2014 19:10:41 -0500
>> From: Ted Unangst <[email protected]>
>>
>> The historic copystr API is like copyinstr/copyoutstr but only for
>> kernel strings. A much more familiar API is strlcpy.
>>
>> This converts three examples in kern.
>>
>> One where the return value is unchecked. One where the return is
>> checked. And one more complicated conversion where the outlen param is
>> used.
>>
>> Now, something to be careful about is the man page for copystr is
>> rather unclear about what actually happens with the nul bytes. It's
>> quite explicit, but somehow manages to still not be clear. For
>> example, this line:
>>
>> functions return ENAMETOOLONG if the string is longer than len bytes.
>>
>> It would seem that sentence includes the nul byte in len, but when one
>> speaks of C strings, the nul byte is typically not counted.
> 
> The vfs_subr.c changes make sense, but I really think the other
> changes make the code significantly harder to read.

That's kind of the point. Right now, I'm trying to do an exact
semantic replacement, then we can reconsider better ways to do it.
Also, even if it's more code, being explicit is preferable to relying
on a rarely used function. The long term goal here is to remove
copystr entirely.

Reply via email to