Repository navigation
libusb: match path loop index to port count - #856
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
intfor theget_path()loop index to matchnum_ports, removing CodeQL'scpp/comparison-with-wider-typefinding 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 andhid_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