public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Larry Johnson <lrj@acm.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] use of C99
Date: Thu, 09 Apr 2009 09:27:22 -0400	[thread overview]
Message-ID: <49DDF7BA.5000503@acm.org> (raw)
In-Reply-To: <20090409055028.053E684C4323@gemini.denx.de>

Wolfgang Denk wrote:
> Dear Pink Boy,
> 
> In message <139940.41801.qm@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

  reply	other threads:[~2009-04-09 13:27 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-09  1:53 [U-Boot] use of C99 Pink Boy
2009-04-09  2:12 ` Jerry Van Baren
2009-04-09  5:50 ` Wolfgang Denk
2009-04-09 13:27   ` Larry Johnson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-04-08 18:51 Kumar Gala
2009-04-08 19:28 ` Wolfgang Denk
2009-04-08 19:46   ` Jerry Van Baren
2009-04-08 20:25     ` Timur Tabi
2009-04-08 20:46       ` Premi, Sanjeev
2009-04-08 20:57         ` Timur Tabi
2009-04-08 21:26           ` Premi, Sanjeev
2009-04-08 21:34             ` Timur Tabi
2009-04-08 21:03         ` Ben Warren
2009-04-08 21:23           ` Premi, Sanjeev
2009-04-08 20:52       ` Scott Wood
2009-04-08 21:01         ` Timur Tabi
2009-04-08 22:26           ` Scott Wood
2009-04-08 21:34       ` Wolfgang Denk
2009-04-08 21:38         ` Timur Tabi
2009-04-08 22:39           ` Graeme Russ
2009-04-08 22:45             ` Timur Tabi
2009-04-08 22:59               ` Wolfgang Denk
2009-04-08 23:09                 ` Scott Wood
2009-04-08 22:28         ` Scott Wood
2009-04-08 21:27     ` Wolfgang Denk
2009-04-08 23:22 ` Larry Johnson
2009-04-08 23:40   ` Scott Wood
2009-04-09  4:27 ` Kumar Gala
2009-04-09 11:38   ` Jerry Van Baren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49DDF7BA.5000503@acm.org \
    --to=lrj@acm.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox