Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/iio_common: Fix HEX value parsing in sanitize_clamp() #580

Merged
merged 1 commit into from
Aug 3, 2020

Conversation

mhennerich
Copy link
Contributor

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]

@mhennerich mhennerich requested review from rgetz and dNechita July 31, 2020 11:22
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]>
@rgetz
Copy link
Contributor

rgetz commented Jul 31, 2020

strtoul with base 0 will accept decimal, hex (with leading 0x) and octal (with leading `0).

printf("%lu\n", strtoul("014",NULL,0));
12

as long as that we what we want - that works. Just need to add that to the man pages. (and I agree - adding a -v option to iio_reg print out what it is doing would also be a good idea).

@dNechita dNechita merged commit 692c818 into master Aug 3, 2020
@dNechita dNechita deleted the fix-tools branch August 3, 2020 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants