[PATCH] iio: multiplexer: fix unsigned check with less than zero

From: Colin King
Date: Tue Mar 07 2017 - 11:41:19 EST


From: Colin Ian King <colin.king@xxxxxxxxxxxxx>

Comparing a size_t with less than zero is always false as size_t
is unsigned. The intent of the comparison was to check if the size
was -1 (that is, undefined), so use that instead.

Detected by CoverityScan, CID#1415278 ("Unsigned compared against 0")

Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
---
drivers/iio/multiplexer/iio-mux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c
index 94d40f9b..6c23033 100644
--- a/drivers/iio/multiplexer/iio-mux.c
+++ b/drivers/iio/multiplexer/iio-mux.c
@@ -61,7 +61,7 @@ static int iio_mux_select(struct mux *mux, int idx)

cache = &child->ext_info_cache[i];

- if (cache->size < 0)
+ if (cache->size == (size_t)-1)
continue;

ret = iio_write_channel_ext_info(mux->parent, attr,
--
2.10.2