You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix -d device selection silently matching nothing for bare hex USB IDs (#571)
parse_two_ids() read a token without a 0x prefix as decimal, and std::from_chars
reports success when it consumes only part of the input. "1b1c" therefore
stopped at the 'b' and yielded 1, so -d 1b1c:0a64 built the filter 0001:0000,
matched nothing, and surfaced as "No supported device found" - as though the
device were unplugged. The help text has documented this form (1038:12ad) all
along, and 12ad cannot be anything but hex.
parse_two_ids() gains a base for unprefixed tokens, defaulting to 10 so existing
callers are unaffected. The two call sites parsing USB vendor/product IDs - -d in
main.cpp and --device in dev.cpp - ask for base 16, matching how lsusb and our
own device listing print them. An explicit 0x prefix still forces hex. --usage in
dev mode is not a USB ID and documents a decimal range, so it keeps base 10.
Partial parses are now rejected outright rather than truncated, so a malformed
value reports a format error instead of quietly becoming a filter that matches
nothing.
-d also cast the parsed IDs straight to uint16_t. An out-of-range value wrapped
to 0, and matchesDevice() treats 0 as "no filter", so -d 10000:0a64 matched any
vendor and -d 10000:10000 matched everything connected. Both are now rejected;
0 itself stays accepted as the existing no-filter default.
Note: -d 1234:5678 previously meant decimal (1234, 5678) and now means
(0x1234, 0x5678).
0 commit comments