Re: [PATCH 2.6] via-rhine: WOL band-aid

Jeff Garzik
2004-12-02T22:41:30Z

Roger Luethi wrote:
> On Tue, 30 Nov 2004 18:17:52 -0500, Jeff Garzik wrote:
>
>>I don't object to the patch, but I wonder if anything can be done to
>>reduce the usage of "magic numbers" (numeric rather than named constants)?
>
>
> That's a non-trivial task if you want to do it properly. There be dragons.
> Magic numbers may be evil but at least they are honest and convenient.

The reason why they are evil is that I have no clue what a change like

- iowrite8(ioread8(ioaddr + ConfigA) & 0xFE, ioaddr + ConfigA);
+ iowrite8(ioread8(ioaddr + ConfigA) & 0xFC, ioaddr + ConfigA);

does.

So two main points:

1) Linux is "evolution not revolution". I'm not asking for you to
change every magic number in the driver immediately to named constants.
Do it over time as you patch the driver. Add a couple WOL constants
now, a few more constants later, ...

2) Avoiding magic numbers is important to "reviewability" and long term
maintenance. Five years from now, changing "0xFE" to "0xFC" is just as
indecipherable as it is today, but without the memory of the current WOL
discussions and experiences to guide us. Source code needs to be
_readable_.

As I said in the other email though, I applied your patch to the
internal via-rhine queue, inside the netdev-2.6 queue. I simply ask
that you consider some remove-magic-numbers patches in the future.

Jeff