Thread (5 messages) 5 messages, 3 authors, 2026-08-03

Re: [PATCH 1/2] powerpc/powernv: Avoid strlen() in pnv_restart()

flat view

From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
Date: 2026-07-31 07:14:09
Also in: lkml


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 <redacted>
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
quoted hunk ↗ jump to hunk
---
  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);
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help