Re: Patch of a new driver for kernel 2.4.x that need review

Willy Tarreau
2005-06-23T04:50:54Z

Hi Pekka,

On Thu, Jun 23, 2005 at 07:16:17AM +0300, Pekka J Enberg wrote:
> Hi Willy,
>
> Willy Tarreau writes:
> >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.
>
> Sorry, what do you have to count with the following?
>
> enum {
> TLCLK_REG0 = TLCLK_BASE,
> TLCLK_REG1 = TLCLK_BASE+1,
> TLCLK_REG2 = TLCLK_BASE+2,
> };

Sorry for the noise, I replied in a second mail that I was perfectly OK
with this usage. What I though you wanted to propose was the simplest for
of enum where only the first value is specified, and which is a nightmare
to debug afterwards. Bill Gatliff also suggested that gdb can display and
use the symbolic values while it's not the case on defines.

Regards,
Willy