From: Bill Gatliff <bgat@billgatliff.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Patch of a new driver for kernel 2.4.x that need review
Date: Wed, 22 Jun 2005 15:59:12 -0500 [thread overview]
Message-ID: <42B9D120.6030108@billgatliff.com> (raw)
In-Reply-To: <20050622203211.GI8907@alpha.home.local>
Willy:
Willy Tarreau wrote:
>Hi,
>
>On Wed, Jun 22, 2005 at 10:43:40PM +0300, Pekka Enberg wrote:
>
>
>>On 6/22/05, Bouchard, Sebastien <Sebastien.Bouchard@ca.kontron.com> wrote:
>>
>>
>>>+#define TLCLK_REG7 TLCLK_BASE+7
>>>
>>>
>>Please use enums instead.
>>
>>
>
>I dont agree with you here : enums are good to simply specify an ordering.
>But they must not be used to specify static mapping. Eg: if REG4 *must* be
>equal to BASE+4, you should not use enums, otherwise it will render the
>code unreadable. I personnaly don't want to count the position of REG7 in
>the enum to discover that it's at BASE+7.
>
>
What Sebastien is after is something like this:
enum tclk_regid {TCLK_BASE=0xa80, TCLK_REG0=TCLK_BASE, TCLK_REG1=TCLK_BASE+1...};
enum tclk_regid tclk;
And then later on, if you ask gdb with the value of tclk is, it can tell you "TCLK_REG1", instead of just 0xa801. You can also assign values to tclk from within gdb using the enumerations, rather than magic numbers.
If you insist on using #defines, then you need to do them like this at the very least:
#define TCLK_REG7 (TCLK_BASE+7)
... so as to prevent operator precedence problems later on. I.e. what happens here:
tclk = TCLK_REG7 / 2;
Not implying that the above is a realistic example, I'm just pointing out a potential gotcha that is easily avoided...
b.g.
--
Bill Gatliff
"A DTI spokesman said Wicks would use his debut announcement to
'reaffirm the government's commitment to developing wind' to tackle
the threat of climate change." -- The Observer, May 22, 2005
bgat@billgatliff.com
next prev parent reply other threads:[~2005-06-22 21:03 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-22 15:12 Patch of a new driver for kernel 2.4.x that need review Bouchard, Sebastien
2005-06-22 19:43 ` Pekka Enberg
2005-06-22 20:32 ` Willy Tarreau
2005-06-22 20:59 ` Bill Gatliff [this message]
2005-06-22 21:58 ` Willy Tarreau
2005-06-23 4:58 ` Pekka Enberg
2005-06-23 4:16 ` Pekka J Enberg
2005-06-23 4:49 ` Willy Tarreau
2005-07-06 21:11 ` Mark Gross
2005-07-07 6:00 ` Pekka J Enberg
2005-07-07 6:50 ` Dmitry Torokhov
2005-07-07 6:55 ` Pekka J Enberg
2005-07-07 7:13 ` Dmitry Torokhov
2005-07-07 7:43 ` Pekka J Enberg
2005-07-07 6:10 ` Pekka J Enberg
2005-06-22 20:04 ` Pekka Enberg
2005-06-23 21:42 ` Alan Cox
2005-06-22 21:18 ` Jesper Juhl
2005-07-06 21:14 ` Mark Gross
2005-07-06 22:49 ` randy_dunlap
2005-07-06 22:57 ` Greg KH
2005-08-08 15:35 ` Mark Gross
2005-08-09 7:17 ` Pekka Enberg
2005-08-09 16:56 ` Mark Gross
2005-08-09 17:51 ` Nishanth Aravamudan
-- strict thread matches above, loose matches on Subject: below --
2005-07-07 8:15 moreau francis
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=42B9D120.6030108@billgatliff.com \
--to=bgat@billgatliff.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.