All of lore.kernel.org
 help / color / mirror / Atom feed
From: jglisse@redhat.com (Jerome Glisse)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Multiple match versus single header result in conflicts
Date: Mon, 7 May 2018 11:25:30 -0400	[thread overview]
Message-ID: <20180507152530.GA13419@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1805050718570.2528@hadrien>

On Sat, May 05, 2018 at 07:20:04AM +0200, Julia Lawall wrote:
> 
> 
> On Fri, 4 May 2018, Jerome Glisse wrote:
> 
> > Following semantics does not update function prototype in header file:
> >
> > @S@
> > identifier I1, I2;
> > @@
> > struct myop I1 = { ..., .add = I2 , ... };
> >
> > @U depends on S@
> > identifier S.I2;
> > identifier A1, A2;
> > type T1, T2;
> > @@
> > int I2(T1 A1,
> > +int c,
> > T2 A2) { ... }
> >
> > run with spatch --in-place --sp-file test.spatch --dir . --all-includes
> > (tested various includes/headers combinations) on 3 files f1.h f1.c
> > f2.c (if f1.c and f2.c are merge together then thing works).
> >
> > f1.h: ----------------------------------------------------------------
> > struct myop {
> >     int (*add)(int, int);
> > };
> >
> > int myadd(int, int);
> > ----------------------------------------------------------------------
> >
> > f1.c: ----------------------------------------------------------------
> > #include "f1.h"
> >
> > int myadd(int a, int b)
> > {
> >     return a + b;
> > }
> >
> > struct myop myop = {
> >     .add = myadd,
> > };
> > ----------------------------------------------------------------------
> >
> > f2.c: ----------------------------------------------------------------
> > #include "f1.h"
> >
> > int myadd2(int a, int b)
> > {
> >     return a + b;
> > }
> >
> > struct myop myop2 = {
> >     .add = myadd2,
> > };
> > ----------------------------------------------------------------------
> >
> > If f1.c and f2.c are just one file than the header files is properly
> > updated. The error message is:
> >
> > different modification result for ./f1.h
> >
> > I am not sure if there is a way to make the semantic patch work against
> > such scenario. So is this expected ? Is my semantic patch wrong ? Or
> > is it a bug in coccinelle ?
> 
> I believe that Coccinelle just doesn't make the effort to realize that the
> modifications are the same.  Probably things will be fine if you don't use
> --in-place.
> 

Yes it does work thank you for quick answer. By the way my next hurdle
is trying to match function prototype no matter if argument has a name
or not ie matching all:

void toto(int,int);
void toto(int a, int);
void toto(int, int b);
void toto(int a, int b);

This tie back to my original issue, when a function callback is use
in myop struct in one file and prototype is in header file, i want to
update prototype so that latter when coccinelle process the different
file in which the function is defined i can use the modified header
file to also update the function definition.

Between thank you for coccinelle it is an amazing tools ! :)

Cheers,
J?r?me

  reply	other threads:[~2018-05-07 15:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04 19:30 [Cocci] Multiple match versus single header result in conflicts Jerome Glisse
2018-05-05  5:20 ` Julia Lawall
2018-05-07 15:25   ` Jerome Glisse [this message]
2018-05-07 19:57     ` Julia Lawall
2018-05-07 20:16       ` Jerome Glisse
2018-05-07 20:44         ` 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=20180507152530.GA13419@redhat.com \
    --to=jglisse@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.