All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Aleksandr Mezin <mezin.alexander@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
	Jean Delvare <jdelvare@suse.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	Abaci Robot <abaci@linux.alibaba.com>
Subject: Re: [PATCH] hwmon: Use min() instead of doing it manually
Date: Tue, 28 Dec 2021 06:18:37 +0600	[thread overview]
Message-ID: <CADnvcfJ_ZxQgrsxxAyrEfMLKFZGuGo6CESCWNyWYtPHkA4ZTsQ@mail.gmail.com> (raw)
In-Reply-To: <e689de7b-033b-0ada-5135-faf7fdb1e26b@roeck-us.net>

On Mon, Dec 27, 2021 at 9:43 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 12/27/21 3:36 AM, Jiapeng Chong wrote:
> > Eliminate following coccicheck warning:
> >
> > ./drivers/hwmon/nzxt-smart2.c:461:12-13: WARNING opportunity for min().
> >
> > Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> > Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> > ---
> >   drivers/hwmon/nzxt-smart2.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/hwmon/nzxt-smart2.c b/drivers/hwmon/nzxt-smart2.c
> > index 534d39b8908e..b30de7441fbb 100644
> > --- a/drivers/hwmon/nzxt-smart2.c
> > +++ b/drivers/hwmon/nzxt-smart2.c
> > @@ -458,7 +458,7 @@ static int send_output_report(struct drvdata *drvdata, const void *data,
> >
> >       ret = hid_hw_output_report(drvdata->hid, drvdata->output_buffer,
> >                                  sizeof(drvdata->output_buffer));
> > -     return ret < 0 ? ret : 0;
> > +     return min(ret, 0);
>
> Nack, that is just confusing. ret is an error if < 0, and min obfuscates
> that we want to return an error or 0.
>
> Guenter

Should I change that ternary operator to a full "if" maybe?
Apparently, both some people and some tools read it as "min()".

  reply	other threads:[~2021-12-28  0:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27 11:36 [PATCH] hwmon: Use min() instead of doing it manually Jiapeng Chong
2021-12-27 15:43 ` Guenter Roeck
2021-12-28  0:18   ` Aleksandr Mezin [this message]
2021-12-28  0:36     ` Guenter Roeck

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=CADnvcfJ_ZxQgrsxxAyrEfMLKFZGuGo6CESCWNyWYtPHkA4ZTsQ@mail.gmail.com \
    --to=mezin.alexander@gmail.com \
    --cc=abaci@linux.alibaba.com \
    --cc=jdelvare@suse.com \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.