[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aU_0nv6yYjwCsK_Y@smile.fi.intel.com>
Date: Sat, 27 Dec 2025 17:00:46 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Alper Ak <alperyasinak1@...il.com>
Cc: jic23@...nel.org, David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: light: gp2ap020a00f: Fix signedness bug in
gp2ap020a00f_get_thresh_reg()
On Fri, Dec 26, 2025 at 06:45:21PM +0300, Alper Ak wrote:
> gp2ap020a00f_get_thresh_reg() returns -EINVAL on error,
> but it was declared as a u8.
>
> Change the return type to int and update callers to use int type for
> the return value and properly check for negative error codes.
...
> thresh_reg_l = gp2ap020a00f_get_thresh_reg(chan, dir);
> +
This blank line is redundant.
> + if (thresh_reg_l < 0) {
> + err = thresh_reg_l;
> + goto error_unlock;
> + }
And entire code can be rewritten in a shorter way
(in this case the type not needed to be changed):
err = gp2ap020a00f_get_thresh_reg(chan, dir);
if (err < 0)
goto error_unlock;
thresh_reg_l = err;
but this one is up to maintainers as I know Jonathan likes the clear naming
to be assigned to (however when written as above it clear to me what's the
semantics of the non-negative returns).
...
Ditto for the other function.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists