From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Alper Ak <alperyasinak1@gmail.com>
Cc: jic23@kernel.org, "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: light: gp2ap020a00f: Fix signedness bug in gp2ap020a00f_get_thresh_reg()
Date: Sat, 27 Dec 2025 17:00:46 +0200 [thread overview]
Message-ID: <aU_0nv6yYjwCsK_Y@smile.fi.intel.com> (raw)
In-Reply-To: <20251226154523.89215-1-alperyasinak1@gmail.com>
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
next prev parent reply other threads:[~2025-12-27 15:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-26 15:45 [PATCH] iio: light: gp2ap020a00f: Fix signedness bug in gp2ap020a00f_get_thresh_reg() Alper Ak
2025-12-27 15:00 ` Andy Shevchenko [this message]
2025-12-31 17:15 ` Jonathan Cameron
2025-12-27 18:24 ` Jonathan Cameron
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=aU_0nv6yYjwCsK_Y@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=alperyasinak1@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/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