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] [day] [month] [year] [list]
Message-ID: <Ys0gJlsZap/Qd1Gi@kroah.com>
Date:   Tue, 12 Jul 2022 09:17:58 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Jiangshan Yi <13667453960@....com>
Cc:     rafael@...nel.org, dri-devel@...ts.freedesktop.org,
        linux-kernel@...r.kernel.org, Jiangshan Yi <yijiangshan@...inos.cn>
Subject: Re: [PATCH] component: replace ternary operator with min()

On Tue, Jul 12, 2022 at 03:12:23PM +0800, Jiangshan Yi wrote:
> From: Jiangshan Yi <yijiangshan@...inos.cn>
> 
> Fix the following coccicheck warning:
> 
> drivers/base/component.c:544: WARNING opportunity for min().
> drivers/base/component.c:740: WARNING opportunity for min().
> 
> min() macro is defined in include/linux/minmax.h. It avoids
> multiple evaluations of the arguments when non-constant and performs
> strict type-checking.
> 
> Signed-off-by: Jiangshan Yi <yijiangshan@...inos.cn>
> ---
>  drivers/base/component.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/component.c b/drivers/base/component.c
> index 5eadeac6c532..349c54694481 100644
> --- a/drivers/base/component.c
> +++ b/drivers/base/component.c
> @@ -541,7 +541,7 @@ int component_master_add_with_match(struct device *parent,
>  
>  	mutex_unlock(&component_mutex);
>  
> -	return ret < 0 ? ret : 0;
> +	return min(ret, 0);

This is a traditional "if there is an error, report it, otherwise return
0" pattern, and not really a min() call.  So perhaps the original should
stay, or be turned into:
	if (ret < 0)
		return ret
	return 0;
to make it more obvious?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ