From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Artem Lytkin <iprintercanon@gmail.com>
Cc: Marc Dietrich <marvin24@gmx.de>,
ac100@lists.launchpad.net, linux-tegra@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: nvec: use strcmp() instead of strncmp() with magic length
Date: Sat, 7 Feb 2026 14:41:33 +0100 [thread overview]
Message-ID: <2026020754-finalist-unbent-f4fd@gregkh> (raw)
In-Reply-To: <20260205234632.1964-1-iprintercanon@gmail.com>
On Thu, Feb 05, 2026 at 11:46:32PM +0000, Artem Lytkin wrote:
> Replace strncmp() with a hardcoded length of 30 with strcmp().
> The bat_type string is already null-terminated (set two lines above),
> so strncmp() with an arbitrary length is misleading and functionally
> equivalent to strcmp().
>
> Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
> ---
> drivers/staging/nvec/nvec_power.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/nvec/nvec_power.c b/drivers/staging/nvec/nvec_power.c
> index 2faab9fde..89dd997aa 100644
> --- a/drivers/staging/nvec/nvec_power.c
> +++ b/drivers/staging/nvec/nvec_power.c
> @@ -207,7 +207,7 @@ static int nvec_power_bat_notifier(struct notifier_block *nb,
> * This differs a little from the spec fill in more if you find
> * some.
> */
> - if (!strncmp(power->bat_type, "Li", 30))
> + if (!strcmp(power->bat_type, "Li"))
Now the checking tools that look for "strcmp() is bad!" will come along
and someone will send a patch that essencially reverts this :)
Please just leave this as-is, it's really fine and is not broken, right?
thanks,
greg k-h
prev parent reply other threads:[~2026-02-07 13:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 23:46 [PATCH] staging: nvec: use strcmp() instead of strncmp() with magic length Artem Lytkin
2026-02-07 13:41 ` Greg Kroah-Hartman [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=2026020754-finalist-unbent-f4fd@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=ac100@lists.launchpad.net \
--cc=iprintercanon@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=marvin24@gmx.de \
/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