lkml.org 
[lkml]   [2004]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2.6] via-rhine: WOL band-aid
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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.053 / U:1.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site