Skip to contentSkip to conversation

xtensa: ISS: don't use string pointer before NULL check

PATCH New Max Filippov 1 participant 1 message Aug 10, 2021 Tensilica Xtensa port (xtensa)

lore
Share & tools
lore

Max Filippov

author maintainer
#0 lore raw

PATCH 1/1 xtensa: ISS: don't use string pointer before NULL check

Move strlen call inside the if block that checks string pointer for NULL. While at it also fix the following coccicheck warning:

./arch/xtensa/platforms/iss/console.c:204:10-11: WARNING comparing pointer to 0.

---
 arch/xtensa/platforms/iss/console.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/xtensa/platforms/iss/console.c +3 -3
index a3dda25a4e45..8f41c0088220 100644
@@ -193,10 +193,10 @@ late_initcall(rs_init);
 
 static void iss_console_write(struct console *co, const char *s, unsigned count)
 {
-	int len = strlen(s);
-
-	if (s != 0 && *s != 0)
+	if (s && *s != 0) {
+		int len = strlen(s);
 		simc_write(1, s, count < len ? count : len);
+	}
 }
 
 static struct tty_driver* iss_console_device(struct console *c, int *index)
Signature · 1 line
2.20.1