Wireless mouse battery level patch

Matthew Williams mrw7mrw at yahoo.ca
Fri Sep 15 15:10:54 PDT 2006


Kay Sievers wrote:
> There is no such thing, udev contains no "standard rules".

I was referring to the rules in the udev distribution tarball.

> 
>> SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev};
>> B=$${X%%%%.*}; D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c"
>>
>> Although your udev rule would also fix this particular problem, the patch
>> itself delivers a better comparison in any case.  It doesn't make sense to
>> do a string compare of two pairs of integer values.  Your change also
>> doesn't cover off the difference in hex vs decimal for /proc/bus/usb vs
>> /dev/bus/usb.
> 
> What makes you think, that it's hex?

The code for the mouse battery level was taken from lmctl which indicated
that the bus and device numbers are in hex.  However, after looking into
this in more depth, it seems that the author of lmctl was mistaken.  Looking
at linux/drivers/usb/core/inode.c, it looks like they are in fact in
decimal, as you suggest.

I still believe a patch is in order.  Whether or not the udev tarball rules
are right or wrong, it is bad code to be using string comparisons to compare
integers.  The patch can be simplified, of course, as the string can be
easily converted to a number using atoi instead of a sscanf and there
doesn't need to be two code paths based on the length of the string.

Matt
__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the hal mailing list