Skip to content

Commit

Permalink
tests/iio_common: Fix HEX value parsing in sanitize_clamp()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mhennerich committed Jul 31, 2020
1 parent f0089b5 commit f75ced2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/iio_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f75ced2

Please sign in to comment.