mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tty: xtensa/iss: Use umin() to fix Coccinelle warning
@ 2024-04-03 23:47 Thorsten Blum
  2024-04-04  2:10 ` Max Filippov
  2024-04-04  5:05 ` Jiri Slaby
  0 siblings, 2 replies; 9+ messages in thread
From: Thorsten Blum @ 2024-04-03 23:47 UTC (permalink / raw)
  To: Chris Zankel, Max Filippov
  Cc: Greg Kroah-Hartman, Jiri Slaby (SUSE), linux-kernel, Thorsten Blum

Use unsigned size_t to improve len data type and umin() to fix the
following Coccinelle/coccicheck warning reported by minmax.cocci:

	WARNING opportunity for min()

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 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..b493fc50933d 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, umin(count, len));
 	}
 }
 
-- 
2.44.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-04  9:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-03 23:47 [PATCH] tty: xtensa/iss: Use umin() to fix Coccinelle warning Thorsten Blum
2024-04-04  2:10 ` Max Filippov
2024-04-04  5:05 ` Jiri Slaby
2024-04-04  7:35   ` Thorsten Blum
2024-04-04  7:38   ` [PATCH v2] tty: xtensa/iss: Use min() " Thorsten Blum
2024-04-04  7:41     ` Jiri Slaby
2024-04-04  7:58       ` [PATCH v3] " Thorsten Blum
2024-04-04  8:11         ` Jiri Slaby
2024-04-04  9:12         ` Max Filippov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®