All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] Octal constants confuse spatch
@ 2019-02-25 22:56 Timur Tabi
  2019-02-25 23:06 ` Timur Tabi
  0 siblings, 1 reply; 4+ messages in thread
From: Timur Tabi @ 2019-02-25 22:56 UTC (permalink / raw)
  To: cocci

The following test confuses spatch:

void func(void)
{
    x = FLD_SET_DRF(0080, 1, 2, 3, 4);

    DBG_PRINTF((DBG_MODULE_PERFCTL, DBG_LEVEL_INFO, "hello\n"));
}

This gives me:

ERROR-RECOV: found sync '}' at line 7

If I change the "0080" to "80", it works fine.  I tried adding this line:

#define FLD_TEST_DRF(a, b, c, d, e)             1

But it didn't help.
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Cocci] Octal constants confuse spatch
  2019-02-25 22:56 [Cocci] Octal constants confuse spatch Timur Tabi
@ 2019-02-25 23:06 ` Timur Tabi
  2019-02-25 23:22   ` Timur Tabi
  0 siblings, 1 reply; 4+ messages in thread
From: Timur Tabi @ 2019-02-25 23:06 UTC (permalink / raw)
  To: cocci

On Mon, Feb 25, 2019 at 4:56 PM Timur Tabi <timur@kernel.org> wrote:
> #define FLD_TEST_DRF(a, b, c, d, e)             1

Sorry, bad copy-paste.  I meant

#define FLD_SET_DRF(a, b, c, d, e)             1
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Cocci] Octal constants confuse spatch
  2019-02-25 23:06 ` Timur Tabi
@ 2019-02-25 23:22   ` Timur Tabi
  2019-02-26  6:25     ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Timur Tabi @ 2019-02-25 23:22 UTC (permalink / raw)
  To: Timur Tabi; +Cc: cocci

On Mon, Feb 25, 2019 at 5:06 PM Timur Tabi <timur@kernel.org> wrote:
> Sorry, bad copy-paste.  I meant
>
> #define FLD_SET_DRF(a, b, c, d, e)             1

Ok, now I found something weird.

If I put the #define on the top of the source file (test.c), it doesn't work.

But if I put it in a header file specified by --macro-file-builtins,
it does work.

So it seems to me that spatch is parsing the macros in the
--macro-file-builtins header file differently than the macros in the
source file itself.  That doesn't explain why it doesn't like 0080,
though.

Anyway, I seem to be unblocked for now, but this might be something to
look into.
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Cocci] Octal constants confuse spatch
  2019-02-25 23:22   ` Timur Tabi
@ 2019-02-26  6:25     ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2019-02-26  6:25 UTC (permalink / raw)
  To: Timur Tabi; +Cc: cocci



On Mon, 25 Feb 2019, Timur Tabi wrote:

> On Mon, Feb 25, 2019 at 5:06 PM Timur Tabi <timur@kernel.org> wrote:
> > Sorry, bad copy-paste.  I meant
> >
> > #define FLD_SET_DRF(a, b, c, d, e)             1
>
> Ok, now I found something weird.
>
> If I put the #define on the top of the source file (test.c), it doesn't work.
>
> But if I put it in a header file specified by --macro-file-builtins,
> it does work.
>
> So it seems to me that spatch is parsing the macros in the
> --macro-file-builtins header file differently than the macros in the
> source file itself.  That doesn't explain why it doesn't like 0080,
> though.

It doesn't like 0080 because that's not an octal number.  Octal numbers
should only have digits up to 7.

On the other hand, when I try to parse the function in isolation, it fails
for a few parsing rounds, but then succeeds in the end.

Coccinelle tries to avoid unfolding macros, because doing so means that
the macro code can't be transformed.  --macro-file-builtins means use
these definitions immediately when parsing.  --macro-file definitions are
used in a later parsing attempt.  I think that macro definitions in the
code are only used when they have an impact on control-flow, ie a macro
definition that contains a return.  So what you see is the intended
behavior.

julia

>
> Anyway, I seem to be unblocked for now, but this might be something to
> look into.
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-26  6:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-25 22:56 [Cocci] Octal constants confuse spatch Timur Tabi
2019-02-25 23:06 ` Timur Tabi
2019-02-25 23:22   ` Timur Tabi
2019-02-26  6:25     ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.