All of lore.kernel.org
 help / color / mirror / Atom feed
From: mstefani@redhat.com (Michael Stefaniuc)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Odd behaviour for ... and sub-expressions
Date: Fri, 29 Apr 2016 19:36:19 +0200	[thread overview]
Message-ID: <57239B93.9020600@redhat.com> (raw)

Hello,

I'm observing an odd behaviour difference when using an ellipses
following a plain expression or a sub-expression in <+... ...+>

Following coccinelle rule does not behave as expected:

// Sanity check to not use a RECT field in the SetRect.
@@
expression rect;
identifier fld;
@@
  SetRect(&rect, ...,
-                     <+... rect.fld ...+>
+                     BADBADBAD
                                ,...)

It does not matches cases where the bad subexpression is the last
argument of the function call. E.g. for

void foo(void)
{
    RECT r;
    SetRect(&r, 0, 0, r.left, 0);
    SetRect(&r, 0, 0, 0, r.top);
    SetRect(&r, 0, 0, r.left + 1, 0);
    SetRect(&r, 0, 0, 0, r.top + 1);
}

it modifies just the 1st and 3rd SetRect() call while it should match
all 4 cases.

If I just use rect.fld without the <+... ...+> the rule will match
correctly both the 1st and 2nd SetRect() call aka it matches at the end
of the argument list too.

Is this a bug? I'm running coccinelle 1.0.4.

thanks
bye
     michael

P.S.: As a workaround I have created a separate rule for the last
argument and that works.

             reply	other threads:[~2016-04-29 17:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29 17:36 Michael Stefaniuc [this message]
2016-04-29 19:00 ` [Cocci] Odd behaviour for ... and sub-expressions Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57239B93.9020600@redhat.com \
    --to=mstefani@redhat.com \
    --cc=cocci@systeme.lip6.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.