[Cocci] Preprocessor enclosed code ignored
lacombar at gmail.com
Fri May 14 22:04:40 CEST 2010
On Fri, May 14, 2010 at 2:30 PM, Julia Lawall <julia at diku.dk> wrote:
> On Fri, 14 May 2010, Arnaud Lacombe wrote:
>> On Fri, May 14, 2010 at 1:51 PM, yoann padioleau
>> <yoann.padioleau at gmail.com> wrote:
>> > There are some hardcoded patterns in the C parser used by coccinelle
>> > to not process code under
>> > #if 0
>> > #endif
>> > The reason is that at least in the linux kernel, the code under such
>> > ifdef is often not valid C code.
>> does it ? I just ran spatch with -noif0_passing in the root of the
>> 2.6.33 directory and it completed successfully. I'd be tempted to say
>> that having '#if 0' code ignored by default is misleading and error
> Spatch is not perturbed by code that it can't parse. It just silently
> ignores the function containing it.
> You see warnings if you use the
> option -parse_error_msg or -verbose_parsing (different degrees of
Still no warning with these two options enabled. -parse_ch is much
more verbose, but trigger *way* more error.
> It would perhaps be unfortunate if a function with legitimate code were
> not treated because it contained code under #if 0 that was somehow
> unparsable. But which solution one wants probably depends on the problem
> and the code at hand.
This argument would be valid for any constant expression hiding
invalid C code, 0 is just one of them. I my example, you may have
ignored the #if ZERO too. Wouldn't the right things to do be to
[identify and] fix these C-invalid '#if 0' block, rather than silently
ignoring all of them ? From a quick thought, invalid one should
concern a minority.
More information about the Cocci