From: Jiri Slaby <jirislaby@kernel.org>
To: Thorsten Blum <thorsten.blum@toblux.com>
Cc: chris@zankel.net, gregkh@linuxfoundation.org, jcmvbkbc@gmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] tty: xtensa/iss: Use min() to fix Coccinelle warning
Date: Thu, 4 Apr 2024 09:41:37 +0200 [thread overview]
Message-ID: <528c6824-287e-4be2-82f3-7fcdd254eb15@kernel.org> (raw)
In-Reply-To: <20240404073801.5716-2-thorsten.blum@toblux.com>
On 04. 04. 24, 9:38, Thorsten Blum wrote:
> 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));
So do you need 'len' after all :)?
if (s && *s != 0)
simc_write(1, s, min(count, strlen(s)));
sounds good.
> }
> }
>
--
js
suse labs
next prev parent reply other threads:[~2024-04-04 7:41 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 ` [PATCH v2] tty: xtensa/iss: Use min() " Thorsten Blum
2024-04-04 7:41 ` Jiri Slaby [this message]
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=528c6824-287e-4be2-82f3-7fcdd254eb15@kernel.org \
--to=jirislaby@kernel.org \
--cc=chris@zankel.net \
--cc=gregkh@linuxfoundation.org \
--cc=jcmvbkbc@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=thorsten.blum@toblux.com \
/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®