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

Re: [PATCH 2/2] powerpc/pseries: Avoid strlen() in do_{remove,update}_property()

flat view

From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
Date: 2026-07-31 07:15:32
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().

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