lkml.org 
[lkml]   [2019]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] lib/string.c: implement a basic bcmp
From
Date
On 13/03/2019 20.01, Steven Rostedt wrote:
> On Wed, 13 Mar 2019 11:51:09 -0700
> Nick Desaulniers <ndesaulniers@google.com> wrote:
>
>>>
>>> or have a better comment explaining why its the same.
>>
>> I could add something about "the signedness of the return code not
>> providing any meaning." What would you like to see in such a comment?
>
> I think it's the wording that bothers me:
>
> + * bcmp - Like memcmp but a non-zero return code simply indicates a non-match.
>
> What about:
>
> * bcmp - Like memcmp but non-zero only means a non-match
>
> Then in the description say that bcmp() callers must not expect
> anything more than zero and non-zero,

Yes, but let's completely avoid mentioning memcmp in the summary.

bcmp - return 0 if and only if the buffers have identical contents
@a: pointer to first buffer
@b: pointer to second buffer
@len: size of buffers

The sign or magnitude of a non-zero return value has no particular
meaning, and architectures may implement their own more efficient
bcmp(). So while this particular implementation is a simple (tail) call
to memcmp, do not rely on anything but whether the return value is zero
or non-zero.

Rasmus

\
 
 \ /
  Last update: 2019-03-13 20:34    [W:0.100 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site