> 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 to usbdevs.

For what it's worth.

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 zero is always under the administration of the hub driver and is 
about to be moved to a non-zero address.

Valid USB  device addresses are always in the range [1..127].

So (independent of the advisability of using atoi()), it's completely 
reasonable to use 0 as an illegal USB device address, and reject any attempt to 
specify that.  If looking into `usbdevs`, it would make sense to check this 
kind of thing.

The man page for usbdevs is not clear on what is meant by "address"; if there 
are multiple host controllers, there may be many devices with the same 
numerical address, each on a different host controller/bus. Generally an 
address should include a host controller (or bus ID) in order to be useful. I'm 
not sure what `usbdevs` is trying to do.  For better or worse, `lsusb` on a 
typical Linux userland does take all this into account, and is the way most 
people think of this these days; if selecting device by address you also 
include the bus.

Best regards,
--Terry

Reply via email to