[PATCH v2] tty: xtensa/iss: Use min() to fix Coccinelle warning
From: Thorsten Blum
Date: Thu Apr 04 2024 - 03:38:47 EST
Use unsigned size_t to improve len data type and min() to fix the
following Coccinelle/coccicheck warning reported by minmax.cocci:
WARNING opportunity for min()
Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxxx>
---
Changes in v2:
- Use min() instead of umin() as suggested by Jiri Slaby
---
arch/xtensa/platforms/iss/console.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 8896e691c051..d2380767f3a4 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -167,8 +167,9 @@ 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);
+ size_t len = strlen(s);
+
+ simc_write(1, s, min(count, len));
}
}
--
2.44.0