summaryrefslogtreecommitdiff
path: root/msvc/xusb_2019.vcxproj
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-01-23 16:18:24 -0800
committerChris Dickens <christopher.a.dickens@gmail.com>2020-01-24 11:22:52 -0800
commitc3864c822b190dfbef48b0459222a08467f94cfb (patch)
tree8b3a498944772040058f52d5292d7820eeeb150b /msvc/xusb_2019.vcxproj
parentd5bb64b3dc438a0a03c66d08a7fd12de5543f538 (diff)
downloadlibusb-c3864c822b190dfbef48b0459222a08467f94cfb.tar.gz
linux_usbfs: Clean up inconsistencies and optimize memory usage
The formatting and coding style varied across the whole file. Adopt the following consistent style: - Align function arguments to the opening parenthesis - Do not check for NULL before calling free() - Reduce indentation where possible in loops by continuing in the success case - Remove space between function name and opening parenthesis - Remove pointless pointer casts from void * - Replace comparisons with NULL or 0 by a negation operator - When comparing against rvalues, place the rvalue on the right side of the expression - Where possible, have the debug message string on the same line as the usbi_* call. This makes it easier to grep for specific strings. Also update the definitions in linux_usbfs.h to exactly match that of the kernel and remove definitions that are not needed. A number of functions declared stack buffers of size PATH_MAX. This is generally 4K, which is very much overkill for a lot of the strings and is not friendly for embedded environments. Replace many of these buffers with reasonably-sized ones, in many cases using exactly the size needed. When reading the descriptors during device enumeration, we were starting with a 1K buffer and doubling as needed. The vast majority of devices will not have a large set of descriptors, so change the allocation logic to grow the buffer in steps of 256 bytes. Introduce a new parsing function for reading sysfs attributes. Using the fdopen() function to use fscanf() results in excessive memory allocation, one for the FILE object and another for the buffer into which the C library will read the data. The sysfs attributes of interest are generally just a few characters, so use a small stack buffer and some rigorous parsing to read these attributes. This also consolidates error checking (e.g. negative values or larger than expected values). Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'msvc/xusb_2019.vcxproj')
0 files changed, 0 insertions, 0 deletions