On Fri, 1 Mar 2019, Timur Tabi wrote:

> Cocci seems to have problems with { } blocks inside #if statements.
> For example, the following code:
>
> void func1(U32 Notifier)
> {
>     if (x == 0)
>     {
>         x = 1;
>     }
> #ifndef MACRO
>     else if (x == 1)
>     {
>         x = 2;
>     }
> #endif
>     else
>     {
>         return;
>     }
>
>     DBG_PRINTF((DBG_MODULE_PERFCTL, DBG_LEVEL_INFO, "hello\n"));
> }
>
> Gives me this error:
>
> ERROR-RECOV: found sync '}' at line 19
> parsing pass2: try again
> ERROR-RECOV: found sync '}' at line 19
> parsing pass2: try again
>
> In this case, my nv_printf.cocci is still able to process the
> DBG_PRINTF and convert it to NV_PRINTF, so technically it still works.
>
> However, I have much more complex source files (which I cannot share)
> that choke spatch.  I typically get multiple "found sync }" messages

Those messages are not necessarily a problem.  It is talking about parsing
pass 2.  There are four parsing passes.  To find parsing problems, you
should look for BAD.

> along with stuff like:
>
> PB MAYBE: dangerous typedef inference, maybe not a typedef: NvU8
> TYPEDEF CONFLICT:NvU8
> FLOW: cant jump to done: because we can't find this label
>
> In this last case, the label "done" does exist, but it's called only
> from within macros.

Is the macro defined in the same file?  Coccinelle may try to unfold macro
definitions if they relate to control flow.  Or you could put the macro
definition in your --macro-file-builtins file, which I think causes the
macro to be unfolded always.

julia

> _______________________________________________
> Cocci mailing list
> [email protected]
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to