descriptor: Miscellaneous improvements to the overall source
authorChris Dickens <christopher.a.dickens@gmail.com>
Thu, 13 Aug 2020 17:31:51 +0000 (10:31 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Thu, 13 Aug 2020 17:31:51 +0000 (10:31 -0700)
commitfa3f91e7c4c73fd233104cf3cad4890dd6121043
tree39a096c35ab7816e6fb8b3fa086b2d1408f5c583
parent7b5e31b8cb427cd95a307c607741cc52a39cb951
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>
libusb/descriptor.c
libusb/version_nano.h