All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
@ 2014-12-03 17:29 Francois Berenger
  2014-12-03 17:34 ` Luis R. Rodriguez
  2014-12-03 18:13 ` Julia Lawall
  0 siblings, 2 replies; 13+ messages in thread
From: Francois Berenger @ 2014-12-03 17:29 UTC (permalink / raw)
  To: cocci

Hello,

I give up trying to write the spatch myself:

Before file:
---
int i;

for ( ; ; ++i ) {
   if (1) {
     continue;
   }
}
---

After file:
---
int i;

for ( ; ; ) {
   if (1) {
     ++i;
     continue;
   }
   ++i;
}
---

All my trials don't work, not any change in the file appears
if I try --in-place and -o fails because
"-o can not be applied because there are no modified files"

Thanks a lot,
Francois.

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-03 17:29 [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation Francois Berenger
@ 2014-12-03 17:34 ` Luis R. Rodriguez
  2014-12-04 12:49   ` Francois Berenger
  2014-12-03 18:13 ` Julia Lawall
  1 sibling, 1 reply; 13+ messages in thread
From: Luis R. Rodriguez @ 2014-12-03 17:34 UTC (permalink / raw)
  To: cocci

On Wed, Dec 03, 2014 at 06:29:54PM +0100, Francois Berenger wrote:
> Hello,
>
> I give up trying to write the spatch myself:
>
> Before file:
> ---
> int i;
>
> for ( ; ; ++i ) {
>   if (1) {
>     continue;
>   }
> }
> ---
>
> After file:
> ---
> int i;
>
> for ( ; ; ) {
>   if (1) {
>     ++i;
>     continue;
>   }
>   ++i;
> }
> ---
>
> All my trials don't work, not any change in the file appears
> if I try --in-place and -o fails because
> "-o can not be applied because there are no modified files"

Can you take the hands on tutorial before expecting folks to
write rules for you?

https://www.youtube.com/watch?v=buZrNd6XkEw

  Luis

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-03 17:29 [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation Francois Berenger
  2014-12-03 17:34 ` Luis R. Rodriguez
@ 2014-12-03 18:13 ` Julia Lawall
  2014-12-04 10:17   ` Francois Berenger
  1 sibling, 1 reply; 13+ messages in thread
From: Julia Lawall @ 2014-12-03 18:13 UTC (permalink / raw)
  To: cocci

On Wed, 3 Dec 2014, Francois Berenger wrote:

> Hello,
>
> I give up trying to write the spatch myself:
>
> Before file:
> ---
> int i;
>
> for ( ; ; ++i ) {
>   if (1) {
>     continue;
>   }
> }
> ---
>
> After file:
> ---
> int i;
>
> for ( ; ; ) {
>   if (1) {
>     ++i;
>     continue;
>   }
>   ++i;
> }
> ---
>
> All my trials don't work, not any change in the file appears
> if I try --in-place and -o fails because
> "-o can not be applied because there are no modified files"

It's hard to know how much generality you want.  But just for the code you
have shown, the following code works fine for me:

@@
expression i;
@@

for ( ; ;
- ++i
    ) {
  if (1) {
+   ++i;
    continue;
  }
}

julia

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-03 18:13 ` Julia Lawall
@ 2014-12-04 10:17   ` Francois Berenger
  2014-12-04 10:29     ` Julia Lawall
  0 siblings, 1 reply; 13+ messages in thread
From: Francois Berenger @ 2014-12-04 10:17 UTC (permalink / raw)
  To: cocci

Hello,

What is the spatch command line you used and which version of coccinelle 
are you using?

I tried this:

# apply.spatch is your exact proposal
spatch --sp-file apply.spatch test_before.c -o /dev/stdout

Then I see on stdout the exact same file than what's in test_before.c

On 12/03/2014 07:13 PM, Julia Lawall wrote:
> @@
> expression i;
> @@
>
> for ( ; ;
> - ++i
>      ) {
>    if (1) {
> +   ++i;
>      continue;
>    }
> }
>
> julia

-- 
Regards,
Francois.

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-04 10:17   ` Francois Berenger
@ 2014-12-04 10:29     ` Julia Lawall
  2014-12-04 10:40       ` Francois Berenger
  0 siblings, 1 reply; 13+ messages in thread
From: Julia Lawall @ 2014-12-04 10:29 UTC (permalink / raw)
  To: cocci

On Thu, 4 Dec 2014, Francois Berenger wrote:

> Hello,
>
> What is the spatch command line you used and which version of coccinelle are
> you using?
>
> I tried this:
>
> # apply.spatch is your exact proposal
> spatch --sp-file apply.spatch test_before.c -o /dev/stdout

spatch apply.spatch test_before.c

See what happens if you add -debug to the argument list.

julia

>
> Then I see on stdout the exact same file than what's in test_before.c
>
> On 12/03/2014 07:13 PM, Julia Lawall wrote:
> > @@
> > expression i;
> > @@
> >
> > for ( ; ;
> > - ++i
> >      ) {
> >    if (1) {
> > +   ++i;
> >      continue;
> >    }
> > }
> >
> > julia
>
> --
> Regards,
> Francois.
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-04 10:29     ` Julia Lawall
@ 2014-12-04 10:40       ` Francois Berenger
  2014-12-04 11:00         ` Francois Berenger
  2014-12-04 11:22         ` Julia Lawall
  0 siblings, 2 replies; 13+ messages in thread
From: Francois Berenger @ 2014-12-04 10:40 UTC (permalink / raw)
  To: cocci

On 12/04/2014 11:29 AM, Julia Lawall wrote:
> On Thu, 4 Dec 2014, Francois Berenger wrote:
>
>> Hello,
>>
>> What is the spatch command line you used and which version of coccinelle are
>> you using?
>>
>> I tried this:
>>
>> # apply.spatch is your exact proposal
>> spatch --sp-file apply.spatch test_before.c -o /dev/stdout
>
> spatch apply.spatch test_before.c
>
> See what happens if you add -debug to the argument list.

# spatch -debug -sp apply.spatch test_before.c
init_defs_builtins: /home/berenger/.opam/4.01.0/share/coccinelle/standard.h
-----------------------------------------------------------------------
processing semantic patch file: /tmp/sp-15933-b4165a.cocci
with isos from: /home/berenger/.opam/4.01.0/share/coccinelle/standard.iso
-----------------------------------------------------------------------
@@
@@
* apply.spatch

warning: line 3: should apply be a metavariable?
(ONCE) Expected tokens spatch apply
Skipping:test_before.c
Check duplication for 0 files
@@
@@
* apply.spatch

> julia
>
>>
>> Then I see on stdout the exact same file than what's in test_before.c
>>
>> On 12/03/2014 07:13 PM, Julia Lawall wrote:
>>> @@
>>> expression i;
>>> @@
>>>
>>> for ( ; ;
>>> - ++i
>>>       ) {
>>>     if (1) {
>>> +   ++i;
>>>       continue;
>>>     }
>>> }
>>>
>>> julia
>>
>> --
>> Regards,
>> Francois.
>> _______________________________________________
>> Cocci mailing list
>> Cocci at systeme.lip6.fr
>> https://systeme.lip6.fr/mailman/listinfo/cocci
>>

-- 
Regards,
Francois.

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-04 10:40       ` Francois Berenger
@ 2014-12-04 11:00         ` Francois Berenger
  2014-12-04 11:22         ` Julia Lawall
  1 sibling, 0 replies; 13+ messages in thread
From: Francois Berenger @ 2014-12-04 11:00 UTC (permalink / raw)
  To: cocci

On 12/04/2014 11:40 AM, Francois Berenger wrote:
> On 12/04/2014 11:29 AM, Julia Lawall wrote:
>> On Thu, 4 Dec 2014, Francois Berenger wrote:
>>
>>> Hello,
>>>
>>> What is the spatch command line you used and which version of
>>> coccinelle are
>>> you using?
>>>
>>> I tried this:
>>>
>>> # apply.spatch is your exact proposal
>>> spatch --sp-file apply.spatch test_before.c -o /dev/stdout
>>
>> spatch apply.spatch test_before.c
>>
>> See what happens if you add -debug to the argument list.
>
> # spatch -debug -sp apply.spatch test_before.c
> init_defs_builtins: /home/berenger/.opam/4.01.0/share/coccinelle/standard.h
> -----------------------------------------------------------------------
> processing semantic patch file: /tmp/sp-15933-b4165a.cocci
> with isos from: /home/berenger/.opam/4.01.0/share/coccinelle/standard.iso
> -----------------------------------------------------------------------
> @@
> @@
> * apply.spatch
>
> warning: line 3: should apply be a metavariable?

In my whole apply.spatch file, there is nothing named apply ...
I am puzzled.

> (ONCE) Expected tokens spatch apply
> Skipping:test_before.c
> Check duplication for 0 files
> @@
> @@
> * apply.spatch
>
>> julia
>>
>>>
>>> Then I see on stdout the exact same file than what's in test_before.c
>>>
>>> On 12/03/2014 07:13 PM, Julia Lawall wrote:
>>>> @@
>>>> expression i;
>>>> @@
>>>>
>>>> for ( ; ;
>>>> - ++i
>>>>       ) {
>>>>     if (1) {
>>>> +   ++i;
>>>>       continue;
>>>>     }
>>>> }
>>>>
>>>> julia
>>>
>>> --
>>> Regards,
>>> Francois.
>>> _______________________________________________
>>> Cocci mailing list
>>> Cocci at systeme.lip6.fr
>>> https://systeme.lip6.fr/mailman/listinfo/cocci
>>>
>

-- 
Regards,
Francois.

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-04 10:40       ` Francois Berenger
  2014-12-04 11:00         ` Francois Berenger
@ 2014-12-04 11:22         ` Julia Lawall
  1 sibling, 0 replies; 13+ messages in thread
From: Julia Lawall @ 2014-12-04 11:22 UTC (permalink / raw)
  To: cocci

On Thu, 4 Dec 2014, Francois Berenger wrote:

> On 12/04/2014 11:29 AM, Julia Lawall wrote:
> > On Thu, 4 Dec 2014, Francois Berenger wrote:
> >
> > > Hello,
> > >
> > > What is the spatch command line you used and which version of coccinelle
> > > are
> > > you using?
> > >
> > > I tried this:
> > >
> > > # apply.spatch is your exact proposal
> > > spatch --sp-file apply.spatch test_before.c -o /dev/stdout
> >
> > spatch apply.spatch test_before.c
> >
> > See what happens if you add -debug to the argument list.
>
> # spatch -debug -sp apply.spatch test_before.c

The argument -sp does not do what you think.  It takes the following text
as a semantic patch.  It is useful for doing very simple searches, since
you don't have to make a separate file.

julia

> init_defs_builtins: /home/berenger/.opam/4.01.0/share/coccinelle/standard.h
> -----------------------------------------------------------------------
> processing semantic patch file: /tmp/sp-15933-b4165a.cocci
> with isos from: /home/berenger/.opam/4.01.0/share/coccinelle/standard.iso
> -----------------------------------------------------------------------
> @@
> @@
> * apply.spatch
>
> warning: line 3: should apply be a metavariable?
> (ONCE) Expected tokens spatch apply
> Skipping:test_before.c
> Check duplication for 0 files
> @@
> @@
> * apply.spatch
>
> > julia
> >
> > >
> > > Then I see on stdout the exact same file than what's in test_before.c
> > >
> > > On 12/03/2014 07:13 PM, Julia Lawall wrote:
> > > > @@
> > > > expression i;
> > > > @@
> > > >
> > > > for ( ; ;
> > > > - ++i
> > > >       ) {
> > > >     if (1) {
> > > > +   ++i;
> > > >       continue;
> > > >     }
> > > > }
> > > >
> > > > julia
> > >
> > > --
> > > Regards,
> > > Francois.
> > > _______________________________________________
> > > Cocci mailing list
> > > Cocci at systeme.lip6.fr
> > > https://systeme.lip6.fr/mailman/listinfo/cocci
> > >
>
> --
> Regards,
> Francois.
>

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-03 17:34 ` Luis R. Rodriguez
@ 2014-12-04 12:49   ` Francois Berenger
  2014-12-04 12:56     ` Julia Lawall
  0 siblings, 1 reply; 13+ messages in thread
From: Francois Berenger @ 2014-12-04 12:49 UTC (permalink / raw)
  To: cocci

On 12/03/2014 06:34 PM, Luis R. Rodriguez wrote:
> On Wed, Dec 03, 2014 at 06:29:54PM +0100, Francois Berenger wrote:
>> Hello,
>>
>> I give up trying to write the spatch myself:
>>
>> Before file:
>> ---
>> int i;
>>
>> for ( ; ; ++i ) {
>>    if (1) {
>>      continue;
>>    }
>> }
>> ---
>>
>> After file:
>> ---
>> int i;
>>
>> for ( ; ; ) {
>>    if (1) {
>>      ++i;
>>      continue;
>>    }
>>    ++i;
>> }
>> ---
>>
>> All my trials don't work, not any change in the file appears
>> if I try --in-place and -o fails because
>> "-o can not be applied because there are no modified files"
>
> Can you take the hands on tutorial before expecting folks to
> write rules for you?
>
> https://www.youtube.com/watch?v=buZrNd6XkEw

If I really need to invest two hours before being able to use coccinelle 
productively, that would be a serious entry barrier.

And probably not just for me: for any potential new user of
coccinelle.

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-04 12:49   ` Francois Berenger
@ 2014-12-04 12:56     ` Julia Lawall
  2014-12-04 13:00       ` Francois Berenger
  2014-12-04 14:31       ` Francois Berenger
  0 siblings, 2 replies; 13+ messages in thread
From: Julia Lawall @ 2014-12-04 12:56 UTC (permalink / raw)
  To: cocci



On Thu, 4 Dec 2014, Francois Berenger wrote:

> On 12/03/2014 06:34 PM, Luis R. Rodriguez wrote:
> > On Wed, Dec 03, 2014 at 06:29:54PM +0100, Francois Berenger wrote:
> > > Hello,
> > >
> > > I give up trying to write the spatch myself:
> > >
> > > Before file:
> > > ---
> > > int i;
> > >
> > > for ( ; ; ++i ) {
> > >    if (1) {
> > >      continue;
> > >    }
> > > }
> > > ---
> > >
> > > After file:
> > > ---
> > > int i;
> > >
> > > for ( ; ; ) {
> > >    if (1) {
> > >      ++i;
> > >      continue;
> > >    }
> > >    ++i;
> > > }
> > > ---
> > >
> > > All my trials don't work, not any change in the file appears
> > > if I try --in-place and -o fails because
> > > "-o can not be applied because there are no modified files"
> >
> > Can you take the hands on tutorial before expecting folks to
> > write rules for you?
> >
> > https://www.youtube.com/watch?v=buZrNd6XkEw
>
> If I really need to invest two hours before being able to use coccinelle
> productively, that would be a serious entry barrier.
>
> And probably not just for me: for any potential new user of
> coccinelle.

I think that you may have started with an unfortunate case.  I'm not sure
what is the strategy for matching the empty space in a for header.  It's
not an expression, so what is it.  It may be possible only to match it
exactly.

On the other hand, it is helpful if you provide a semantic patch that
you have tried, rather than just the before and after code.  From one
example of before and after code, it is not always possible to guess the
full generality of the rule that you are trying to implement.

julia

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-04 12:56     ` Julia Lawall
@ 2014-12-04 13:00       ` Francois Berenger
  2014-12-04 17:31         ` Luis R. Rodriguez
  2014-12-04 14:31       ` Francois Berenger
  1 sibling, 1 reply; 13+ messages in thread
From: Francois Berenger @ 2014-12-04 13:00 UTC (permalink / raw)
  To: cocci

On 12/04/2014 01:56 PM, Julia Lawall wrote:
>
> On Thu, 4 Dec 2014, Francois Berenger wrote:
>
>> On 12/03/2014 06:34 PM, Luis R. Rodriguez wrote:
>>> On Wed, Dec 03, 2014 at 06:29:54PM +0100, Francois Berenger wrote:
>>>> Hello,
>>>>
>>>> I give up trying to write the spatch myself:
>>>>
>>>> Before file:
>>>> ---
>>>> int i;
>>>>
>>>> for ( ; ; ++i ) {
>>>>     if (1) {
>>>>       continue;
>>>>     }
>>>> }
>>>> ---
>>>>
>>>> After file:
>>>> ---
>>>> int i;
>>>>
>>>> for ( ; ; ) {
>>>>     if (1) {
>>>>       ++i;
>>>>       continue;
>>>>     }
>>>>     ++i;
>>>> }
>>>> ---
>>>>
>>>> All my trials don't work, not any change in the file appears
>>>> if I try --in-place and -o fails because
>>>> "-o can not be applied because there are no modified files"
>>>
>>> Can you take the hands on tutorial before expecting folks to
>>> write rules for you?
>>>
>>> https://www.youtube.com/watch?v=buZrNd6XkEw
>>
>> If I really need to invest two hours before being able to use coccinelle
>> productively, that would be a serious entry barrier.
>>
>> And probably not just for me: for any potential new user of
>> coccinelle.
>
> I think that you may have started with an unfortunate case.  I'm not sure
> what is the strategy for matching the empty space in a for header.  It's
> not an expression, so what is it.  It may be possible only to match it
> exactly.
>
> On the other hand, it is helpful if you provide a semantic patch that
> you have tried, rather than just the before and after code.  From one
> example of before and after code, it is not always possible to guess the
> full generality of the rule that you are trying to implement.

My mistake. Thanks for providing me ealier an example spatch.

The availability of a working spdiff tool, shipping and synchronized 
with coccinelle may lower the entry barrier to new  users:
users could start writing working spatches just by editing
a working starting example they may have inferred using spdiff
from an actual source code difference.

-- 
Regards,
Francois.

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-04 12:56     ` Julia Lawall
  2014-12-04 13:00       ` Francois Berenger
@ 2014-12-04 14:31       ` Francois Berenger
  1 sibling, 0 replies; 13+ messages in thread
From: Francois Berenger @ 2014-12-04 14:31 UTC (permalink / raw)
  To: cocci

On 12/04/2014 01:56 PM, Julia Lawall wrote:
>
>
> On Thu, 4 Dec 2014, Francois Berenger wrote:
>
>> On 12/03/2014 06:34 PM, Luis R. Rodriguez wrote:
>>> On Wed, Dec 03, 2014 at 06:29:54PM +0100, Francois Berenger wrote:
>>>> Hello,
>>>>
>>>> I give up trying to write the spatch myself:
>>>>
>>>> Before file:
>>>> ---
>>>> int i;
>>>>
>>>> for ( ; ; ++i ) {
>>>>     if (1) {
>>>>       continue;
>>>>     }
>>>> }
>>>> ---
>>>>
>>>> After file:
>>>> ---
>>>> int i;
>>>>
>>>> for ( ; ; ) {
>>>>     if (1) {
>>>>       ++i;
>>>>       continue;
>>>>     }
>>>>     ++i;
>>>> }
>>>> ---
>>>>
>>>> All my trials don't work, not any change in the file appears
>>>> if I try --in-place and -o fails because
>>>> "-o can not be applied because there are no modified files"
>>>
>>> Can you take the hands on tutorial before expecting folks to
>>> write rules for you?
>>>
>>> https://www.youtube.com/watch?v=buZrNd6XkEw
>>
>> If I really need to invest two hours before being able to use coccinelle
>> productively, that would be a serious entry barrier.
>>
>> And probably not just for me: for any potential new user of
>> coccinelle.
>
> I think that you may have started with an unfortunate case.  I'm not sure
> what is the strategy for matching the empty space in a for header.  It's
> not an expression, so what is it.

It is an optional expression: either there is an expression, either 
there is none.
I could not find such thing in the SmPL grammar manual (v1.0.0-rc21).

>  It may be possible only to match it
> exactly.
>
> On the other hand, it is helpful if you provide a semantic patch that
> you have tried, rather than just the before and after code.  From one
> example of before and after code, it is not always possible to guess the
> full generality of the rule that you are trying to implement.
>
> julia
>

-- 
Regards,
Francois.

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

* [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation
  2014-12-04 13:00       ` Francois Berenger
@ 2014-12-04 17:31         ` Luis R. Rodriguez
  0 siblings, 0 replies; 13+ messages in thread
From: Luis R. Rodriguez @ 2014-12-04 17:31 UTC (permalink / raw)
  To: cocci

On Thu, Dec 4, 2014 at 8:00 AM, Francois Berenger
<francois.berenger@inria.fr> wrote:
> The availability of a working spdiff tool, shipping and synchronized with
> coccinelle may lower the entry barrier to new  users:
> users could start writing working spatches just by editing
> a working starting example they may have inferred using spdiff
> from an actual source code difference.

Agreed. One must not lightly discard the theoretical complexities and
challenges to even come up with Coccinelle and spdiff, as Coccienlle
matures I'm afraid we haven't yet had much exposure on users to
spdiff, so it may take some time to get users what you describe
seamlessly.

 Luis

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

end of thread, other threads:[~2014-12-04 17:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-03 17:29 [Cocci] What is the spatch file for this change and the corresponding spatch command line invocation Francois Berenger
2014-12-03 17:34 ` Luis R. Rodriguez
2014-12-04 12:49   ` Francois Berenger
2014-12-04 12:56     ` Julia Lawall
2014-12-04 13:00       ` Francois Berenger
2014-12-04 17:31         ` Luis R. Rodriguez
2014-12-04 14:31       ` Francois Berenger
2014-12-03 18:13 ` Julia Lawall
2014-12-04 10:17   ` Francois Berenger
2014-12-04 10:29     ` Julia Lawall
2014-12-04 10:40       ` Francois Berenger
2014-12-04 11:00         ` Francois Berenger
2014-12-04 11:22         ` 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.