[U-Boot] use of C99

Larry Johnson lrj at acm.org
Thu Apr 9 15:27:22 CEST 2009


Wolfgang Denk wrote:
> Dear Pink Boy,
> 
> In message <139940.41801.qm at web31807.mail.mud.yahoo.com> you wrote:
>> Um...  my feeling is that if one is going to declare a variable
>> inside a #ifdef then that variable ought to be called something
>> like
>>
>>   int indx_CONFIG_COOL_FEATURE
>>
>> and
>>
>>   u32 indx_CONFIG_HOT_FEATURE
> 
> Then please read the Coding Style about how to chose variable names.
> 
> Best regards,
> 
> Wolfgang Denk

No matter how many times I like at the code snippet above, my brain
insists on seeing two #define constants named "CONFIG_COOL_FEATURE" and
"CONFIG_HOT_FEATURE".

I once tried to deal with C code whose author had used some all-caps
variable names.  It was like getting a rental car with the gas pedal on
the left and the break on the right.  No matter how aware intellectually
you were of this quirk, the car would be virtually undrivable.  That's
one reason consistent coding styles are important.

The brain also has a harder time dealing with two things that are almost
the same than with two things that differ greatly.  For example, if I
knew French, I'm sure I would have no difficulty writing "centre".
However, being a native speaker of American English, if I needed to
write with traditional British spelling, I'm sure I'd screw up and
writer "center" for "centre" at least half the time.

Personally, I prefer allowing variables to be declared anywhere, but I
don't want the hidden cost of allowing U-Boot to be a little bit
different from the Linux kernel to be underestimated.  There is one
place the styles differ already -- the use of a space between a function
name and the following left parenthesis.  The result is a mishmash, and
just makes it harder to search the code base for function names.

Best regards,
Larry


More information about the U-Boot mailing list