lkml.org 
[lkml]   [2021]   [Dec]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] hwmon: Use min() instead of doing it manually
From
Date
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

\
 
 \ /
  Last update: 2021-12-27 16:52    [W:0.083 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site