aboutsummaryrefslogtreecommitdiff
path: root/contrib/firmware
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2023-07-02 23:48:42 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2023-08-12 16:41:45 +0000
commit3b78b5c1db68841fdc18ee48b6011f4affff2bfd (patch)
tree70477f84c19e4176318036447d02d1fc46b6d8d6 /contrib/firmware
parent51be311f73933d8b51938371a989f1130dec3cfc (diff)
downloadriscv-openocd-3b78b5c1db68841fdc18ee48b6011f4affff2bfd.zip
riscv-openocd-3b78b5c1db68841fdc18ee48b6011f4affff2bfd.tar.gz
riscv-openocd-3b78b5c1db68841fdc18ee48b6011f4affff2bfd.tar.bz2
libusb_helper: split error and returned value
The USB control transfer can be executed without any data. The libusb API libusb_control_transfer() can thus be called with zero 'size', thus returning zero byte transferred when succeed. The OpenOCD API jtag_libusb_control_transfer() returns zero either in case of transfer error and in case of libusb_control_transfer() returning zero, making impossible discriminating the two cases. Extend jtag_libusb_control_transfer() with separate return value for error code and explicit parameter's pointer for transferred bytes. Make the transferred pointer optional, as many callers do not properly handle the returned value. Use 'int' type pointer for transferred, instead of the 'uint16_t' that would have matched the type of 'size'. This can simplify the caller's code by using a single 'int transferred' variable shared with other jtag_libusb_bulk_read|write, while keeping possible the comparison int vs uint16_t without cast. This change is inspired from commit d612baacaa3f ("jtag_libusb_bulk_read|write: return error code instead of size") Change-Id: I14d9bff3e845675be03465c307a136e69eebc317 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7756 Tested-by: jenkins Reviewed-by: ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Diffstat (limited to 'contrib/firmware')
0 files changed, 0 insertions, 0 deletions