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

Use strerror() wherever possible #263

Closed
commodo opened this issue Mar 7, 2019 · 5 comments
Closed

Use strerror() wherever possible #263

commodo opened this issue Mar 7, 2019 · 5 comments

Comments

@commodo
Copy link
Contributor

commodo commented Mar 7, 2019

Some error reports are "I get code X", which prompts questions.
We could mitigate this by putting strerror() wherever possible, to also print strerror() strings.
Especially in examples

@rgetz
Copy link
Contributor

rgetz commented Jul 19, 2019

I think iio_attr and iio_info already do this.

Which other examples did you have in mind?

@pcercuei
Copy link
Contributor

There's iio_strerror btw.

@rgetz
Copy link
Contributor

rgetz commented Jul 23, 2019

Ok - a little check...

rgetz@brain:~/github/libiio$ grep iio_strerr ./tests/* -c
./tests/CMakeLists.txt:0
./tests/iio_adi_xflow_check.c:1
./tests/iio_attr.c:10
./tests/iio_genxml.c:0
./tests/iio_info.c:6
./tests/iio_readdev.c:3
./tests/iio_reg.c:0
./tests/iio_writedev.c:3

which isn't too bad -

but

rgetz@brain:~/github/libiio$ grep iio_strerr ./examples/* -c
./examples/ad9361-iiostream.c:0
./examples/ad9371-iiostream.c:0
./examples/adrv9009-iiostream.c:0
./examples/dummy-iiostream.c:0
./examples/iio-monitor.c:0
./examples/Makefile:0

those need some work/care...

@commodo
Copy link
Contributor Author

commodo commented Jul 24, 2019

As I remember, I created this issue because of some repeated reports on EZ would be "running example/code X, I get -22";

I forget which examples they were providing, but likely some of them were ad9361-iiostream.c [for Pluto and other boards with AD9361] and ad9371-iiostream.c .
Naturally, some of our replies were: "-22 is Invalid Argument" or "-110 is Timedout ", etc; so, we tell people to check things, but usually after we look for the strerror() value of that error code.

Not sure how much reduction in EZ questions [of this sort] we'd get by doing this; I just added it here, so I won't forget about it.

rgetz added a commit that referenced this issue Feb 21, 2020
The warn_unused_result attribute causes a warning to be emitted if a caller
of the function with this attribute does not use its return value. This
is normally useful for functions where not checking the result is either
a security problem or normally bug, but can just point out problems in
end user code.

As various backends (USB, Ethernet) are sometimes not 100%, this helps
ensure that users are checking for various error codes, and hopefully
geting meaningful error messages, as requested in #263.

However, this would make most code pretty noisey to compile, only turn this
on if asked (ie someone defines IIO_CHECK_RET)

Signed-off-by: Robin Getz <[email protected]>
rgetz added a commit that referenced this issue Feb 21, 2020
The warn_unused_result attribute causes a warning to be emitted if a caller
of the function with this attribute does not use its return value. This
is normally useful for functions where not checking the result is either
a security problem or normally bug, but can just point out problems in
end user code.

As various backends (USB, Ethernet) are sometimes not 100%, this helps
ensure that users are checking for various error codes, and hopefully
geting meaningful error messages, as requested in #263.

However, this would make most code pretty noisey to compile, only turn this
on if asked (ie someone defines IIO_CHECK_RET)

Signed-off-by: Robin Getz <[email protected]>
@commodo
Copy link
Contributor Author

commodo commented Apr 2, 2020

i guess i'll close this for now;
it's a bit too generic;
and probably won't solve enough EZ issues anyway;

@commodo commodo closed this as completed Apr 2, 2020
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

No branches or pull requests

3 participants