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

From: Pekka J Enberg
Date: Wed Jun 22 2005 - 23:17:07 EST

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 {

Please note that enums are a general way of specifying _constants_ with the type int, not necessarily named enumerations.

Willy Tarreau writes:
if you need something more verbose to say exactly "write 7 to port 123",
it's better to use defines (or even variables sometimes) than enums.

I would agree on variables (for some special cases) but not for defines. The problem with defines is that you can override a constant without even noticing it. Therefore, always use enums when you can, and defines only when you must.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at