[2/3][PATCH][upstream] TDM Framework
Michael Ellerman
michael at ellerman.id.au
Wed Jul 25 15:18:31 EST 2012
On Wed, 2012-07-25 at 02:40 +0000, Tabi Timur-B04825 wrote:
> Michael Ellerman wrote:
> > I agree these values are odd. But there's no rule that you can only use
> > an enum if the values are monotonically increasing.
> >
> > It can still serve as helpful documentation, and reduce the number of
> > places you pass a bare int around.
>
> IMHO, an enum should only be used if
>
> 1) You are doing real type checking of the enum
Yes, if you're going to define an enum you should use it, which this
patch doesn't, but that's just a bug in this patch.
> 2) You don't care what the actual values of each enum is
I disagree.
They make even more sense when you don't care what the values are, but
that doesn't mean you should only use them in those cases.
And the bible, K & R, includes an example of an enum which explicitly
specifies all its values. It goes on to say "enumeration variables offer
the chance of [type] checking and so are often better than #defines".
cheers
More information about the Linuxppc-dev
mailing list