mirror of
https://github.com/libusb/libusb
synced 2024-11-21 06:26:10 -07:00
Avoid assignments within if
statements
Fixes all clang-tidy bugprone-assignment-in-if-condition warnings References #1479
This commit is contained in:
parent
a18a964aba
commit
9cf84577ce
5 changed files with 23 additions and 14 deletions
|
@ -2,7 +2,6 @@
|
|||
Checks: "-*,\
|
||||
boost-*,\
|
||||
bugprone-*,\
|
||||
-bugprone-assignment-in-if-condition,\
|
||||
-bugprone-branch-clone,\
|
||||
-bugprone-easily-swappable-parameters,\
|
||||
-bugprone-misplaced-widening-cast,\
|
||||
|
|
|
@ -546,11 +546,14 @@ static int test_mass_storage(libusb_device_handle *handle, uint8_t endpoint_in,
|
|||
get_sense(handle, endpoint_in, endpoint_out);
|
||||
} else {
|
||||
display_buffer_hex(data, size);
|
||||
if ((binary_dump) && ((fd = fopen(binary_name, "w")) != NULL)) {
|
||||
if (fwrite(data, 1, (size_t)size, fd) != (unsigned int)size) {
|
||||
perr(" unable to write binary data\n");
|
||||
if (binary_dump) {
|
||||
fd = fopen(binary_name, "w");
|
||||
if (fd != NULL) {
|
||||
if (fwrite(data, 1, (size_t)size, fd) != (unsigned int)size) {
|
||||
perr(" unable to write binary data\n");
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
|
@ -628,11 +631,14 @@ static int test_hid(libusb_device_handle *handle, uint8_t endpoint_in)
|
|||
return -1;
|
||||
}
|
||||
display_buffer_hex(hid_report_descriptor, (unsigned int)descriptor_size);
|
||||
if ((binary_dump) && ((fd = fopen(binary_name, "w")) != NULL)) {
|
||||
if (fwrite(hid_report_descriptor, 1, (size_t)descriptor_size, fd) != (size_t)descriptor_size) {
|
||||
printf(" Error writing descriptor to file\n");
|
||||
if (binary_dump) {
|
||||
fd = fopen(binary_name, "w");
|
||||
if (fd != NULL) {
|
||||
if (fwrite(hid_report_descriptor, 1, (size_t)descriptor_size, fd) != (size_t)descriptor_size) {
|
||||
printf(" Error writing descriptor to file\n");
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
size = get_hid_record_size(hid_report_descriptor, descriptor_size, HID_REPORT_TYPE_FEATURE);
|
||||
|
|
|
@ -2701,7 +2701,8 @@ static int darwin_alloc_streams (struct libusb_device_handle *dev_handle, uint32
|
|||
|
||||
/* find the minimum number of supported streams on the endpoint list */
|
||||
for (i = 0 ; i < num_endpoints ; ++i) {
|
||||
if (0 != (rc = ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface))) {
|
||||
rc = ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface);
|
||||
if (0 != rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -2734,7 +2735,8 @@ static int darwin_free_streams (struct libusb_device_handle *dev_handle, unsigne
|
|||
int rc;
|
||||
|
||||
for (int i = 0 ; i < num_endpoints ; ++i) {
|
||||
if (0 != (rc = ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface)))
|
||||
rc = ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface);
|
||||
if (0 != rc)
|
||||
return rc;
|
||||
|
||||
(*IOINTERFACE_V(cInterface, 550))->SupportsStreams (IOINTERFACE(cInterface), pipeRef, &supportsStreams);
|
||||
|
|
|
@ -1 +1 @@
|
|||
#define LIBUSB_NANO 11921
|
||||
#define LIBUSB_NANO 11922
|
||||
|
|
|
@ -114,7 +114,8 @@ static thread_return_t THREAD_CALL_TYPE init_and_exit(void * arg)
|
|||
for (ti->iteration = 0; ti->iteration < ITERS && !ti->err; ti->iteration++) {
|
||||
libusb_context *ctx = NULL;
|
||||
|
||||
if ((ti->err = libusb_init_context(&ctx, /*options=*/NULL, /*num_options=*/0)) != 0) {
|
||||
ti->err = libusb_init_context(&ctx, /*options=*/NULL, /*num_options=*/0);
|
||||
if (ti->err != 0) {
|
||||
break;
|
||||
}
|
||||
if (ti->enumerate) {
|
||||
|
@ -127,7 +128,8 @@ static thread_return_t THREAD_CALL_TYPE init_and_exit(void * arg)
|
|||
for (int i = 0; i < ti->devcount && ti->err == 0; i++) {
|
||||
libusb_device *dev = devs[i];
|
||||
struct libusb_device_descriptor desc;
|
||||
if ((ti->err = libusb_get_device_descriptor(dev, &desc)) != 0) {
|
||||
ti->err = libusb_get_device_descriptor(dev, &desc);
|
||||
if (ti->err != 0) {
|
||||
break;
|
||||
}
|
||||
if (no_access[i]) {
|
||||
|
|
Loading…
Reference in a new issue