mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Willy Tarreau <willy@w.ods.org>
To: Bill Gatliff <bgat@billgatliff.com>
Cc: "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 23:58:54 +0200	[thread overview]
Message-ID: <20050622215854.GJ8907@alpha.home.local> (raw)
In-Reply-To: <42B9D120.6030108@billgatliff.com>

On Wed, Jun 22, 2005 at 03:59:12PM -0500, Bill Gatliff wrote:
 
> 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.

Bill, this is a good reason, I agree with you. What I did not want to see
was something like :

  enum { TCLK_BASE=0xa80, TCLK_REG0, TCLK_REG1, ... }

> 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...

indeed, nearly all defines need to get lots of parenthesis for the exact
same reason.

Thanks for pointing out the gdb trick.
Willy


  reply	other threads:[~2005-06-22 22:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-22 15:12 Bouchard, Sebastien
2005-06-22 19:43 ` Pekka Enberg
2005-06-22 20:32   ` Willy Tarreau
2005-06-22 20:59     ` Bill Gatliff
2005-06-22 21:58       ` Willy Tarreau [this message]
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
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=20050622215854.GJ8907@alpha.home.local \
    --to=willy@w.ods.org \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®