Reset the number of bytes to zero on error
The hidapi read and write functions return a negative value if an error occurs. Those negative values should not be returned to the caller as the actual number of bytes (or used in the logging). The value is reset to zero instead.
This commit is contained in:
parent
d251b373be
commit
b82d5fcfff
@ -362,6 +362,7 @@ dc_usbhid_read (dc_usbhid_t *usbhid, void *data, size_t size, size_t *actual)
|
||||
if (nbytes < 0) {
|
||||
ERROR (usbhid->context, "Usb read interrupt transfer failed.");
|
||||
status = DC_STATUS_IO;
|
||||
nbytes = 0;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
@ -422,6 +423,7 @@ dc_usbhid_write (dc_usbhid_t *usbhid, const void *data, size_t size, size_t *act
|
||||
if (nbytes < 0) {
|
||||
ERROR (usbhid->context, "Usb write interrupt transfer failed.");
|
||||
status = DC_STATUS_IO;
|
||||
nbytes = 0;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user