Skip to content

Commit

Permalink
darwin: Fix clang static analyzer warning about a variable that's nev…
Browse files Browse the repository at this point in the history
…er read

Reformulate the loop in a way that the variable is read.

References #1414
  • Loading branch information
seanm authored and tormodvolden committed Apr 4, 2024
1 parent 4e246a7 commit 1c1bad9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions libusb/os/darwin_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,17 +1242,18 @@ static bool get_device_port (io_service_t service, UInt8 *port) {

/* Returns 1 on success, 0 on failure. */
static bool get_device_parent_sessionID(io_service_t service, UInt64 *parent_sessionID) {
IOReturn kresult;
io_service_t parent;

/* Walk up the tree in the IOService plane until we find a parent that has a sessionID */
parent = service;
while((kresult = IORegistryEntryGetParentEntry (parent, kIOUSBPlane, &parent)) == kIOReturnSuccess) {
io_service_t parent = service;
do {
IOReturn kresult = IORegistryEntryGetParentEntry (parent, kIOUSBPlane, &parent);
if (kresult != kIOReturnSuccess) {
break;
}
if (get_ioregistry_value_number (parent, CFSTR("sessionID"), kCFNumberSInt64Type, parent_sessionID)) {
/* Success */
return true;
}
}
} while (true);

/* We ran out of parents */
return false;
Expand Down
2 changes: 1 addition & 1 deletion libusb/version_nano.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define LIBUSB_NANO 11891
#define LIBUSB_NANO 11892

0 comments on commit 1c1bad9

Please sign in to comment.