diff mbox series

iio: st_accel: remove unnecessary comparison of unsigned integer with < 0

Message ID 20190318173302.GA10761@embeddedor (mailing list archive)
State New, archived
Headers show
Series iio: st_accel: remove unnecessary comparison of unsigned integer with < 0 | expand

Commit Message

Gustavo A. R. Silva March 18, 2019, 5:33 p.m. UTC
There is no need to compare *val* with < 0 because such comparison
of an unsigned value is always false.

Fix this by removing such comparison.

Addresses-Coverity-ID: 1443919 ("Unsigned compared against 0")
Fixes: f38ab20b749d ("iio: st_accel: use ACPI orientation data")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/iio/accel/st_accel_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron March 24, 2019, 12:25 p.m. UTC | #1
On Mon, 18 Mar 2019 12:33:02 -0500
"Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:

> There is no need to compare *val* with < 0 because such comparison
> of an unsigned value is always false.
> 
> Fix this by removing such comparison.
> 
> Addresses-Coverity-ID: 1443919 ("Unsigned compared against 0")
> Fixes: f38ab20b749d ("iio: st_accel: use ACPI orientation data")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Thanks,

Colin King got there first and I have a patch fixing this queued up.

Jonathan

> ---
>  drivers/iio/accel/st_accel_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index a3c0916479fa..9930edf423bf 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -992,7 +992,7 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev,
>  			goto out;
>  
>  		val = elements[i].integer.value;
> -		if (val < 0 || val > 2)
> +		if (val > 2)
>  			goto out;
>  
>  		/* Avoiding full matrix multiplication, we simply reorder the
diff mbox series

Patch

diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index a3c0916479fa..9930edf423bf 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -992,7 +992,7 @@  static int apply_acpi_orientation(struct iio_dev *indio_dev,
 			goto out;
 
 		val = elements[i].integer.value;
-		if (val < 0 || val > 2)
+		if (val > 2)
 			goto out;
 
 		/* Avoiding full matrix multiplication, we simply reorder the