Re: kernel coding style for if ... else which cross #ifdef

From: Sam Ravnborg
Date: Sat May 24 2008 - 14:51:20 EST


On Sat, May 24, 2008 at 04:45:52PM +0100, Jeremy Fitzhardinge wrote:
> Sam Ravnborg wrote:
> >We should actually do as you intially suggested and alwyas
> >define CONFIG_FOO no matter if FOO is built-in or module.
> >Because we do only want to distingush between the two in rare cases.
> >
> >But that is a separate patch and lets not do the same
> >mistage with CFG_*
> >
>
> I think pretty strongly that CFG_ and CONFIG_ should be exactly
> parallel. If you want to change the meaning of CONFIG_X in the presence
> of modules, then change CFG_X at the same time. Making them have
> different meanings will just confuse anyone wanting to convert #ifdef
> CONFIG_ code into if(CFG_) code.

We agree they should have the same semantics - we do just not agree on
the timing.
I would love to do a two patch set:
1) Introduce CFG_
2) Alwyas define CONFIG_FOO in case of modules

But I ned someone to audit the use of CONFIG_FOO before I do
such a change.
I could just do it - but I'm pretty sure it will hurt.
And I do not want to introduce CFG_ with the same
IMO wrong semantic.

> >We may use CFG_* here and there and clash is not good.
And this needs to be checked too - but this is almost trivial to do.

> I have to say I'm not very keen on the CFG_* prefix. It doesn't have
> any inherent meaning and just looks like a redundant abbreviation of
> CONFIG_; something which actually expresses the notion that it's always
> a compile-time constant would be better. Not that I have any
> particularly good alternatives: CONST_? CCONST_? CONFIG_X_VAL? KCONFIG_?
> KONFIG_? KCONST_?
Of the above I would prefer KCONFIG_FOO if we do not go for
the CFG_FOO version.
That it is const is already given by being UPPERCASE.

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