RE: [patch] usbdevs(8) use strtol(3) instead of atoi(3) for more predictable result

2019-11-24 Thread Terry Moore
> Yes, but usbdevs(8) everywhere counts devices from zero, so probably this should be updated, > if it is ok I will take a look there and fix this if need in a separate patch. As you wish. At the very least the man page could be updated to indicate that -a specifies a device *index*, not a *USB bu

RE: [patch] usbdevs(8) use strtol(3) instead of atoi(3) for more predictable result

2019-11-24 Thread Terry Moore
> usbdevs(8) uses atoi(3) to convert a device address given from a > command line argument. > But atoi(3) will return - zero in a case of non-integer value and such > device will be used. > This is kind of unpredictable behaviour to use a device by 0 addr in a > case when wrong > address was given

Re: [patch] usbdevs(8) use strtol(3) instead of atoi(3) for more predictable result

2019-11-24 Thread 'Alexander Kuleshov'
Hello, On 11-24-19, Terry Moore wrote: > > Zero is never a legal address for an operating USB device. (It can appear > transiently during enumeration, but there's no way to operate a device in > that state; so it make no sense for address zero to be used in usermode). A > device at address zer

Re: [patch] usbdevs(8) use strtol(3) instead of atoi(3) for more predictable result

2019-11-24 Thread Robert Elz
Date:Sun, 24 Nov 2019 13:49:56 +0600 From:Alexander Kuleshov Message-ID: | +addr = strtol(optarg, &ep, 10); | Any comments? strtol() returns a long, addr is just int - something needs to be adjusted to avoid value truncation, depending upon what's

Re: [patch] usbdevs(8) use strtol(3) instead of atoi(3) for more predictable result

2019-11-24 Thread Kamil Rytarowski
On 24.11.2019 08:56, Alexander Kuleshov wrote: > I sorry for noise, but wrong artifact hit to the first one patch, > here is the update: > strtoi(3) is easier here than strtol(3). > > diff --git a/usr.sbin/usbdevs/usbdevs.c b/usr.sbin/usbdevs/usbdevs.c > index e8fe1e7e6f4..526c1eade38 100644 >