mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: lotte bai <baihaowen88@gmail.com>
Cc: agross@kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] soc: qcom: qmi: Use min() instead of doing it manually
Date: Mon, 28 Feb 2022 19:53:51 -0600	[thread overview]
Message-ID: <Yh18r0jpHjswyksi@yoga> (raw)
In-Reply-To: <CAFo17PjBtoWcrQyxe-Twowf+_5FJ3_OOMjtv950VBR7NocWfhg@mail.gmail.com>

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@gmail.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

       reply	other threads:[~2022-03-01  1:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAFo17PjBtoWcrQyxe-Twowf+_5FJ3_OOMjtv950VBR7NocWfhg@mail.gmail.com>
2022-03-01  1:53 ` Bjorn Andersson [this message]
2022-02-25  8:00 Haowen Bai

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=Yh18r0jpHjswyksi@yoga \
    --to=bjorn.andersson@linaro.org \
    --cc=agross@kernel.org \
    --cc=baihaowen88@gmail.com \
    --cc=linux-arm-msm@vger.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®