diff options
author | Ludovic Rousseau <ludovic.rousseau+github@gmail.com> | 2013-09-22 21:25:00 +0200 |
---|---|---|
committer | Ludovic Rousseau <ludovic.rousseau+github@gmail.com> | 2013-09-28 12:17:58 +0200 |
commit | c393574a0148a826e4be575c356b7b5724190c8c (patch) | |
tree | e32cf9be1dfd8eb90c1e089a278c84f31c25eb9f /examples | |
parent | d4dabfd14e50144c2935c4ef30202a8dd46b5ae6 (diff) | |
download | libusb-c393574a0148a826e4be575c356b7b5724190c8c.tar.gz |
examples: check value returned by libusb_bulk_transfer()
Problem detected by the Coverity tool
CID 1042540 (#1 of 1): Unchecked return value (CHECKED_RETURN)1.
check_return: Calling function "libusb_bulk_transfer(struct
libusb_device_handle *, unsigned char, unsigned char *, int, int *,
unsigned int)" without checking return value (as is done elsewhere 4 out
of 5 times).
Diffstat (limited to 'examples')
-rw-r--r-- | examples/xusb.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/xusb.c b/examples/xusb.c index 4df65c4..829ce41 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -415,6 +415,7 @@ static void get_sense(libusb_device_handle *handle, uint8_t endpoint_in, uint8_t uint8_t sense[18]; uint32_t expected_tag; int size; + int rc; // Request Sense printf("Request Sense:\n"); @@ -424,7 +425,12 @@ static void get_sense(libusb_device_handle *handle, uint8_t endpoint_in, uint8_t cdb[4] = REQUEST_SENSE_LENGTH; send_mass_storage_command(handle, endpoint_out, 0, cdb, LIBUSB_ENDPOINT_IN, REQUEST_SENSE_LENGTH, &expected_tag); - libusb_bulk_transfer(handle, endpoint_in, (unsigned char*)&sense, REQUEST_SENSE_LENGTH, &size, 1000); + rc = libusb_bulk_transfer(handle, endpoint_in, (unsigned char*)&sense, REQUEST_SENSE_LENGTH, &size, 1000); + if (rc < 0) + { + printf("libusb_bulk_transfer failed: %s\n", libusb_error_name(rc)); + return; + } printf(" received %d bytes\n", size); if ((sense[0] != 0x70) && (sense[0] != 0x71)) { |