From: Joe Perches <joe@perches.com>
To: Len Baker <len.baker@gmx.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
David Laight <David.Laight@aculab.com>,
Kees Cook <keescook@chromium.org>,
linux-hardening@vger.kernel.org,
linux-iio <linux-iio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4] drivers/iio: Remove all strcpy() uses
Date: Sun, 15 Aug 2021 09:58:02 -0700 [thread overview]
Message-ID: <eb51990402a466821b855092a3fa2171b5a98bcf.camel@perches.com> (raw)
In-Reply-To: <20210815163639.GA97260@titan>
On Sun, 2021-08-15 at 18:36 +0200, Len Baker wrote:
> Hi Joe,
Hello Len.
Don't take this advice too seriously, it's just bikeshedding
but it seems to me an unexpected use of a strcmp equivalent
in a non performance sensitive path.
> On Sun, Aug 15, 2021 at 08:06:45AM -0700, Joe Perches wrote:
[]
> > bikeshed:
> >
> > I think this change is less intelligible than the original strcmp.
>
> So, if I understand correctly you suggest to change the above line for:
> else if (strcmp(orient, "0") == 0)
Yes.
In kernel sources it's about 2:1 in favor of '!strcmp()' over 'strcmp() == 0'
$ git grep -P '\!\s*strcmp\b' | wc -l
3457
$ git grep -P '\bstrcmp\s*\([^\)]+\)\s*==\s*0\b' | wc -l
1719
And it's your choice to use one or the other or just your V4 patch.
btw, according to godbolt:
gcc -O2 doesn't call strcmp and produces the same object code as your
byte comparisons. clang 11 calls strcmp regardless of optimization level.
next prev parent reply other threads:[~2021-08-15 16:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-14 13:55 Len Baker
2021-08-14 19:36 ` Andy Shevchenko
2021-08-15 8:19 ` Len Baker
2021-08-15 14:45 ` Jonathan Cameron
2021-08-15 15:59 ` Jonathan Cameron
2021-08-15 15:06 ` Joe Perches
2021-08-15 16:36 ` Len Baker
2021-08-15 16:58 ` Joe Perches [this message]
2021-08-15 17:12 ` Len Baker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb51990402a466821b855092a3fa2171b5a98bcf.camel@perches.com \
--to=joe@perches.com \
--cc=David.Laight@aculab.com \
--cc=andy.shevchenko@gmail.com \
--cc=jic23@kernel.org \
--cc=keescook@chromium.org \
--cc=lars@metafoo.de \
--cc=len.baker@gmx.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®