[Nut-upsdev] [nut-commits] svn commit r1578 - in trunk: . drivers

Arjen de Korte nut+devel at de-korte.org
Wed Nov 26 22:27:03 UTC 2008


Citeren Arnaud Quette <aquette.dev at gmail.com>:

>> The reason why I removed this here, is the fact that over-use of defines
>> makes code more difficult, instead easier to understand.
> I strongly disagree there. VENDOR_NAME is always more informative than 0x????

In what way? I fully agree that having a USB_DEVICE macro helps in  
extracting the VID:PID information (and makes clear these are used  
together), but a VENDOR_NAME define is adding nothing at all here.  
People wishing to add additional supported devices are helped more by  
a listing of existing VID:PID combinations to see if theirs is already  
supported, than by an arbitrary define chosen by a developer  
VENDOR_NAME (which is not related to anything reported by tools to get  
to the VID:PID combination). In fact, since it is a developer who  
chose this name, there is no hope of ever matching it to VID's found  
in the field.

Overuse of defines is a pet-peeve of me. With all the good intentions  
that may be behind these, if you use a define only once in your code,  
chances are that it would have been clearer not to use it. For  
instance in the SNMP MIBs, the use of defines means that if I'm  
looking for a certain OID I found in a manual, I need two steps to get  
to the NUT variable that uses it. One to get the from the OID to the  
define and a second one to get to the NUT variable that uses it. Not  
using defines here, would have led me straight to the NUT variable, so  
this is just complicating matters. The problem here is that these  
names are made up by humans, so there is no direct reference to  
something found in a reference manual anymore. So in case of the MIBs,  
I'd rather lose the defines.

Best regards, Arjen
-- 
Please keep list traffic on the list



More information about the Nut-upsdev mailing list