descriptor: Miscellaneous improvements to the overall source

Introduce union types that simplify working with descriptors. Previously
there were simple arrays declared on the stack and these were either
parsed into the target descriptor structure or were accessed with magic
offsets into the array. Using the union type allows the descriptors to
be read with the need to parse it into a separate structure.

Fix a memory leak that would occur in the interface parsing code if the
usbi_reallocf() function failed. Each interface has a separately
allocated array of endpoints and potential extra descriptors. These
cannot be freed when using usbi_reallocf(), so switch to use realloc().

Fix an obscure limitation where extra descriptors would not be appended
to the configuration is any previous extra descriptors had already been
found.

Make the error checking and error messages consistent across all the
parsing functions. This includes printing unknown or unexpected
descriptor types in hex format, which is often easier to lookup as most
specifications use hex notation.

Constify the input buffer argument to the parsing functions.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2 files changed
tree: 39a096c35ab7816e6fb8b3fa086b2d1408f5c583
  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. AUTHORS
  14. autogen.sh
  15. bootstrap.sh
  16. ChangeLog
  17. configure.ac
  18. COPYING
  19. INSTALL_WIN.txt
  20. libusb-1.0.pc.in
  21. Makefile.am
  22. NEWS
  23. PORTING
  24. README.git
  25. README.md
  26. test
  27. TODO
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, Haiku and Solaris 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)