* [PATCH] staging: nvec: use strcmp() instead of strncmp() with magic length
@ 2026-02-05 23:46 Artem Lytkin
2026-02-07 13:41 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Artem Lytkin @ 2026-02-05 23:46 UTC (permalink / raw)
To: Marc Dietrich, Greg Kroah-Hartman
Cc: ac100, linux-tegra, linux-staging, linux-kernel, Artem Lytkin
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"))
power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_LION;
else
power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] staging: nvec: use strcmp() instead of strncmp() with magic length
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
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-02-07 13:41 UTC (permalink / raw)
To: Artem Lytkin
Cc: Marc Dietrich, ac100, linux-tegra, linux-staging, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-07 13:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox