All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc/powernv: Avoid strlen() in pnv_restart()
@ 2026-07-21 15:53 Thorsten Blum
  2026-07-21 15:53 ` [PATCH 2/2] powerpc/pseries: Avoid strlen() in do_{remove,update}_property() Thorsten Blum
  2026-07-31  7:14 ` [PATCH 1/2] powerpc/powernv: Avoid strlen() in pnv_restart() Christophe Leroy (CS GROUP)
  0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-07-21 15:53 UTC (permalink / raw)
  To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Aboorva Devarajan
  Cc: Thorsten Blum, linuxppc-dev, linux-kernel

Check only the first byte instead of scanning the entire string with
strlen().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/powerpc/platforms/powernv/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index 06ed5e2aa265..2af92e7ba4ee 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -312,7 +312,7 @@ static void  __noreturn pnv_restart(char *cmd)
 	pnv_prepare_going_down();
 
 	do {
-		if (!cmd || !strlen(cmd))
+		if (!cmd || *cmd == '\0')
 			rc = opal_cec_reboot();
 		else if (strcmp(cmd, "full") == 0)
 			rc = opal_cec_reboot2(OPAL_REBOOT_FULL_IPL, NULL);


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] powerpc/pseries: Avoid strlen() in do_{remove,update}_property()
  2026-07-21 15:53 [PATCH 1/2] powerpc/powernv: Avoid strlen() in pnv_restart() Thorsten Blum
@ 2026-07-21 15:53 ` Thorsten Blum
  2026-07-31  7:15   ` Christophe Leroy (CS GROUP)
  2026-07-31  7:14 ` [PATCH 1/2] powerpc/powernv: Avoid strlen() in pnv_restart() Christophe Leroy (CS GROUP)
  1 sibling, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2026-07-21 15:53 UTC (permalink / raw)
  To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Kees Cook
  Cc: Thorsten Blum, linuxppc-dev, linux-kernel

Check only the first byte instead of scanning the entire string with
strlen().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/powerpc/platforms/pseries/reconfig.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index 7faebcffc9df..18e3f1a036e3 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -307,7 +307,7 @@ static int do_remove_property(char *buf, size_t bufsize)
 	if (tmp)
 		*tmp = '\0';
 
-	if (strlen(buf) == 0)
+	if (*buf == '\0')
 		return -EINVAL;
 
 	return of_remove_property(np, of_find_property(np, buf, NULL));
@@ -330,7 +330,7 @@ static int do_update_property(char *buf, size_t bufsize)
 	if (!next_prop)
 		return -EINVAL;
 
-	if (!strlen(name))
+	if (*name == '\0')
 		return -ENODEV;
 
 	newprop = new_property(name, length, value, NULL);


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] powerpc/powernv: Avoid strlen() in pnv_restart()
  2026-07-21 15:53 [PATCH 1/2] powerpc/powernv: Avoid strlen() in pnv_restart() Thorsten Blum
  2026-07-21 15:53 ` [PATCH 2/2] powerpc/pseries: Avoid strlen() in do_{remove,update}_property() Thorsten Blum
@ 2026-07-31  7:14 ` Christophe Leroy (CS GROUP)
  1 sibling, 0 replies; 4+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-07-31  7:14 UTC (permalink / raw)
  To: Thorsten Blum, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Aboorva Devarajan
  Cc: linuxppc-dev, linux-kernel



Le 21/07/2026 à 17:53, Thorsten Blum a écrit :
> Check only the first byte instead of scanning the entire string with
> strlen().

Well, strlen() is not going to scan the entire string, it will break at 
first 0. But I agreed calling strlen() is not worth it.

> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
>   arch/powerpc/platforms/powernv/setup.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
> index 06ed5e2aa265..2af92e7ba4ee 100644
> --- a/arch/powerpc/platforms/powernv/setup.c
> +++ b/arch/powerpc/platforms/powernv/setup.c
> @@ -312,7 +312,7 @@ static void  __noreturn pnv_restart(char *cmd)
>   	pnv_prepare_going_down();
>   
>   	do {
> -		if (!cmd || !strlen(cmd))
> +		if (!cmd || *cmd == '\0')

Maybe !*cmd instead ?

>   			rc = opal_cec_reboot();
>   		else if (strcmp(cmd, "full") == 0)
>   			rc = opal_cec_reboot2(OPAL_REBOOT_FULL_IPL, NULL);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] powerpc/pseries: Avoid strlen() in do_{remove,update}_property()
  2026-07-21 15:53 ` [PATCH 2/2] powerpc/pseries: Avoid strlen() in do_{remove,update}_property() Thorsten Blum
@ 2026-07-31  7:15   ` Christophe Leroy (CS GROUP)
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-07-31  7:15 UTC (permalink / raw)
  To: Thorsten Blum, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Kees Cook
  Cc: linuxppc-dev, linux-kernel



Le 21/07/2026 à 17:53, Thorsten Blum a écrit :
> Check only the first byte instead of scanning the entire string with
> strlen().
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
>   arch/powerpc/platforms/pseries/reconfig.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
> index 7faebcffc9df..18e3f1a036e3 100644
> --- a/arch/powerpc/platforms/pseries/reconfig.c
> +++ b/arch/powerpc/platforms/pseries/reconfig.c
> @@ -307,7 +307,7 @@ static int do_remove_property(char *buf, size_t bufsize)
>   	if (tmp)
>   		*tmp = '\0';
>   
> -	if (strlen(buf) == 0)
> +	if (*buf == '\0')

Can use !*buf instead.

>   		return -EINVAL;
>   
>   	return of_remove_property(np, of_find_property(np, buf, NULL));
> @@ -330,7 +330,7 @@ static int do_update_property(char *buf, size_t bufsize)
>   	if (!next_prop)
>   		return -EINVAL;
>   
> -	if (!strlen(name))
> +	if (*name == '\0')

Can use !*name instead.

>   		return -ENODEV;
>   
>   	newprop = new_property(name, length, value, NULL);



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-31  7:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 15:53 [PATCH 1/2] powerpc/powernv: Avoid strlen() in pnv_restart() Thorsten Blum
2026-07-21 15:53 ` [PATCH 2/2] powerpc/pseries: Avoid strlen() in do_{remove,update}_property() Thorsten Blum
2026-07-31  7:15   ` Christophe Leroy (CS GROUP)
2026-07-31  7:14 ` [PATCH 1/2] powerpc/powernv: Avoid strlen() in pnv_restart() Christophe Leroy (CS GROUP)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.