mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@toblux.com>
To: jirislaby@kernel.org
Cc: chris@zankel.net, gregkh@linuxfoundation.org, jcmvbkbc@gmail.com,
	linux-kernel@vger.kernel.org, thorsten.blum@toblux.com
Subject: [PATCH v2] tty: xtensa/iss: Use min() to fix Coccinelle warning
Date: Thu,  4 Apr 2024 09:38:02 +0200	[thread overview]
Message-ID: <20240404073801.5716-2-thorsten.blum@toblux.com> (raw)
In-Reply-To: <fba2102e-aefc-4be4-905a-57061c1f8cce@kernel.org>

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@toblux.com>
---
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


  parent reply	other threads:[~2024-04-04  7:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 23:47 [PATCH] tty: xtensa/iss: Use umin() " 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   ` Thorsten Blum [this message]
2024-04-04  7:41     ` [PATCH v2] tty: xtensa/iss: Use min() " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240404073801.5716-2-thorsten.blum@toblux.com \
    --to=thorsten.blum@toblux.com \
    --cc=chris@zankel.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jcmvbkbc@gmail.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®