Skip to content

libusb: match path loop index to port count - #856

Merged
Youw merged 1 commit into
masterfrom
fix-libusb-path-loop-index
Nov 16, 2026
Merged

Youw merged 1 commit into
masterfrom
fix-libusb-path-loop-index

Conversation

@Youw

@Youw Youw commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Use int for the get_path() loop index to match num_ports, removing CodeQL's cpp/comparison-with-wider-type finding with a one-line change.

This is a false positive under the libusb API contract: libusb_get_port_numbers() returns the number of entries filled or an overflow error, so the eight-entry buffer already bounds the count. Widening the index preserves path formatting and error handling for enumeration and hid_open_path().

Validation: the libusb backend builds with -Wall -Wextra -Werror, and all 26 existing libusb CTest cases pass. Required CI checks pass, and the label-gated CodeQL scans pass on Linux, Windows and macOS with zero reported findings and no analysis errors or warnings.

Addresses CodeQL alert 1.

Related to #854 and #596.

Assisted-by: Codex:GPT-6

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
@Youw Youw added the ci-codeql Triggers CodeQL scan label Nov 15, 2026
@Youw
Youw merged commit 3348de6 into master Nov 16, 2026
37 of 40 checks passed
@Youw
Youw deleted the fix-libusb-path-loop-index branch November 16, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-codeql Triggers CodeQL scan

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant