diff mbox series

iio: light: fix test for val being not zero or not one.

Message ID 20180730125918.7100-1-colin.king@canonical.com (mailing list archive)
State New, archived
Headers show
Series iio: light: fix test for val being not zero or not one. | expand

Commit Message

Colin King July 30, 2018, 12:59 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The current check on val always results in true and so the
call to sii1133_update_adcsens never gets called. Fix this check
so it returns with -EINVAL only when val is not zero and not one.

Detected by CoverityScan, CID#1472099 ("Logically dead code")

Fixes: e01e7eaf37d8 ("iio: light: introduce si1133")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/iio/light/si1133.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron July 30, 2018, 7:09 p.m. UTC | #1
On Mon, 30 Jul 2018 13:59:18 +0100
Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> The current check on val always results in true and so the
> call to sii1133_update_adcsens never gets called. Fix this check
> so it returns with -EINVAL only when val is not zero and not one.
> 
> Detected by CoverityScan, CID#1472099 ("Logically dead code")
> 
> Fixes: e01e7eaf37d8 ("iio: light: introduce si1133")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks!,

Applied to the fixes-togreg branch of iio.git. Will send upstream after
the merge window closes now.

Jonathan

> ---
>  drivers/iio/light/si1133.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c
> index d3fbeb3bc463..5ac22c46da1f 100644
> --- a/drivers/iio/light/si1133.c
> +++ b/drivers/iio/light/si1133.c
> @@ -838,7 +838,7 @@ static int si1133_write_raw(struct iio_dev *iio_dev,
>  		switch (chan->type) {
>  		case IIO_INTENSITY:
>  		case IIO_UVINDEX:
> -			if (val != 0 || val != 1)
> +			if (val != 0 && val != 1)
>  				return -EINVAL;
>  
>  			return si1133_update_adcsens(data,

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c
index d3fbeb3bc463..5ac22c46da1f 100644
--- a/drivers/iio/light/si1133.c
+++ b/drivers/iio/light/si1133.c
@@ -838,7 +838,7 @@  static int si1133_write_raw(struct iio_dev *iio_dev,
 		switch (chan->type) {
 		case IIO_INTENSITY:
 		case IIO_UVINDEX:
-			if (val != 0 || val != 1)
+			if (val != 0 && val != 1)
 				return -EINVAL;
 
 			return si1133_update_adcsens(data,