lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 4 Apr 2024 07:05:34 +0200
From: Jiri Slaby <jirislaby@...nel.org>
To: Thorsten Blum <thorsten.blum@...lux.com>, Chris Zankel
 <chris@...kel.net>, Max Filippov <jcmvbkbc@...il.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tty: xtensa/iss: Use umin() to fix Coccinelle warning

On 04. 04. 24, 1:47, Thorsten Blum wrote:
> 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@...lux.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));

The cast to unsigned (ie. umin()) is now not necessary. You should have 
used min() as was suggested, right?

>   	}
>   }
>   

thanks,
-- 
js
suse labs


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ