From f75ced2ab5690a3da72c2f83947a854a9f96871e Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 31 Jul 2020 13:22:44 +0200 Subject: [PATCH] tests/iio_common: Fix HEX value parsing in sanitize_clamp() Right now iio_reg and possibly other tools are broken. Registers and values are typically provided in hex values. strtoul() with base 10 returns error when hex values are parsed. So iio_reg will always clear register 0 which in most cases will reset the device. Signed-off-by: Michael Hennerich --- tests/iio_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/iio_common.c b/tests/iio_common.c index 0b789c6f8..8d38f78fc 100644 --- a/tests/iio_common.c +++ b/tests/iio_common.c @@ -137,7 +137,7 @@ unsigned long int sanitize_clamp(const char *name, const char *argv, /* sanitized buffer by taking first 20 (or less) char */ iio_snprintf(buf, sizeof(buf), "%s", argv); errno = 0; - val = strtoul(buf, &end, 10); + val = strtoul(buf, &end, 0); if (buf == end || errno == ERANGE) val = 0; }