From 9b1d3e8cb4696cfae7a45a852237f022de65e2a3 Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Mon, 16 Nov 2026 01:59:01 +0200 Subject: [PATCH] libusb: match path loop index to port count Use int for the get_path loop index, matching num_ports. The count is already bounded by the eight-entry libusb buffer, so this preserves behavior while avoiding CodeQL's comparison-with-wider-type finding. Assisted-by: Codex:GPT-6 --- libusb/hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libusb/hid.c b/libusb/hid.c index 5541501ac..faf8c7437 100644 --- a/libusb/hid.c +++ b/libusb/hid.c @@ -585,7 +585,7 @@ static void get_path(char (*result)[64], libusb_device *dev, int config_number, if (num_ports > 0) { int n = snprintf(str, sizeof("000-000"), "%u-%u", libusb_get_bus_number(dev), port_numbers[0]); - for (uint8_t i = 1; i < num_ports; i++) { + for (int i = 1; i < num_ports; i++) { n += snprintf(&str[n], sizeof(".000"), ".%u", port_numbers[i]); } n += snprintf(&str[n], sizeof(":000.000"), ":%u.%u", (uint8_t)config_number, (uint8_t)interface_number);