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

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jeremy Fitzhardinge <jeremy@...>
Cc: Sam Ravnborg <sam@...>, H. Peter Anvin <hpa@...>, Steve French <smfrench@...>, lkml <linux-kernel@...>
Date: Saturday, May 24, 2008 - 6:49 am

On Sat, May 24, 2008 at 11:06:21AM +0100, Jeremy Fitzhardinge wrote:

A quite common pattern in the kernel is:
#if defined(CONFIG_FOO) || (defined(CONFIG_FOO_MODULE) && defined(MODULE))

Your suggestion would require them to be changed to:
#if (defined(CONFIG_FOO) && !defined(CONFIG_FOO_MODULE)) || (defined(CONFIG_FOO_MODULE) && defined(MODULE))

(We could push these cases to kconfig, but there might also be other 
 cases where changing the existing semantics of CONFIG_FOO could cause
 breakages.)

We see daily in kconfig that mixing tristates with bools is tricky 
(especially since bools are used with different intended semantics),
and I don't think doing the same in the source files would be an 
improvement.

We might be able to do (without any CFG_FOO_MODULE at all):

Enabled m:

    #undef CONFIG_FOO
    #define CFG_FOO   0
    #define CONFIG_FOO_MODULE

And let everyone who want's "either y or m" semantics to convert the 
tristate to a bool with this semantics in kconfig himself:

config FOO
	tristate

config BAR
	def_bool FOO

Especially since this is actually a relatively unusual (and not nice) 
case since usually adding a module does not (and should) not change the 
kernel image.


cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
kernel coding style for if ... else which cross #ifdef, Steve French, (Fri May 23, 3:11 pm)
Re: kernel coding style for if ... else which cross #ifdef, H. Peter Anvin, (Fri May 23, 7:03 pm)
Re: kernel coding style for if ... else which cross #ifdef, H. Peter Anvin, (Sat May 24, 1:42 am)
Re: kernel coding style for if ... else which cross #ifdef, H. Peter Anvin, (Sat May 24, 2:08 pm)
Re: kernel coding style for if ... else which cross #ifdef, Jeremy Fitzhardinge, (Sat May 24, 6:06 am)
Re: kernel coding style for if ... else which cross #ifdef, Jeremy Fitzhardinge, (Sat May 24, 10:35 am)
Re: kernel coding style for if ... else which cross #ifdef, Jeremy Fitzhardinge, (Sat May 24, 11:45 am)
Re: kernel coding style for if ... else which cross #ifdef, H. Peter Anvin, (Sat May 24, 2:12 pm)
Re: kernel coding style for if ... else which cross #ifdef, Vegard Nossum, (Sat May 24, 11:57 am)
Re: kernel coding style for if ... else which cross #ifdef, H. Peter Anvin, (Sat May 24, 2:12 pm)
Re: kernel coding style for if ... else which cross #ifdef, Jeremy Fitzhardinge, (Sat May 24, 12:02 pm)
Re: kernel coding style for if ... else which cross #ifdef, Jeremy Fitzhardinge, (Sat May 24, 4:38 pm)
Re: kernel coding style for if ... else which cross #ifdef, H. Peter Anvin, (Sat May 24, 4:43 pm)
Re: kernel coding style for if ... else which cross #ifdef, Jeremy Fitzhardinge, (Sat May 24, 4:51 pm)
Re: kernel coding style for if ... else which cross #ifdef, H. Peter Anvin, (Sat May 24, 4:54 pm)
Re: kernel coding style for if ... else which cross #ifdef, Jeremy Fitzhardinge, (Sat May 24, 5:15 pm)
Re: kernel coding style for if ... else which cross #ifdef, H. Peter Anvin, (Sun May 25, 8:27 pm)
Re: kernel coding style for if ... else which cross #ifdef, Willy Tarreau, (Sat May 24, 10:39 am)
Re: kernel coding style for if ... else which cross #ifdef, Jeremy Fitzhardinge, (Sat May 24, 10:41 am)
Re: kernel coding style for if ... else which cross #ifdef, Willy Tarreau, (Sat May 24, 10:46 am)
Re: kernel coding style for if ... else which cross #ifdef, Adrian Bunk, (Sat May 24, 6:49 am)