Parse USB bus:dev as decimal integers, to be consistent with --scan-usb.

Do not accept auto-detected base 0 (e.g. prefix '0x' for hex), since '0'
prefix gives an octal interpretation, and the user is likely to copy
values from `--scan-usb` or `lsusb` that could then be misinterpreted,
e.g. 005:010.
This commit is contained in:
Haakan T Johansson 2023-07-29 09:43:32 +02:00
parent 3955a70843
commit bed17f3be8
1 changed files with 2 additions and 2 deletions

View File

@ -895,9 +895,9 @@ int parse_opt(int argc, char **argv, struct arguments *args,
}
try {
args->bus_addr = static_cast<uint8_t>(std::stoi(bus_dev_num[0],
nullptr, 16));
nullptr, 10));
args->device_addr = static_cast<uint8_t>(
std::stoi(bus_dev_num[1], nullptr, 16));
std::stoi(bus_dev_num[1], nullptr, 10));
} catch (std::exception &e) {
printError("Error: busdev-num invalid format: must be numeric values");
throw std::exception();