Re: [PATCH] iio: humidity: htc100c: Fix checkpatch warn unnecessary else
David Lechner <[email protected]> Sun, 2 Aug 2026 09:48:11 -0500
| Newsgroups | dev.linux.lists.linux-kernel-mentees,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 8/1/26 8:44 PM, Adi Nata wrote:
> Checkpatch warning:
Making checkpatch happy is not a good reason for a change on it's own.
It is only there for guidance. It is not a strict rule that has to be
followed.
I think this is a good change because it reduces duplication of the
return statements and eliminates an unreachable break statement. So
write the commit message with that reasoning and don't mention checkpatch.
>
> WARNING:UNNECESSARY_ELSE: else is not generally useful after a break or return
> + return IIO_VAL_FRACTIONAL;
> + } else {
>
> Signed-off-by: Adi Nata <[email protected]>
> ---
> drivers/iio/humidity/hdc100x.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
> index bc452cc8fbcf..38903239fb9a 100644
> --- a/drivers/iio/humidity/hdc100x.c
> +++ b/drivers/iio/humidity/hdc100x.c
> @@ -229,13 +229,11 @@ static int hdc100x_read_raw(struct iio_dev *indio_dev,
> if (chan->type == IIO_TEMP) {
> *val = 165000;
> *val2 = 65536;
> - return IIO_VAL_FRACTIONAL;
> } else {
> *val = 100000;
> *val2 = 65536;
> - return IIO_VAL_FRACTIONAL;
> }
> - break;
> + return IIO_VAL_FRACTIONAL;
> case IIO_CHAN_INFO_OFFSET:
> *val = -15887;
> *val2 = 515151;