[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190313150133.117e2b63@gandalf.local.home>
Date: Wed, 13 Mar 2019 15:01:33 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Nick Desaulniers <ndesaulniers@...gle.com>
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, 13 Mar 2019 11:51:09 -0700
Nick Desaulniers <ndesaulniers@...gle.com> wrote:
> > 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.
I figured you would say as much ;-)
>
> >
> > 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, as different implementations only
need to return non-zero for non matches. The non-zero has no other
meaning like it does in memcmp(). You could add that memcmp() itself is
one implementation of bcmp() but not vice versa.
-- Steve
Powered by blists - more mailing lists