Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions transports/libhoth_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ int libhoth_get_usb_loc(libusb_device* dev, struct libhoth_usb_loc* result) {
int libhoth_usb_get_device(libusb_context* ctx,
const struct libhoth_usb_loc* usb_loc,
libusb_device** out) {
if (ctx == NULL || usb_loc == NULL || out == NULL) {
if (ctx == NULL || out == NULL) {
return LIBUSB_ERROR_INVALID_PARAM;
}

Expand All @@ -416,17 +416,19 @@ int libhoth_usb_get_device(libusb_context* ctx,
}

for (ssize_t i = 0; i < num_devices; i++) {
int rev = libhoth_get_usb_loc(device[i], &loc);
if (rev) {
continue;
}
if (usb_loc != NULL) {
int rev = libhoth_get_usb_loc(device[i], &loc);
if (rev) {
continue;
}

bool loc_matches = (loc.bus == usb_loc->bus) &&
(loc.num_ports == usb_loc->num_ports) &&
(memcmp(loc.ports, usb_loc->ports, loc.num_ports) == 0);
bool loc_matches =
(loc.bus == usb_loc->bus) && (loc.num_ports == usb_loc->num_ports) &&
(memcmp(loc.ports, usb_loc->ports, loc.num_ports) == 0);

if (!loc_matches) {
continue;
if (!loc_matches) {
continue;
}
}

struct libusb_device_descriptor device_descriptor;
Expand Down
Loading