[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdnheUi6Ho5u4akTLGa-tBeUq94hQJH0+a4ROe_aEUgo7g@mail.gmail.com>
Date: Wed, 13 Mar 2019 11:51:09 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
clang-built-linux@...glegroups.com,
Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
"# 3.4.x" <stable@...r.kernel.org>,
Nathan Chancellor <natechancellor@...il.com>,
Adhemerval Zanella <adhemerval.zanella@...aro.org>,
Arnd Bergmann <arnd@...db.de>,
James Y Knight <jyknight@...gle.com>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Ingo Molnar <mingo@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Dan Williams <dan.j.williams@...el.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] lib/string.c: implement a basic bcmp
On Wed, Mar 13, 2019 at 11:40 AM Steven Rostedt <rostedt@...dmis.org> wrote:
>
> On Wed, 13 Mar 2019 11:17:15 -0700
> Nick Desaulniers <ndesaulniers@...gle.com> wrote:
>
> > +#ifndef __HAVE_ARCH_BCMP
> > +/**
> > + * bcmp - Like memcmp but a non-zero return code simply indicates a non-match.
> > + * @cs: One area of memory.
> > + * @ct: Another area of memory.
> > + * @count: The size of the areas.
> > + */
> > +#undef bcmp
> > +int bcmp(const void *cs, const void *ct, size_t count)
> > +{
> > + return memcmp(cs, ct, count);
>
> This is confusing where the comment says "like memcmp but .." and then
> just returns memcmp() unmodified. If anything, I would expect to see
>
> return !!memcmp(cs, ct, conut);
That's more work than strictly needed. memcmp already provides the
semantics of bcmp. memcmp just provides more meaning to the
signedness of the return code, whereas bcmp does not.
>
> 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?
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists