]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
tty: xtensa/iss: Use min() to fix Coccinelle warning
authorThorsten Blum <thorsten.blum@toblux.com>
Thu, 4 Apr 2024 07:58:13 +0000 (09:58 +0200)
committerMax Filippov <jcmvbkbc@gmail.com>
Thu, 4 Apr 2024 09:10:44 +0000 (02:10 -0700)
Inline strlen() and use min() to fix the following Coccinelle/coccicheck
warning reported by minmax.cocci:

WARNING opportunity for min()

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Message-Id: <20240404075811.6936-3-thorsten.blum@toblux.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/platforms/iss/console.c

index 8896e691c051eab87ba88ffcbac01bd4860df0de..abec44b687dff0d4da3a77307603a0866a35ce88 100644 (file)
@@ -166,10 +166,8 @@ late_initcall(rs_init);
 
 static void iss_console_write(struct console *co, const char *s, unsigned count)
 {
-       if (s && *s != 0) {
-               int len = strlen(s);
-               simc_write(1, s, count < len ? count : len);
-       }
+       if (s && *s != 0)
+               simc_write(1, s, min(count, strlen(s)));
 }
 
 static struct tty_driver* iss_console_device(struct console *c, int *index)