From: Alejandro Colomar <alx+linux-hardening@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Alejandro Colomar <alx@kernel.org>,
linux-hardening@vger.kernel.org, Kees Cook <kees@kernel.org>,
Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH v1 4/4] treewide: Use streq(3) instead of unnecessary uses of strncmp(3)
Date: Mon, 16 Nov 2026 13:44:57 +0100 [thread overview]
Message-ID: <avr6VxeIaXatWFBC@devuan> (raw)
In-Reply-To: <avr2OGrm9hHG05lU@ashevche-desk.local>
[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]
Hi Andy,
> Date: 2026-11-16 14:25:28+0200
> From: Andy Shevchenko <andriy.shevchenko@intel.com>
>
> On Sun, Nov 15, 2026 at 07:46:24PM +0100, Alejandro Colomar wrote:
> > Uses of strncmp(foo,"bar",sizeof("bar")) are really the same as
> > strcmp(foo,"bar"). There's no good reason to use strncmp(3).
> >
> > This code seems to have been confused, and probably thought using
> > strncmp(3) was somehow safer than strcmp(3), but it is not.
> >
> > Let's rewrite with streq(3), which makes it more readable.
> > This patch is not changing the behavior of the existing code.
> >
> > These cases were found with the following script:
> >
> > $ git grep -E 'strncmp\([^,]*, [^,]*, sizeof.*[A-Z"]' \
> > | grep -v -- '- 1';
>
> ...
>
> > arch/m68k/sun3/prom/console.c | 6 +++---
>
> I hope you compile-tested this at least. IIRC PROM is early boot stage on m68k
> and PPC.
Yes, but never trust my word for that, as I make mistakes. :)
That's why I try to explicitly show the testing shell session in the
cover letter or in a reply to it. In this case, the cover letter shows
the full testing I did, including a full build with 'allmodconfig'.
Cheers,
Alex
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2026-11-16 12:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 18:46 [PATCH v1 0/4] Add streq(3), and use it to replace confusing uses of strncmp(3) Alejandro Colomar
2026-11-15 18:46 ` [PATCH v1 1/4] string: Add streq() Alejandro Colomar
2026-11-15 18:46 ` [PATCH v1 2/4] tools/: Add streq() to nolibc/string Alejandro Colomar
2026-11-15 18:46 ` [PATCH v1 3/4] treewide: Use streq(3) instead of confusing uses of strncmp(3) Alejandro Colomar
2026-11-15 18:46 ` [PATCH v1 4/4] treewide: Use streq(3) instead of unnecessary " Alejandro Colomar
2026-11-16 12:25 ` Andy Shevchenko
2026-11-16 12:44 ` Alejandro Colomar [this message]
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=avr6VxeIaXatWFBC@devuan \
--to=alx+linux-hardening@kernel.org \
--cc=alx@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=kees@kernel.org \
--cc=linux-hardening@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