lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 24 May 2008 17:42:13 +0100
From:	"Tom Spink" <tspink@...il.com>
To:	"Jeremy Fitzhardinge" <jeremy@...p.org>
Cc:	"Vegard Nossum" <vegard.nossum@...il.com>,
	"Sam Ravnborg" <sam@...nborg.org>,
	"H. Peter Anvin" <hpa@...or.com>,
	"Steve French" <smfrench@...il.com>,
	lkml <linux-kernel@...r.kernel.org>
Subject: Re: kernel coding style for if ... else which cross #ifdef

2008/5/24 Tom Spink <tspink@...il.com>:
> 2008/5/24 Jeremy Fitzhardinge <jeremy@...p.org>:
>> Vegard Nossum wrote:
>>>
>>> Why not use all-lowercase config_* names? It seems elegant, and fits
>>> in with the notion that these are to be used not as macros, but as
>>> ordinary constants.
>>>
>>
>> We tend to use all caps for symbolic constants, even if they're enums.
>>
>>> (The only disadvantage I can see is that they will stand out less. But
>>> I don't know how great the disadvantage is.)
>>>
>>> You could even go further and make them real constants, something
>>> along the lines of:
>>>
>>> enum config_value { no, yes, mod };
>>>
>>> static const enum config_value config_lockdep_support = yes;
>>>
>>
>> Well, you could use "enum { config_foo = 0/1 }"  to define a proper C
>> constant.
>>
>> But it means you could only use them in C, not in CPP or asm expressions.
>>
>>   J
>
> Hi,
>
> A thought occurred to me that we may be able to used some preprocessor
> magic and do this:
>
> #define config_defined(x) CFGVAL_## x
>
> Which means that, if we get Kconfig to produce:
>
> #define CFGVAL_CONFIG_FOO 0
> #define CFGVAL_CONFIG_VALUE_BAR 1
> #define CFGVAL_CONFIG_VALUE_BAZ_MODULE 1
>
> We can use this:
>
> if (config_defined(CONFIG_FOO) && some_expr) {
>   panic("Oh no.");
> }
>
> Thoughts?
>
> --
> Tom Spink
>

There's a wee typo on the #define lines there:

> #define CFGVAL_CONFIG_FOO 0
> #define CFGVAL_CONFIG_VALUE_BAR 1
> #define CFGVAL_CONFIG_VALUE_BAZ_MODULE 1

I, of course, meant:

#define CFGVAL_CONFIG_FOO 0
#define CFGVAL_CONFIG_BAR 1
#define CFGVAL_CONFIG_BAZ_MODULE 1

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ