[PATCH v6] Implement strlcpy [BZ #178]
Florian Weimer
fweimer@redhat.com
Tue Nov 17 14:07:00 GMT 2015
On 11/17/2015 06:58 AM, Carlos O'Donell wrote:
>> +size_t
>> +__strlcpy_chk (char *__restrict s1, const char *__restrict s2,
>> + size_t n, size_t s1len)
>> +{
>
> Despite the simplicity I think this should have a comment about
> the invariant being tested.
Fixed.
>> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
>> +This function is similar to @code{strcpy}, but copies at most @var{size}
>> +characters into @var{to}, including the terminating null character.
>> +
>> +If the length of @var{from} is equal to or more than @var{size}, then
>> +@code{strlcpy} copies just the first @samp{@var{size} - 1} characters.
>
> ... and the null character?
I have slightly reworded this section (--word-diff helps for incremental
review).
>> +static int
>> +do_test (void)
>> +{
>> + struct {
>> + char buf1[16];
>> + char buf2[16];
>> + } s;
>> +
>
> This needs more comments.
>
> Each of these tests needs a comment explaining the intent of the test,
> even a succinct comment is worth a lot to a future maintainer reviewing
> the failed test.
Good point, comments added.
I'm attaching what I hope is the final version.
Regarding attribution in NEWS, we can add that once strlcat is committed. :)
Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: incremental.patch
Type: text/x-patch
Size: 4730 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20151117/c94b9973/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Implement-strlcpy-BZ-178.patch
Type: text/x-patch
Size: 30180 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20151117/c94b9973/attachment-0001.bin>
More information about the Libc-alpha
mailing list