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>] [day] [month] [year] [list]
Message-ID: <Yh18r0jpHjswyksi@yoga>
Date:   Mon, 28 Feb 2022 19:53:51 -0600
From:   Bjorn Andersson <bjorn.andersson@...aro.org>
To:     lotte bai <baihaowen88@...il.com>
Cc:     agross@...nel.org, linux-arm-msm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] soc: qcom: qmi: Use min() instead of doing it manually

On Mon 28 Feb 19:36 CST 2022, lotte bai wrote:

> Fix following coccicheck warning:
> drivers/soc/qcom/qmi_interface.c:773:12-13: WARNING opportunity for min()
> 

Thanks for the patch Haowen.

> Signed-off-by: Haowen Bai <baihaowen88@...il.com>
> ---
>  drivers/soc/qcom/qmi_interface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/qcom/qmi_interface.c
> b/drivers/soc/qcom/qmi_interface.c
> index c8c4c73..3337a70 100644
> --- a/drivers/soc/qcom/qmi_interface.c
> +++ b/drivers/soc/qcom/qmi_interface.c
> @@ -770,7 +770,7 @@ static ssize_t qmi_send_message(struct qmi_handle *qmi,
> 
>          kfree(msg);
> 
> -       return ret < 0 ? ret : 0;
> +       return min(ret, 0);

The code isn't trying to say "return the minimum of ret and 0", it says
"if ret is negative return that, otherwise return 0".

Mathematically this happens to be the same, but for me as reader of the
code they have different meaning.

Regards,
Bjorn

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ