Change the errcode argument in libusb_strerror to be of type int

It would be more convenient in practice if the type of error code
argument in libusb_strerror was declared as "int", rather than
enum libusb_error: In practice, the value for the argument almost
always comes from a value returned by libusb function, thus its
type is "int" at that point. In which case, depending on the
checks enabled when compiling the C or C++ code of applications
using libusb's API, every call to libusb_strerror often requires
explicit type casting – while not a biggie, it gets inconvenient
as the number of logging calls using libusb_strerror grows.

It is worth of noting that the "peer" function libusb_error_name
already takes the int-type argument, thus eliminating the need in
extra value casting. Aligning the signature of libusb_strerror
to be the same would also improve the consistency between those
two parts of the libusb API.

Given that libusb_strerror does a range validation of its argument
value, there should not be any real drawbacks or negative effects
from "relaxing" the type declaration from enumeration to integer.
The existing application code that already does explicit casting
to enum, will keep compiling and running like before.

Closes #606

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
3 files changed
tree: 408740a337c36d263140c249551ed1549d21e1eb
  1. .private/
  2. android/
  3. doc/
  4. examples/
  5. libusb/
  6. msvc/
  7. tests/
  8. Xcode/
  9. .gitattributes
  10. .gitignore
  11. .travis.yml
  12. appveyor.yml
  13. appveyor_cygwin.bat
  14. appveyor_minGW.bat
  15. AUTHORS
  16. autogen.sh
  17. bootstrap.sh
  18. Brewfile
  19. ChangeLog
  20. configure.ac
  21. COPYING
  22. INSTALL_WIN.txt
  23. libusb-1.0.pc.in
  24. Makefile.am
  25. NEWS
  26. PORTING
  27. README.git
  28. README.md
  29. TODO
  30. travis-autogen.sh
README.md

libusb

Build Status Build status Coverity Scan Build Status

libusb is a library for USB device access from Linux, macOS, Windows, OpenBSD/NetBSD and Haiku userspace. It is written in C (Haiku backend in C++) and licensed under the GNU Lesser General Public License version 2.1 or, at your option, any later version (see COPYING).

libusb is abstracted internally in such a way that it can hopefully be ported to other operating systems. Please see the PORTING file for more information.

libusb homepage: http://libusb.info/

Developers will wish to consult the API documentation: http://api.libusb.info

Use the mailing list for questions, comments, etc: http://mailing-list.libusb.info

(Please use the mailing list rather than mailing developers directly)