All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] Replacing one (specific!) type with another
@ 2016-10-05  3:27 Nikolaus Rath
  2016-10-05  5:45 ` Julia Lawall
  2016-10-05  5:51 ` SF Markus Elfring
  0 siblings, 2 replies; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-05  3:27 UTC (permalink / raw)
  To: cocci

Hello,

In a set of C files, I would like to replace each instance of one type
(struct fasel_foo) with another type (struct fasel_bar). For instance,

char* fasel_foo_print(struct fasel_foo *ptr) {
    // ...
   return "this struct fasel_foo string should not change";
}

should become

char* fasel_foo_print(struct fasel_bar *ptr) {
    // ...
   return "this struct fasel_foo string should not change";
}


Based on the LWN articles that I've read, this seems like the perfect
use-case for coccinelle. However, somehow I'm struggling to write a
patch for this. All the documentation that I could get my hands on seems
to describe more abstract changes that require the use of variables -
but as far as I can tell, I need something much simpler:

@@
"struct fasel_foo must be a type name!"
@@
- struct fasel_foo
+ struct fasel_bar


...if only I knew what to put between the @@.

Can someone point me in the right direction?


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-05  3:27 [Cocci] Replacing one (specific!) type with another Nikolaus Rath
@ 2016-10-05  5:45 ` Julia Lawall
  2016-10-05 16:09   ` Nikolaus Rath
  2016-10-05  5:51 ` SF Markus Elfring
  1 sibling, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-05  5:45 UTC (permalink / raw)
  To: cocci



On Tue, 4 Oct 2016, Nikolaus Rath wrote:

> Hello,
>
> In a set of C files, I would like to replace each instance of one type
> (struct fasel_foo) with another type (struct fasel_bar). For instance,
>
> char* fasel_foo_print(struct fasel_foo *ptr) {
>     // ...
>    return "this struct fasel_foo string should not change";
> }
>
> should become
>
> char* fasel_foo_print(struct fasel_bar *ptr) {
>     // ...
>    return "this struct fasel_foo string should not change";
> }
>
>
> Based on the LWN articles that I've read, this seems like the perfect
> use-case for coccinelle. However, somehow I'm struggling to write a
> patch for this. All the documentation that I could get my hands on seems
> to describe more abstract changes that require the use of variables -
> but as far as I can tell, I need something much simpler:
>
> @@
> "struct fasel_foo must be a type name!"
> @@
> - struct fasel_foo
> + struct fasel_bar
>
>
> ...if only I knew what to put between the @@.

Put nothing :)  From the word struct it should figure out that it is
working on a type.

julia

>
> Can someone point me in the right direction?
>
>
> Best,
> -Nikolaus
>
> --
> GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
> Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
>              ?Time flies like an arrow, fruit flies like a Banana.?
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-05  3:27 [Cocci] Replacing one (specific!) type with another Nikolaus Rath
  2016-10-05  5:45 ` Julia Lawall
@ 2016-10-05  5:51 ` SF Markus Elfring
  1 sibling, 0 replies; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-05  5:51 UTC (permalink / raw)
  To: cocci

> Based on the LWN articles that I've read, this seems like the perfect
> use-case for coccinelle.

I would expect this also if you are interested in the simple replacement
for the data type of a function parameter.


> However, somehow I'm struggling to write a patch for this.

Are you exploring the software development possibilities together with
the semantic patch language?


> All the documentation that I could get my hands on seems to describe
> more abstract changes that require the use of variables

SmPL metavariables have got their purposes. How do you think about
to discuss a bit more if you will eventually use them also?


> - but as far as I can tell, I need something much simpler:

There are some improvement opportunities in this approach.


> @@
> "struct fasel_foo must be a type name!"
> @@

How did you get the idea to place this test string there?


> - struct fasel_foo
> + struct fasel_bar
> 
> 
> ...if only I knew what to put between the @@.

Are the other parts of this source code search pattern also incomplete so far?


> Can someone point me in the right direction?

I hope so.

Would the following small SmPL script fit to your expectations?


@data_type_replacement@
@@
 char* fasel_foo_print(
-struct fasel_foo
+struct fasel_bar
                       *ptr) {
    // ...
   return "this struct fasel_foo string should not change";
}



Regards,
Markus

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-05  5:45 ` Julia Lawall
@ 2016-10-05 16:09   ` Nikolaus Rath
  2016-10-05 16:39     ` Michael Stefaniuc
                       ` (2 more replies)
  0 siblings, 3 replies; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-05 16:09 UTC (permalink / raw)
  To: cocci

On Oct 05 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Tue, 4 Oct 2016, Nikolaus Rath wrote:
>
>> Hello,
>>
>> In a set of C files, I would like to replace each instance of one type
>> (struct fasel_foo) with another type (struct fasel_bar). For instance,
>>
>> char* fasel_foo_print(struct fasel_foo *ptr) {
>>     // ...
>>    return "this struct fasel_foo string should not change";
>> }
>>
>> should become
>>
>> char* fasel_foo_print(struct fasel_bar *ptr) {
>>     // ...
>>    return "this struct fasel_foo string should not change";
>> }
>>
>>
>> Based on the LWN articles that I've read, this seems like the perfect
>> use-case for coccinelle. However, somehow I'm struggling to write a
>> patch for this. All the documentation that I could get my hands on seems
>> to describe more abstract changes that require the use of variables -
>> but as far as I can tell, I need something much simpler:
>>
>> @@
>> "struct fasel_foo must be a type name!"
>> @@
>> - struct fasel_foo
>> + struct fasel_bar
>>
>>
>> ...if only I knew what to put between the @@.
>
> Put nothing :)  From the word struct it should figure out that it is
> working on a type.

Oh, great! Thanks!


This solves my problem, but it makes me wonder how this generalizes to
other problems. For example, 

1. What would I need to do if I don't want to replace a struct but
   something typedef'd? (my_type *ptr --> new_type *ptr).

2. ..and how would I go about if instead of the type, I want to replace
   a variable name? (my_type *ptr --> my_type *pointer).


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-05 16:09   ` Nikolaus Rath
@ 2016-10-05 16:39     ` Michael Stefaniuc
  2016-10-05 17:21     ` [Cocci] Replacing one variable name " SF Markus Elfring
  2016-10-05 20:02     ` [Cocci] Replacing one (specific!) type " Julia Lawall
  2 siblings, 0 replies; 46+ messages in thread
From: Michael Stefaniuc @ 2016-10-05 16:39 UTC (permalink / raw)
  To: cocci

On 10/05/2016 06:09 PM, Nikolaus Rath wrote:
> On Oct 05 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> On Tue, 4 Oct 2016, Nikolaus Rath wrote:
>>
>>> Hello,
>>>
>>> In a set of C files, I would like to replace each instance of one type
>>> (struct fasel_foo) with another type (struct fasel_bar). For instance,
>>>
>>> char* fasel_foo_print(struct fasel_foo *ptr) {
>>>     // ...
>>>    return "this struct fasel_foo string should not change";
>>> }
>>>
>>> should become
>>>
>>> char* fasel_foo_print(struct fasel_bar *ptr) {
>>>     // ...
>>>    return "this struct fasel_foo string should not change";
>>> }
>>>
>>>
>>> Based on the LWN articles that I've read, this seems like the perfect
>>> use-case for coccinelle. However, somehow I'm struggling to write a
>>> patch for this. All the documentation that I could get my hands on seems
>>> to describe more abstract changes that require the use of variables -
>>> but as far as I can tell, I need something much simpler:
>>>
>>> @@
>>> "struct fasel_foo must be a type name!"
>>> @@
>>> - struct fasel_foo
>>> + struct fasel_bar
>>>
>>>
>>> ...if only I knew what to put between the @@.
>>
>> Put nothing :)  From the word struct it should figure out that it is
>> working on a type.
> 
> Oh, great! Thanks!
> 
> 
> This solves my problem, but it makes me wonder how this generalizes to
> other problems. For example, 
> 
> 1. What would I need to do if I don't want to replace a struct but
>    something typedef'd? (my_type *ptr --> new_type *ptr).
Easy

@@
typedef my_type, new_type;
@@
- my_type
+ new_type

> 2. ..and how would I go about if instead of the type, I want to replace
>    a variable name? (my_type *ptr --> my_type *pointer).
Depends on the exact circumstance. But that's easy to figure out. I
recommend the workshop papers and tutorials from
http://coccinelle.lip6.fr/papers.php; I wish I would have had those when
I started with coccinelle.

bye
	michael

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

* [Cocci] Replacing one variable name with another
  2016-10-05 16:09   ` Nikolaus Rath
  2016-10-05 16:39     ` Michael Stefaniuc
@ 2016-10-05 17:21     ` SF Markus Elfring
  2016-10-05 22:34       ` Nikolaus Rath
  2016-10-05 20:02     ` [Cocci] Replacing one (specific!) type " Julia Lawall
  2 siblings, 1 reply; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-05 17:21 UTC (permalink / raw)
  To: cocci

> 2. ..and how would I go about if instead of the type, I want to replace
>    a variable name? (my_type *ptr --> my_type *pointer).

Would you like to try another small SmPL script out like the following?


@name_replacement@
@@
 my_type *
-ptr
+pointer
 ;


How will your software development experiments evolve for the desired
application of the semantic patch language?

Regards,
Markus

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-05 16:09   ` Nikolaus Rath
  2016-10-05 16:39     ` Michael Stefaniuc
  2016-10-05 17:21     ` [Cocci] Replacing one variable name " SF Markus Elfring
@ 2016-10-05 20:02     ` Julia Lawall
  2016-10-05 22:38       ` Nikolaus Rath
  2016-10-08  4:22       ` Nikolaus Rath
  2 siblings, 2 replies; 46+ messages in thread
From: Julia Lawall @ 2016-10-05 20:02 UTC (permalink / raw)
  To: cocci



On Wed, 5 Oct 2016, Nikolaus Rath wrote:

> On Oct 05 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> > On Tue, 4 Oct 2016, Nikolaus Rath wrote:
> >
> >> Hello,
> >>
> >> In a set of C files, I would like to replace each instance of one type
> >> (struct fasel_foo) with another type (struct fasel_bar). For instance,
> >>
> >> char* fasel_foo_print(struct fasel_foo *ptr) {
> >>     // ...
> >>    return "this struct fasel_foo string should not change";
> >> }
> >>
> >> should become
> >>
> >> char* fasel_foo_print(struct fasel_bar *ptr) {
> >>     // ...
> >>    return "this struct fasel_foo string should not change";
> >> }
> >>
> >>
> >> Based on the LWN articles that I've read, this seems like the perfect
> >> use-case for coccinelle. However, somehow I'm struggling to write a
> >> patch for this. All the documentation that I could get my hands on seems
> >> to describe more abstract changes that require the use of variables -
> >> but as far as I can tell, I need something much simpler:
> >>
> >> @@
> >> "struct fasel_foo must be a type name!"
> >> @@
> >> - struct fasel_foo
> >> + struct fasel_bar
> >>
> >>
> >> ...if only I knew what to put between the @@.
> >
> > Put nothing :)  From the word struct it should figure out that it is
> > working on a type.
>
> Oh, great! Thanks!
> >
> This solves my problem, but it makes me wonder how this generalizes to
> other problems. For example,
>
> 1. What would I need to do if I don't want to replace a struct but
>    something typedef'd? (my_type *ptr --> new_type *ptr).

Coccinelle needs to know that the thing is a typedef.  So this time, you
can start your rule with

@@
typedef my_type;
typedef new_type;
@@

>
> 2. ..and how would I go about if instead of the type, I want to replace
>    a variable name? (my_type *ptr --> my_type *pointer).

I'm not completely sure what the issue is here.  Do you specifically want
to convert ptr to pointer?  Is the type important?  To make exactly what
you have written, you could put:

@@
typedef my_type;
idexpression mytype * p1;
@@

- ptr at p1
+ pointer

This checks for the word ptr, and also checks that it is an identifier of
the right type.  I haven't tested it, so let me know if there is any
problem.

julia

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

* [Cocci] Replacing one variable name with another
  2016-10-05 17:21     ` [Cocci] Replacing one variable name " SF Markus Elfring
@ 2016-10-05 22:34       ` Nikolaus Rath
  2016-10-06  5:42         ` SF Markus Elfring
  2016-10-06  5:56         ` Julia Lawall
  0 siblings, 2 replies; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-05 22:34 UTC (permalink / raw)
  To: cocci

On Oct 05 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>> 2. ..and how would I go about if instead of the type, I want to replace
>>    a variable name? (my_type *ptr --> my_type *pointer).
>
> Would you like to try another small SmPL script out like the following?
>
>
> @name_replacement@
> @@
>  my_type *
> -ptr
> +pointer
>  ;

I could try it, but I'm actually more interested in understanding how
this works (I already solved my primariy problem). Could you explain
this script a bit more? What exactly does "@name_replacement@" mean?
Does it the interpretation of "my_type *" further down?


> How will your software development experiments evolve for the desired
> application of the semantic patch language?

Aeh, sorry, I don't understand the question.


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-05 20:02     ` [Cocci] Replacing one (specific!) type " Julia Lawall
@ 2016-10-05 22:38       ` Nikolaus Rath
  2016-10-06  5:55         ` Julia Lawall
  2016-10-06  6:30         ` [Cocci] Replacing one (specific!) type with another SF Markus Elfring
  2016-10-08  4:22       ` Nikolaus Rath
  1 sibling, 2 replies; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-05 22:38 UTC (permalink / raw)
  To: cocci

On Oct 05 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> 1. What would I need to do if I don't want to replace a struct but
>>    something typedef'd? (my_type *ptr --> new_type *ptr).
>
> Coccinelle needs to know that the thing is a typedef.  So this time, you
> can start your rule with
>
> @@
> typedef my_type;
> typedef new_type;
> @@

Makes sense, thanks!

>> 2. ..and how would I go about if instead of the type, I want to replace
>>    a variable name? (my_type *ptr --> my_type *pointer).
>
> I'm not completely sure what the issue is here.  Do you specifically want
> to convert ptr to pointer?  Is the type important?  To make exactly what
> you have written, you could put:
>
> @@
> typedef my_type;
> idexpression mytype * p1;
> @@
>
> - ptr at p1
> + pointer
>
> This checks for the word ptr, and also checks that it is an identifier of
> the right type.  I haven't tested it, so let me know if there is any
> problem.

Well, I don't have an actual use-case anymore. My problem is solved, I'm
just curious what else I could do with Coccinelle to do :-).

Somehow I'm having a really hard time grasping the fundamentals. The
first two examples make sense - I could adapt them for similar
situations. But then, I still have absolutely no idea how I would come
up with the third example, or how to adapt it. What does "idexpression"
mean? What does "ptr at p1" mean? Is this documented anywhere? 

I'd hate to waste your time asking tons of such trivial questions on the
mailing list, but I just can't find any helpful documentation at all...


Best,
-Nikolaus
-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one variable name with another
  2016-10-05 22:34       ` Nikolaus Rath
@ 2016-10-06  5:42         ` SF Markus Elfring
  2016-10-06  5:56         ` Julia Lawall
  1 sibling, 0 replies; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-06  5:42 UTC (permalink / raw)
  To: cocci

>> @name_replacement@
>> @@
>>  my_type *
>> -ptr
>> +pointer
>>  ;
> 
> I could try it, but I'm actually more interested in understanding how
> this works (I already solved my primariy problem).

Thanks for your interest.


> Could you explain this script a bit more?

Yes, of course.

It shows the general structure of a simple script for the semantic patch language.

Outline:
* Block for definition of SmPL metavariables
* Specification of C source code fragments (together with desired changes)


> What exactly does "@name_replacement@" mean?

Such a SmPL rule can specify a name for it. Which identifier would you
choose there according to your naming preferences?
http://coccinelle.lip6.fr/docs/main_grammar002.html


> Does it the interpretation of "my_type *" further down?

No. - I tend to use a title there which is descriptive somewhat.


>> How will your software development experiments evolve for the desired
>> application of the semantic patch language?
> 
> Aeh, sorry, I don't understand the question.

Do you plan to try any more SmPL scripts out?
How do you think about to share further experiences?

Regards,
Markus

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-05 22:38       ` Nikolaus Rath
@ 2016-10-06  5:55         ` Julia Lawall
  2016-10-08  3:16           ` Nikolaus Rath
  2016-10-06  6:30         ` [Cocci] Replacing one (specific!) type with another SF Markus Elfring
  1 sibling, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-06  5:55 UTC (permalink / raw)
  To: cocci



On Wed, 5 Oct 2016, Nikolaus Rath wrote:

> On Oct 05 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> 1. What would I need to do if I don't want to replace a struct but
> >>    something typedef'd? (my_type *ptr --> new_type *ptr).
> >
> > Coccinelle needs to know that the thing is a typedef.  So this time, you
> > can start your rule with
> >
> > @@
> > typedef my_type;
> > typedef new_type;
> > @@
>
> Makes sense, thanks!
>
> >> 2. ..and how would I go about if instead of the type, I want to replace
> >>    a variable name? (my_type *ptr --> my_type *pointer).
> >
> > I'm not completely sure what the issue is here.  Do you specifically want
> > to convert ptr to pointer?  Is the type important?  To make exactly what
> > you have written, you could put:
> >
> > @@
> > typedef my_type;
> > idexpression mytype * p1;
> > @@
> >
> > - ptr at p1
> > + pointer
> >
> > This checks for the word ptr, and also checks that it is an identifier of
> > the right type.  I haven't tested it, so let me know if there is any
> > problem.
>
> Well, I don't have an actual use-case anymore. My problem is solved, I'm
> just curious what else I could do with Coccinelle to do :-).
>
> Somehow I'm having a really hard time grasping the fundamentals. The
> first two examples make sense - I could adapt them for similar
> situations. But then, I still have absolutely no idea how I would come
> up with the third example, or how to adapt it. What does "idexpression"
> mean? What does "ptr at p1" mean? Is this documented anywhere?

idexpression is an expression that is resricted to be an identifier.  It
allows you to put a type on an expression that has the form of an
identifier.  You can also say identifier x;  But that is just a name.  It
has no type.  It could be an expression, a field name, a parameter name,
etc.

@ connects patterns that match the same term.  So match a term against the
explicit name ptr and also match it against an identifier expression that
has a particular type.  This is not exactly a beginner example.

> I'd hate to waste your time asking tons of such trivial questions on the
> mailing list, but I just can't find any helpful documentation at all...

If you look on the web page in the papers and slides section, at the top
there are several tutorials and overview talks, some with video.

There is a grammar of the language at
http://coccinelle.lip6.fr/documentation.php
I doubt that it would be very helpful for a beginner.  But there are many
examples at another link on the same page.

julia

>
> Best,
> -Nikolaus
> --
> GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
> Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
>              ?Time flies like an arrow, fruit flies like a Banana.?
>

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

* [Cocci] Replacing one variable name with another
  2016-10-05 22:34       ` Nikolaus Rath
  2016-10-06  5:42         ` SF Markus Elfring
@ 2016-10-06  5:56         ` Julia Lawall
  1 sibling, 0 replies; 46+ messages in thread
From: Julia Lawall @ 2016-10-06  5:56 UTC (permalink / raw)
  To: cocci



On Wed, 5 Oct 2016, Nikolaus Rath wrote:

> On Oct 05 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> >> 2. ..and how would I go about if instead of the type, I want to replace
> >>    a variable name? (my_type *ptr --> my_type *pointer).
> >
> > Would you like to try another small SmPL script out like the following?
> >
> >
> > @name_replacement@
> > @@
> >  my_type *
> > -ptr
> > +pointer
> >  ;
>
> I could try it, but I'm actually more interested in understanding how
> this works (I already solved my primariy problem). Could you explain
> this script a bit more? What exactly does "@name_replacement@" mean?

Between the initial @@ you can put the name of the rule, as well as some
other information.  If no other rule needs to refer to this one, then
there is no need for a name.

julia

> Does it the interpretation of "my_type *" further down?
>
>
> > How will your software development experiments evolve for the desired
> > application of the semantic patch language?
>
> Aeh, sorry, I don't understand the question.
>
>
> Best,
> -Nikolaus
>
> --
> GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
> Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
>              ?Time flies like an arrow, fruit flies like a Banana.?
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-05 22:38       ` Nikolaus Rath
  2016-10-06  5:55         ` Julia Lawall
@ 2016-10-06  6:30         ` SF Markus Elfring
  1 sibling, 0 replies; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-06  6:30 UTC (permalink / raw)
  To: cocci

>> @@
>> typedef my_type;
>> idexpression mytype * p1;
>> @@
>>
>> - ptr at p1
>> + pointer
>>
>> This checks for the word ptr, and also checks that it is an identifier of
>> the right type.  I haven't tested it, so let me know if there is any problem.
> 
> Well, I don't have an actual use-case anymore.

I am curious when the next one will evolve for you.


> My problem is solved,

Nice to hear.


> I'm just curious what else I could do with Coccinelle to do :-).

This software supports a lot of development possibilities.


> Somehow I'm having a really hard time grasping the fundamentals.

The learning process can take a while as usual.


> The first two examples make sense - I could adapt them for similar situations.

Thanks for your understanding.


> But then, I still have absolutely no idea how I would come
> up with the third example, or how to adapt it.

The usage of SmPL metavariables was demonstrated a bit.


> What does "idexpression" mean?

This is a specific metavariable type which handles C variables.


> What does "ptr at p1" mean?

This expression shows the restriction of a C code identifier by the means
of a SmPL variable.


> Is this documented anywhere?

Yes, of course.
http://coccinelle.lip6.fr/docs/main_grammar002.html#elem

Would you like to help in improving corresponding descriptions?


> I'd hate to waste your time asking tons of such trivial questions
> on the mailing list,

The answers will be published from which others can hopefully learn a bit.
It will take some time to become more familiar with an evolving
software technology.

Are you looking for a FAQ document?


> but I just can't find any helpful documentation at all...

I find this feedback strange. - Where did you look so far?

The help could become better there as usual.
Which information sources did you check before?

Regards,
Markus

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-06  5:55         ` Julia Lawall
@ 2016-10-08  3:16           ` Nikolaus Rath
  2016-10-08  5:50             ` Julia Lawall
  2016-10-08  6:48             ` [Cocci] Usage of "expressions" and "identifiers" with SmPL SF Markus Elfring
  0 siblings, 2 replies; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-08  3:16 UTC (permalink / raw)
  To: cocci

On Oct 06 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> Somehow I'm having a really hard time grasping the fundamentals. The
>> first two examples make sense - I could adapt them for similar
>> situations. But then, I still have absolutely no idea how I would come
>> up with the third example, or how to adapt it. What does "idexpression"
>> mean? What does "ptr at p1" mean? Is this documented anywhere?
>
> idexpression is an expression that is resricted to be an identifier.  It
> allows you to put a type on an expression that has the form of an
> identifier.  You can also say identifier x;  But that is just a name.  It
> has no type.  It could be an expression, a field name, a parameter name,
> etc.

Hm. Based on your last two sentences I'd conclude that 'idexpression'
matches variable names for variables of a specific type. But that
doesn't seem to be what you describe in your first two sentences. Could
you explain what you meant iwth "expression that has the form of an
identifier"?

To me, an identifier is something that's written literally into the
source code and cannot be meaningfully taken apart, e.g. a function
name, variable name, or the member of a struct. An expression, on the
other hand, is something that can be meaningfully split into
sub-components. Is that also how you use these terms?

> @ connects patterns that match the same term.  So match a term against the
> explicit name ptr and also match it against an identifier expression that
> has a particular type.  This is not exactly a beginner example.

Okay, I'll just ignore that for now.

>> I'd hate to waste your time asking tons of such trivial questions on the
>> mailing list, but I just can't find any helpful documentation at all...
>
> If you look on the web page in the papers and slides section, at the top
> there are several tutorials and overview talks, some with video.

I think I looked at everything that is not a video. But none of it
mentioned that you can put an arbitrary name between the @@ or explained
what the different metavariable types (idexpression, expression, etc)
are.

Anyway, enough whining. Coccinelle seems like a really useful tool, even
if I'm having an impedance mismatch with its documentation.


Best,
-Niko

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-05 20:02     ` [Cocci] Replacing one (specific!) type " Julia Lawall
  2016-10-05 22:38       ` Nikolaus Rath
@ 2016-10-08  4:22       ` Nikolaus Rath
  2016-10-08  5:31         ` Julia Lawall
  1 sibling, 1 reply; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-08  4:22 UTC (permalink / raw)
  To: cocci

On Oct 05 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>>
>> 2. ..and how would I go about if instead of the type, I want to replace
>>    a variable name? (my_type *ptr --> my_type *pointer).
>
> I'm not completely sure what the issue is here.  Do you specifically want
> to convert ptr to pointer?  Is the type important?  To make exactly what
> you have written, you could put:
>
> @@
> typedef my_type;
> idexpression mytype * p1;
> @@
>
> - ptr at p1
> + pointer
>
> This checks for the word ptr, and also checks that it is an identifier of
> the right type.  I haven't tested it, so let me know if there is any
> problem.

It workes somewhat... but not completely.

Here's what I wanted to do: I merged two structures (struct fuse_session
and struct fuse_ll) into one (struct fuse_session). I've first replaced
all the type names, and then manually fixed the cases where this
resulted in bogus/redundant code (typically in functions that used to
work with both structs).

Now my project compiles and runs fine, but I the variable naming is
inconsistent: in some cases the struct fuse_session pointer is called
*se (these were the variables that were always of type struct
fuse_session), and in other cases the pointer is called *f (these were
the variables that were previously of type struct fuse_ll).

I'd like to fix this too, and always refer call fuse_session pointers
"se" (except where this name is already used for something else, but
I'll just fix this up by hand afterwards). I tried the following patch:

$ cat se-name.cocci 
@@
idexpression struct fuse_session *p1;
@@
- f at p1
+ se

but it resulted in these changes:

 	struct fuse_session *f = req->se;
-	struct cuse_data *cd = f->cuse_data;
-	size_t bufsize = f->bufsize;
+	struct cuse_data *cd = se->cuse_data;
+	size_t bufsize = se->bufsize;

So it seems to replace the variable where its used, but not where it's
defined.

Is there a way to catch the definitions too?


Best,
-Nikolaus


-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-08  4:22       ` Nikolaus Rath
@ 2016-10-08  5:31         ` Julia Lawall
  2016-10-08 20:52           ` Nikolaus Rath
  0 siblings, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-08  5:31 UTC (permalink / raw)
  To: cocci



On Fri, 7 Oct 2016, Nikolaus Rath wrote:

> On Oct 05 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >>
> >> 2. ..and how would I go about if instead of the type, I want to replace
> >>    a variable name? (my_type *ptr --> my_type *pointer).
> >
> > I'm not completely sure what the issue is here.  Do you specifically want
> > to convert ptr to pointer?  Is the type important?  To make exactly what
> > you have written, you could put:
> >
> > @@
> > typedef my_type;
> > idexpression mytype * p1;
> > @@
> >
> > - ptr at p1
> > + pointer
> >
> > This checks for the word ptr, and also checks that it is an identifier of
> > the right type.  I haven't tested it, so let me know if there is any
> > problem.
>
> It workes somewhat... but not completely.
>
> Here's what I wanted to do: I merged two structures (struct fuse_session
> and struct fuse_ll) into one (struct fuse_session). I've first replaced
> all the type names, and then manually fixed the cases where this
> resulted in bogus/redundant code (typically in functions that used to
> work with both structs).
>
> Now my project compiles and runs fine, but I the variable naming is
> inconsistent: in some cases the struct fuse_session pointer is called
> *se (these were the variables that were always of type struct
> fuse_session), and in other cases the pointer is called *f (these were
> the variables that were previously of type struct fuse_ll).
>
> I'd like to fix this too, and always refer call fuse_session pointers
> "se" (except where this name is already used for something else, but
> I'll just fix this up by hand afterwards). I tried the following patch:
>
> $ cat se-name.cocci
> @@
> idexpression struct fuse_session *p1;
> @@
> - f at p1
> + se
>
> but it resulted in these changes:
>
>  	struct fuse_session *f = req->se;
> -	struct cuse_data *cd = f->cuse_data;
> -	size_t bufsize = f->bufsize;
> +	struct cuse_data *cd = se->cuse_data;
> +	size_t bufsize = se->bufsize;
>
> So it seems to replace the variable where its used, but not where it's
> defined.
>
> Is there a way to catch the definitions too?

Write separate rules for that.  You would need one case for a local
variable and one case fora parameter.  You can actually probably just drop
the rule you have currently.  I would imagine something like the
following:

@@
symbol f, se; // avoid unneeded warnings from Coccinelle
@@

struct fuse_session *
-f
+se
 ;
<...
-f
+se
...>

@@
identifier fn;
@@

fn(...,struct fuse_session *f,...) { <...
-f
+se
...> }

I think that the symbol declaration has effect in the rest of the semantic
patch, and does not have to be repeated.  If you get warnings for the
second rule, just copy it down.

julia

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-08  3:16           ` Nikolaus Rath
@ 2016-10-08  5:50             ` Julia Lawall
  2016-10-08 20:45               ` Nikolaus Rath
  2016-10-08  6:48             ` [Cocci] Usage of "expressions" and "identifiers" with SmPL SF Markus Elfring
  1 sibling, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-08  5:50 UTC (permalink / raw)
  To: cocci



On Fri, 7 Oct 2016, Nikolaus Rath wrote:

> On Oct 06 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> Somehow I'm having a really hard time grasping the fundamentals. The
> >> first two examples make sense - I could adapt them for similar
> >> situations. But then, I still have absolutely no idea how I would come
> >> up with the third example, or how to adapt it. What does "idexpression"
> >> mean? What does "ptr at p1" mean? Is this documented anywhere?
> >
> > idexpression is an expression that is resricted to be an identifier.  It
> > allows you to put a type on an expression that has the form of an
> > identifier.  You can also say identifier x;  But that is just a name.  It
> > has no type.  It could be an expression, a field name, a parameter name,
> > etc.
>
> Hm. Based on your last two sentences I'd conclude that 'idexpression'
> matches variable names for variables of a specific type. But that
> doesn't seem to be what you describe in your first two sentences. Could
> you explain what you meant iwth "expression that has the form of an
> identifier"?
>
> To me, an identifier is something that's written literally into the
> source code and cannot be meaningfully taken apart, e.g. a function
> name, variable name, or the member of a struct. An expression, on the
> other hand, is something that can be meaningfully split into
> sub-components. Is that also how you use these terms?

An expression is something that has a value.  So an idexpression would be
something that cannot be taken apart, but it is also used in a context
where it has a value.  Unlike in the case of a parameter name or field
name, where it is a name for something that will get a value in the
future.

>
> > @ connects patterns that match the same term.  So match a term against the
> > explicit name ptr and also match it against an identifier expression that
> > has a particular type.  This is not exactly a beginner example.
>
> Okay, I'll just ignore that for now.
>
> >> I'd hate to waste your time asking tons of such trivial questions on the
> >> mailing list, but I just can't find any helpful documentation at all...
> >
> > If you look on the web page in the papers and slides section, at the top
> > there are several tutorials and overview talks, some with video.
>
> I think I looked at everything that is not a video. But none of it
> mentioned that you can put an arbitrary name between the @@ or explained
> what the different metavariable types (idexpression, expression, etc)
> are.

The name is illustrated in Advanced SmPL:
http://coccinelle.lip6.fr/papers/cocciwk4_talk2.pdf

A variety of metavariable types are listed in slide 11 of the Linux
oriented tutorial: http://coccinelle.lip6.fr/papers/tutorial.pdf

julia

> Anyway, enough whining. Coccinelle seems like a really useful tool, even
> if I'm having an impedance mismatch with its documentation.
>
>
> Best,
> -Niko
>
> --
> GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
> Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
>              ?Time flies like an arrow, fruit flies like a Banana.?
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-08  3:16           ` Nikolaus Rath
  2016-10-08  5:50             ` Julia Lawall
@ 2016-10-08  6:48             ` SF Markus Elfring
  2016-10-08  6:57               ` Julia Lawall
       [not found]               ` <alpine.DEB.2.10.1610080850470.7750@hadrien>
  1 sibling, 2 replies; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-08  6:48 UTC (permalink / raw)
  To: cocci

> To me, an identifier is something that's written literally into the
> source code and cannot be meaningfully taken apart, e.g. a function
> name, variable name, or the member of a struct. An expression, on the
> other hand, is something that can be meaningfully split into
> sub-components. Is that also how you use these terms?

Yes, in principle.

The Coccinelle software was designed for the generation of semantic patches.

1. Its tool "spatch" expects some input and will usually produce
   corresponding output.

2. One kind of such input are source files for which data processing
   is also directly supported if they were mostly written in a programming
   language like "C".

3. Another kind of required input is the specification of source code search
   or transformation patterns in the semantic patch language.

4. Special data processing is also possible just because the programming
   languages "OCaml" and "Python" can be used in SmPL script rules already.

5. There are several languages involved. SmPL script developers need to be
   careful about the relevant syntax context.

   * So while you are looking from a view of "C source", you might tend
     to think about "C identifiers". The semantic patch language provides
     metavariables which can get the data type "identifier".

   * But what was an "item" in the source language can become an other
     in the Coccinelle technology.
     One example is the use of a metavariable with the type "idexpression"
     in your case. At which places would you start to think about a code
     situation by the means of "expressions"?

   * Syntax constructs from the supported source languages are matched with
     "key words" that are often similar (or even identical) to the host language
     (within SmPL scripts).


>> @ connects patterns that match the same term.  So match a term against the
>> explicit name ptr and also match it against an identifier expression that
>> has a particular type.  This is not exactly a beginner example.
> 
> Okay, I'll just ignore that for now.
> 
>>> I'd hate to waste your time asking tons of such trivial questions on the
>>> mailing list, but I just can't find any helpful documentation at all...
>>
>> If you look on the web page in the papers and slides section, at the top
>> there are several tutorials and overview talks, some with video.
> 
> I think I looked at everything that is not a video.

Thanks for your feedback.


> But none of it mentioned that you can put an arbitrary name between the @@

I got an other impression from the available documentation.


> or explained what the different metavariable types (idexpression,
> expression, etc) are.

I see some improvement possibilities there, too.


> Anyway, enough whining. Coccinelle seems like a really useful tool,

Yes, of course.


> even if I'm having an impedance mismatch with its documentation.

Do you see further chances to reduce this mismatch for following
software developers?

Regards,
Markus

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-08  6:48             ` [Cocci] Usage of "expressions" and "identifiers" with SmPL SF Markus Elfring
@ 2016-10-08  6:57               ` Julia Lawall
       [not found]               ` <alpine.DEB.2.10.1610080850470.7750@hadrien>
  1 sibling, 0 replies; 46+ messages in thread
From: Julia Lawall @ 2016-10-08  6:57 UTC (permalink / raw)
  To: cocci

Nicolaus, please ignore this message.

julia

On Sat, 8 Oct 2016, SF Markus Elfring wrote:

> > To me, an identifier is something that's written literally into the
> > source code and cannot be meaningfully taken apart, e.g. a function
> > name, variable name, or the member of a struct. An expression, on the
> > other hand, is something that can be meaningfully split into
> > sub-components. Is that also how you use these terms?
>
> Yes, in principle.
>
> The Coccinelle software was designed for the generation of semantic patches.
>
> 1. Its tool "spatch" expects some input and will usually produce
>    corresponding output.
>
> 2. One kind of such input are source files for which data processing
>    is also directly supported if they were mostly written in a programming
>    language like "C".
>
> 3. Another kind of required input is the specification of source code search
>    or transformation patterns in the semantic patch language.
>
> 4. Special data processing is also possible just because the programming
>    languages "OCaml" and "Python" can be used in SmPL script rules already.
>
> 5. There are several languages involved. SmPL script developers need to be
>    careful about the relevant syntax context.
>
>    * So while you are looking from a view of "C source", you might tend
>      to think about "C identifiers". The semantic patch language provides
>      metavariables which can get the data type "identifier".
>
>    * But what was an "item" in the source language can become an other
>      in the Coccinelle technology.
>      One example is the use of a metavariable with the type "idexpression"
>      in your case. At which places would you start to think about a code
>      situation by the means of "expressions"?
>
>    * Syntax constructs from the supported source languages are matched with
>      "key words" that are often similar (or even identical) to the host language
>      (within SmPL scripts).
>
>
> >> @ connects patterns that match the same term.  So match a term against the
> >> explicit name ptr and also match it against an identifier expression that
> >> has a particular type.  This is not exactly a beginner example.
> >
> > Okay, I'll just ignore that for now.
> >
> >>> I'd hate to waste your time asking tons of such trivial questions on the
> >>> mailing list, but I just can't find any helpful documentation at all...
> >>
> >> If you look on the web page in the papers and slides section, at the top
> >> there are several tutorials and overview talks, some with video.
> >
> > I think I looked at everything that is not a video.
>
> Thanks for your feedback.
>
>
> > But none of it mentioned that you can put an arbitrary name between the @@
>
> I got an other impression from the available documentation.
>
>
> > or explained what the different metavariable types (idexpression,
> > expression, etc) are.
>
> I see some improvement possibilities there, too.
>
>
> > Anyway, enough whining. Coccinelle seems like a really useful tool,
>
> Yes, of course.
>
>
> > even if I'm having an impedance mismatch with its documentation.
>
> Do you see further chances to reduce this mismatch for following
> software developers?
>
> Regards,
> Markus
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
       [not found]               ` <alpine.DEB.2.10.1610080850470.7750@hadrien>
@ 2016-10-08  7:49                 ` SF Markus Elfring
  2016-10-08  7:56                   ` Julia Lawall
  0 siblings, 1 reply; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-08  7:49 UTC (permalink / raw)
  To: cocci

>>    * Syntax constructs from the supported source languages are matched with
>>      "key words" that are often similar (or even identical) to the host language
>>      (within SmPL scripts).
> 
> This is an enormous amount of verbiage,

Interesting view ?


> and I don't see the relevance to the question.

I am trying to explain the matching from syntax elements of the
C programming language to the means of the semantic patch language
from my view.


> Furthermore, I would very much appreciate it if you would stop responding
> to any questions from new users.

I find this kind of response surprising.

Would you eventually like to benefit from additional views which evolved
during collaboration of some years?


> You are not the developer or maintainer of Coccinelle.

This information is appropriate to some degree.

How do you think about the evolution around roles like "intensive SmPL user",
"system tester", "bug reporter" and "supporter"?

* I am trying to contribute a bit also to your software.

* I am active as another ordinary free software for years.


> You don't represent the tool in any way.

I do not represent it "officially". - But I can imagine that my software
development activities have got some useful "side effects" from
which a kind of "image" or "representation" could have evolved already.


> A very large portion of the information that you provide is incorrect

Would you like to clarify this a bit more?


> or unnecessary.

I got an other impression about the necessity.


> I am very concerned that you will frighten people away,

I can understand your concern a bit.


> especially if you ask them to do things that go beyond their
> intended involvement, such as your "Do you see further chances to
> reduce..." comment below.

The involvement can eventually increase, can't it?


> The next time you answer a question from a newcomer where your answer
> either includes a question or goes beyond say 3 lines of text, I will
> adjust your subscription to the mailing list such that you no longer
> receive mail.

Did you really get so angry that you reconsider our collaboration in such
a drastic way?


> I'm sure you consider that you are helping out,

I hope so.

Did my small script examples help a bit in the requested clarification?


> but you are not,

I find this feedback interesting and surprising.


> and it needs to stop immediately.

How can software development discussions be continued after such a response?

Regards,
Markus

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-08  7:49                 ` SF Markus Elfring
@ 2016-10-08  7:56                   ` Julia Lawall
  2016-10-08  8:26                     ` SF Markus Elfring
  0 siblings, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-08  7:56 UTC (permalink / raw)
  To: cocci

> > The next time you answer a question from a newcomer where your answer
> > either includes a question or goes beyond say 3 lines of text, I will
> > adjust your subscription to the mailing list such that you no longer
> > receive mail.
>
> Did you really get so angry that you reconsider our collaboration in such
> a drastic way?

I'm not angry at all, only tired of so much incorrect or unnecessary
information being provided to new users.  It's not practical to write to
each new user and say "Please ignore this message".  I would prefer that
they just stop in the first place.

julia

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-08  7:56                   ` Julia Lawall
@ 2016-10-08  8:26                     ` SF Markus Elfring
  2016-10-08  8:38                       ` Julia Lawall
  0 siblings, 1 reply; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-08  8:26 UTC (permalink / raw)
  To: cocci

> I'm not angry at all,

Thanks for your feedback that there are other emotions involved.


> only tired of so much incorrect

Which details from my description approach are inappropriate in your view?


> or unnecessary information being provided to new users.

I got the impression somehow that the clarification request by Nikolaus Rath 
evolved into a direction where further technical background information
would be useful.
He can also decide on his own if and how he would eventually like to
continue this software development and user support discussion.

Regards,
Markus

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-08  8:26                     ` SF Markus Elfring
@ 2016-10-08  8:38                       ` Julia Lawall
  2016-10-08  9:25                         ` SF Markus Elfring
  0 siblings, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-08  8:38 UTC (permalink / raw)
  To: cocci



On Sat, 8 Oct 2016, SF Markus Elfring wrote:

> > I'm not angry at all,
>
> Thanks for your feedback that there are other emotions involved.
>
>
> > only tired of so much incorrect
>
> Which details from my description approach are inappropriate in your view?

The whole numbered list was pointless.  He was trying to understand what
is meant by "idexpression".  This is a concept particular to Coccinelle,
that was introduced because we discovered that sometimes one wants to
focus only on identifiers, but to also specify their types.  I couldn't
tell from your answer what question it was intended to be relevant to, but
I don't think it is the same as the one he was asking.  It seems to be a
generic overview of what Coccinelle does.  Someone who has to read so much
text and in the end has no information about the question he was asking
will not likely get a good impression about the software he is trying to
use.

julia

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-08  8:38                       ` Julia Lawall
@ 2016-10-08  9:25                         ` SF Markus Elfring
  2016-10-08 20:28                           ` Nikolaus Rath
  0 siblings, 1 reply; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-08  9:25 UTC (permalink / raw)
  To: cocci

>> Which details from my description approach are inappropriate in your view?
> 
> The whole numbered list was pointless.

I hope that we can eventually benefit from such a disagreement
in constructive ways.


> He was trying to understand what is meant by "idexpression".

Yes. - The functionality and relationship of this key word was unclear
to some degree together with the usage of "identifiers", wasn't it?


> This is a concept particular to Coccinelle,

I can follow this view.


> that was introduced because we discovered that sometimes one wants to
> focus only on identifiers, but to also specify their types.

Thanks for this kind of background information.


> I couldn't tell from your answer what question it was intended to be relevant to,

I am curious if a bit more clarification of the relevance and my
corresponding intention would be needed.


> but I don't think it is the same as the one he was asking.
> It seems to be a generic overview of what Coccinelle does.

I am also unsure if and how quick Nikolaus Rath will find the provided
technical details a bit useful.


> Someone who has to read so much text and in the end has no information
> about the question he was asking will not likely get a good impression
> about the software he is trying to use.

A beginner should usually read some text for the desired learning experience.
Can it be that you worry a bit too much about the potential for
bad impressions around your software?

Would you like to start another marketing project?


I find that this mailing list gets only low message traffic so far.
So I would imagine that most well-intended discussion contributions could
be useful. Is the mixture of presented topics reasonable?


We came along different views around the usage of "expressions"
in previous discussions, didn't we?
You repeated the explanation "An expression is something that has a value."
which is reasonable to some degree. I would like to know then:
Which "value" is provided by the software construct "idexpression"
in the semantic patch language?

Regards,
Markus

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-08  9:25                         ` SF Markus Elfring
@ 2016-10-08 20:28                           ` Nikolaus Rath
  2016-10-09  7:49                             ` SF Markus Elfring
  0 siblings, 1 reply; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-08 20:28 UTC (permalink / raw)
  To: cocci

On Oct 08 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>> Someone who has to read so much text and in the end has no information
>> about the question he was asking will not likely get a good impression
>> about the software he is trying to use.
>
> A beginner should usually read some text for the desired learning experience.
> Can it be that you worry a bit too much about the potential for
> bad impressions around your software?

Sorry to be the bringer of bad news, but Julia is spot on. The only
effect your emails had on me was a big "WTF!?". Had Julia not responded
to my messages at almost the same time, I would have left this list and
Coccinelle for good.

> Would you like to start another marketing project?

What's the point of all these random questions that you bring up in
response to every sentence? Do you think they are helpful?

> I find that this mailing list gets only low message traffic so far.

Do you think others share this impression? Do you think this is a good
thing or a bad thing? How do you think will this situation evolve?

> So I would imagine that most well-intended discussion contributions could
> be useful. Is the mixture of presented topics reasonable?

What do you mean with discussion contributions? Do you think that asking
if the topic is reasonable is equivalent to asking if the specific
contributions are reasonable?


> We came along different views around the usage of "expressions"
> in previous discussions, didn't we?

Whom do you mean with "we"? Is it important in this context?

> You repeated the explanation "An expression is something that has a value."
> which is reasonable to some degree. I would like to know then:
> Which "value" is provided by the software construct "idexpression"
> in the semantic patch language?

Do you think you will be able to find out the answer to this question?
How could we best assist you in that?


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-08  5:50             ` Julia Lawall
@ 2016-10-08 20:45               ` Nikolaus Rath
  2016-10-08 21:23                 ` Julia Lawall
  2016-10-09  6:32                 ` SF Markus Elfring
  0 siblings, 2 replies; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-08 20:45 UTC (permalink / raw)
  To: cocci

On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Fri, 7 Oct 2016, Nikolaus Rath wrote:
>
>> On Oct 06 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> >> Somehow I'm having a really hard time grasping the fundamentals. The
>> >> first two examples make sense - I could adapt them for similar
>> >> situations. But then, I still have absolutely no idea how I would come
>> >> up with the third example, or how to adapt it. What does "idexpression"
>> >> mean? What does "ptr at p1" mean? Is this documented anywhere?
>> >
>> > idexpression is an expression that is resricted to be an identifier.  It
>> > allows you to put a type on an expression that has the form of an
>> > identifier.  You can also say identifier x;  But that is just a name.  It
>> > has no type.  It could be an expression, a field name, a parameter name,
>> > etc.
>>
>> Hm. Based on your last two sentences I'd conclude that 'idexpression'
>> matches variable names for variables of a specific type. But that
>> doesn't seem to be what you describe in your first two sentences. Could
>> you explain what you meant iwth "expression that has the form of an
>> identifier"?
>>
>> To me, an identifier is something that's written literally into the
>> source code and cannot be meaningfully taken apart, e.g. a function
>> name, variable name, or the member of a struct. An expression, on the
>> other hand, is something that can be meaningfully split into
>> sub-components. Is that also how you use these terms?
>
> An expression is something that has a value.  So an idexpression would be
> something that cannot be taken apart, but it is also used in a context
> where it has a value.  Unlike in the case of a parameter name or field
> name, where it is a name for something that will get a value in the
> future.

Got it, thanks!

>> > @ connects patterns that match the same term.  So match a term against the
>> > explicit name ptr and also match it against an identifier expression that
>> > has a particular type.  This is not exactly a beginner example.
>>
>> Okay, I'll just ignore that for now.
>>
>> >> I'd hate to waste your time asking tons of such trivial questions on the
>> >> mailing list, but I just can't find any helpful documentation at all...
>> >
>> > If you look on the web page in the papers and slides section, at the top
>> > there are several tutorials and overview talks, some with video.
>>
>> I think I looked at everything that is not a video. But none of it
>> mentioned that you can put an arbitrary name between the @@ or explained
>> what the different metavariable types (idexpression, expression, etc)
>> are.
>
> The name is illustrated in Advanced SmPL:
> http://coccinelle.lip6.fr/papers/cocciwk4_talk2.pdf

Call me stupid, but I just went through it again and I still don't see
it. There are lots of examples with "@ ..stuff..@" (the first on slide
4), but as far as I can tell it never explains what this means.

Actually, the frequent occurence of @script:python@ makes me think that
this actually has semantic signficance and is much more than a label
that I can choose for my own convenience...?
 

> A variety of metavariable types are listed in slide 11 of the Linux
> oriented tutorial: http://coccinelle.lip6.fr/papers/tutorial.pdf

Yes, I saw that. But I deliberately wrote "explained" rather than just
"listed" :-).


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-08  5:31         ` Julia Lawall
@ 2016-10-08 20:52           ` Nikolaus Rath
  2016-10-08 21:21             ` Julia Lawall
  0 siblings, 1 reply; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-08 20:52 UTC (permalink / raw)
  To: cocci

On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Fri, 7 Oct 2016, Nikolaus Rath wrote:
>
>> On Oct 05 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> >>
>> >> 2. ..and how would I go about if instead of the type, I want to replace
>> >>    a variable name? (my_type *ptr --> my_type *pointer).
>> >
>> > I'm not completely sure what the issue is here.  Do you specifically want
>> > to convert ptr to pointer?  Is the type important?  To make exactly what
>> > you have written, you could put:
>> >
>> > @@
>> > typedef my_type;
>> > idexpression mytype * p1;
>> > @@
>> >
>> > - ptr at p1
>> > + pointer
>> >
>> > This checks for the word ptr, and also checks that it is an identifier of
>> > the right type.  I haven't tested it, so let me know if there is any
>> > problem.
>>
>> It workes somewhat... but not completely.
>>
>> Here's what I wanted to do: I merged two structures (struct fuse_session
>> and struct fuse_ll) into one (struct fuse_session). I've first replaced
>> all the type names, and then manually fixed the cases where this
>> resulted in bogus/redundant code (typically in functions that used to
>> work with both structs).
>>
>> Now my project compiles and runs fine, but I the variable naming is
>> inconsistent: in some cases the struct fuse_session pointer is called
>> *se (these were the variables that were always of type struct
>> fuse_session), and in other cases the pointer is called *f (these were
>> the variables that were previously of type struct fuse_ll).
>>
>> I'd like to fix this too, and always refer call fuse_session pointers
>> "se" (except where this name is already used for something else, but
>> I'll just fix this up by hand afterwards). I tried the following patch:
>>
>> $ cat se-name.cocci
>> @@
>> idexpression struct fuse_session *p1;
>> @@
>> - f at p1
>> + se
>>
>> but it resulted in these changes:
>>
>>  	struct fuse_session *f = req->se;
>> -	struct cuse_data *cd = f->cuse_data;
>> -	size_t bufsize = f->bufsize;
>> +	struct cuse_data *cd = se->cuse_data;
>> +	size_t bufsize = se->bufsize;
>>
>> So it seems to replace the variable where its used, but not where it's
>> defined.
>>
>> Is there a way to catch the definitions too?
>
> Write separate rules for that.  You would need one case for a local
> variable and one case fora parameter.  You can actually probably just drop
> the rule you have currently.  I would imagine something like the
> following:
>
> @@
> symbol f, se; // avoid unneeded warnings from Coccinelle
> @@
>
> struct fuse_session *
> -f
> +se
>  ;
> <...
> -f
> +se
> ...>

Could you explain how this works (in particular the effect of the angle
brackets)? I also can't resist to point out that "symbol" is not
included in the list of metavariable types from the tutorial slides :-).

> @@
> identifier fn;
> @@
>
> fn(...,struct fuse_session *f,...) { <...
> -f
> +se
> ...> }
>
> I think that the symbol declaration has effect in the rest of the semantic
> patch, and does not have to be repeated.  If you get warnings for the
> second rule, just copy it down.

Not sure what you mean with "copy it down". I don't get Coccinelle
warnings, but if I just use the two rules as you gave them, then
it looks as if the second one isn't working:

@@ -584,9 +584,9 @@ static struct fuse_ll_pipe *fuse_ll_get_
 
 static void fuse_ll_clear_pipe(struct fuse_session *f)
 {
-	struct fuse_ll_pipe *llp = pthread_getspecific(f->pipe_key);
+	struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
 	if (llp) {
-		pthread_setspecific(f->pipe_key, NULL);
+		pthread_setspecific(se->pipe_key, NULL);
 		fuse_ll_pipe_free(llp);
 	}
 }


Is the problem that "...," does not match nothing, i.e. *f must not be
the first argument of the function?


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-08 20:52           ` Nikolaus Rath
@ 2016-10-08 21:21             ` Julia Lawall
  2016-10-09 20:45               ` Nikolaus Rath
  0 siblings, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-08 21:21 UTC (permalink / raw)
  To: cocci



On Sat, 8 Oct 2016, Nikolaus Rath wrote:

> On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> > On Fri, 7 Oct 2016, Nikolaus Rath wrote:
> >
> >> On Oct 05 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> >>
> >> >> 2. ..and how would I go about if instead of the type, I want to replace
> >> >>    a variable name? (my_type *ptr --> my_type *pointer).
> >> >
> >> > I'm not completely sure what the issue is here.  Do you specifically want
> >> > to convert ptr to pointer?  Is the type important?  To make exactly what
> >> > you have written, you could put:
> >> >
> >> > @@
> >> > typedef my_type;
> >> > idexpression mytype * p1;
> >> > @@
> >> >
> >> > - ptr at p1
> >> > + pointer
> >> >
> >> > This checks for the word ptr, and also checks that it is an identifier of
> >> > the right type.  I haven't tested it, so let me know if there is any
> >> > problem.
> >>
> >> It workes somewhat... but not completely.
> >>
> >> Here's what I wanted to do: I merged two structures (struct fuse_session
> >> and struct fuse_ll) into one (struct fuse_session). I've first replaced
> >> all the type names, and then manually fixed the cases where this
> >> resulted in bogus/redundant code (typically in functions that used to
> >> work with both structs).
> >>
> >> Now my project compiles and runs fine, but I the variable naming is
> >> inconsistent: in some cases the struct fuse_session pointer is called
> >> *se (these were the variables that were always of type struct
> >> fuse_session), and in other cases the pointer is called *f (these were
> >> the variables that were previously of type struct fuse_ll).
> >>
> >> I'd like to fix this too, and always refer call fuse_session pointers
> >> "se" (except where this name is already used for something else, but
> >> I'll just fix this up by hand afterwards). I tried the following patch:
> >>
> >> $ cat se-name.cocci
> >> @@
> >> idexpression struct fuse_session *p1;
> >> @@
> >> - f at p1
> >> + se
> >>
> >> but it resulted in these changes:
> >>
> >>  	struct fuse_session *f = req->se;
> >> -	struct cuse_data *cd = f->cuse_data;
> >> -	size_t bufsize = f->bufsize;
> >> +	struct cuse_data *cd = se->cuse_data;
> >> +	size_t bufsize = se->bufsize;
> >>
> >> So it seems to replace the variable where its used, but not where it's
> >> defined.
> >>
> >> Is there a way to catch the definitions too?
> >
> > Write separate rules for that.  You would need one case for a local
> > variable and one case fora parameter.  You can actually probably just drop
> > the rule you have currently.  I would imagine something like the
> > following:
> >
> > @@
> > symbol f, se; // avoid unneeded warnings from Coccinelle
> > @@
> >
> > struct fuse_session *
> > -f
> > +se
> >  ;
> > <...
> > -f
> > +se
> > ...>
>
> Could you explain how this works (in particular the effect of the angle
> brackets)? I also can't resist to point out that "symbol" is not
> included in the list of metavariable types from the tutorial slides :-).

<... P ...> is called a nest.  It means that the pattern can appear 0 or
more times.  You can put a transformation on the pattern.  It will happen
as many times as the thing appears.

The list on the slides is not exhaustive.  The list in the language
grammar should be exhaustive:
http://coccinelle.lip6.fr/docs/index.html

Symbol also just exists to quiet a warning message; it's not essential.

>
> > @@
> > identifier fn;
> > @@
> >
> > fn(...,struct fuse_session *f,...) { <...
> > -f
> > +se
> > ...> }
> >
> > I think that the symbol declaration has effect in the rest of the semantic
> > patch, and does not have to be repeated.  If you get warnings for the
> > second rule, just copy it down.
>
> Not sure what you mean with "copy it down".

Put the symbol declaration in both rules.

> I don't get Coccinelle
> warnings, but if I just use the two rules as you gave them, then
> it looks as if the second one isn't working:
>
> @@ -584,9 +584,9 @@ static struct fuse_ll_pipe *fuse_ll_get_
>
>  static void fuse_ll_clear_pipe(struct fuse_session *f)
>  {
> -	struct fuse_ll_pipe *llp = pthread_getspecific(f->pipe_key);
> +	struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
>  	if (llp) {
> -		pthread_setspecific(f->pipe_key, NULL);
> +		pthread_setspecific(se->pipe_key, NULL);
>  		fuse_ll_pipe_free(llp);
>  	}
>  }
>
>
> Is the problem that "...," does not match nothing, i.e. *f must not be
> the first argument of the function?

It should match nothing.  What version of Coccinelle do you have?

julia

>
> Best,
> -Nikolaus
>
> --
> GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
> Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
>              ?Time flies like an arrow, fruit flies like a Banana.?
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-08 20:45               ` Nikolaus Rath
@ 2016-10-08 21:23                 ` Julia Lawall
  2016-10-09  6:32                 ` SF Markus Elfring
  1 sibling, 0 replies; 46+ messages in thread
From: Julia Lawall @ 2016-10-08 21:23 UTC (permalink / raw)
  To: cocci

> > The name is illustrated in Advanced SmPL:
> > http://coccinelle.lip6.fr/papers/cocciwk4_talk2.pdf
>
> Call me stupid, but I just went through it again and I still don't see
> it. There are lots of examples with "@ ..stuff..@" (the first on slide
> 4), but as far as I can tell it never explains what this means.

OK, perhaps it is mentioned in the video:
http://faultlinux.lip6.fr/videos/workshop_videos_2011/Julia_Lawall_introduction_part2.f4v

>
> Actually, the frequent occurence of @script:python@ makes me think that
> this actually has semantic signficance and is much more than a label
> that I can choose for my own convenience...?

script:python indicates that the rule has python code rather than pattern
matching.  The name of a rule that you can choose freely should not
contain :

>
>
> > A variety of metavariable types are listed in slide 11 of the Linux
> > oriented tutorial: http://coccinelle.lip6.fr/papers/tutorial.pdf
>
> Yes, I saw that. But I deliberately wrote "explained" rather than just
> "listed" :-).

In the video, perhaps...

The following paper is quite old, but may also be helpful:

Tutorial paper: Semantic Patches, Documenting and Automating Collateral
Evolutions in Linux Device Drivers
Yoann Padioleau, Julia L. Lawall, and Gilles Muller
Ottawa Linux Symposium (OLS 2007), June 2007.

julia

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-08 20:45               ` Nikolaus Rath
  2016-10-08 21:23                 ` Julia Lawall
@ 2016-10-09  6:32                 ` SF Markus Elfring
  1 sibling, 0 replies; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-09  6:32 UTC (permalink / raw)
  To: cocci

>> The name is illustrated in Advanced SmPL:
>> http://coccinelle.lip6.fr/papers/cocciwk4_talk2.pdf
> 
> Call me stupid, but I just went through it again and I still don't see
> it. There are lots of examples with "@ ..stuff..@" (the first on slide
> 4), but as far as I can tell it never explains what this means.

How do you find information from a corresponding syntax description
for the semantic patch language?

Metavariables for transformations
http://coccinelle.lip6.fr/docs/main_grammar002.html


> Actually, the frequent occurence of @script:python@ makes me think that
> this actually has semantic signficance and is much more than a label
> that I can choose for my own convenience...?

Did you read another published document already?

Metavariables for scripts
http://coccinelle.lip6.fr/docs/main_grammar003.html

Regards,
Markus

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-08 20:28                           ` Nikolaus Rath
@ 2016-10-09  7:49                             ` SF Markus Elfring
  2016-10-09 20:38                               ` Nikolaus Rath
  0 siblings, 1 reply; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-09  7:49 UTC (permalink / raw)
  To: cocci

>>> Someone who has to read so much text and in the end has no information
>>> about the question he was asking will not likely get a good impression
>>> about the software he is trying to use.
>>
>> A beginner should usually read some text for the desired learning experience.
>> Can it be that you worry a bit too much about the potential for
>> bad impressions around your software?
> 
> Sorry to be the bringer of bad news, but Julia is spot on.

Thanks for your interesting feedback.

It seems to indicate also special details about your learning approach.


> The only effect your emails had on me was a big "WTF!?".

All of them (including the provided small SmPL script examples on 2016-10-05)?


Do you care for the consequences around the usage of embedded (programming)
languages within the semantic patch language as "a host"?
Can such a distinction be useful also for you?


> Had Julia not responded to my messages at almost the same time,

Here software support is very nice, isn't it?


> I would have left this list and Coccinelle for good.

I wonder that you would really run away so quickly just because
a few alternative description approaches became a bit longer.


>> Would you like to start another marketing project?
> 
> What's the point of all these random questions that you bring up in
> response to every sentence?

Did you inspect any items from the GitHub issue tracker?


> Do you think they are helpful?

I hope so.


>> I find that this mailing list gets only low message traffic so far.
> 
> Do you think others share this impression?

Yes. - I guess so. (I do not know concrete numbers for my view.)


> Do you think this is a good thing or a bad thing?

It might be easier to get started than in other areas you could get
involved in depending on your desire.

I hope that the varying topic mixture is interesting enough as another
valuable information source.


> How do you think will this situation evolve?

I imagine that the Coccinelle software will be improved in various directions.
I hope that the attractiveness of the provided tools will increase accordingly.
Will such an evolution mean more users with a higher message exchange rate
at various places?


>> So I would imagine that most well-intended discussion contributions could
>> be useful. Is the mixture of presented topics reasonable?
> 
> What do you mean with discussion contributions?

Did I (and the other contributors) publish any messages on this mailing list
before that could fit to your way of looking for helpful information already?


> Do you think that asking if the topic is reasonable is equivalent to asking
> if the specific contributions are reasonable?

No. - Would you like to discuss this aspect any further?


>> We came along different views around the usage of "expressions"
>> in previous discussions, didn't we?
> 
> Whom do you mean with "we"?

I guess that it could be primarily interpreted as Julia and me.


> Is it important in this context?

I find the software development history somewhat relevant also in this use case.


>> You repeated the explanation "An expression is something that has a value."
>> which is reasonable to some degree. I would like to know then:
>> Which "value" is provided by the software construct "idexpression"
>> in the semantic patch language?
> 
> Do you think you will be able to find out the answer to this question?

I could get some information from reading OCaml source code in principle.
But I would prefer an other clarification approach.


> How could we best assist you in that?

Which possibilities have you got in mind at the moment?
Are you really interested in improving your "assistance" in significant ways?

Regards,
Markus

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-09  7:49                             ` SF Markus Elfring
@ 2016-10-09 20:38                               ` Nikolaus Rath
  2016-10-10  6:48                                 ` SF Markus Elfring
  0 siblings, 1 reply; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-09 20:38 UTC (permalink / raw)
  To: cocci

On Oct 09 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>> The only effect your emails had on me was a big "WTF!?".
>
> All of them (including the provided small SmPL script examples on
> 2016-10-05)?

You wrote three emails on that day. I assume you mean this one?

,----
| > 2. ..and how would I go about if instead of the type, I want to replace
| >    a variable name? (my_type *ptr --> my_type *pointer).
| 
| Would you like to try another small SmPL script out like the following?
| 
| 
| @name_replacement@
| @@
|  my_type *
| -ptr
| +pointer
|  ;
| 
| 
| How will your software development experiments evolve for the desired
| application of the semantic patch language?
`----

I'm afraid the answer is yes. Even though the snippet was relevant, its
presentation triggered the same WTF effect.


>>> Would you like to start another marketing project?
>> 
>> What's the point of all these random questions that you bring up in
>> response to every sentence?
>
> Did you inspect any items from the GitHub issue tracker?
[...]

Well, I tried to make a point here., but it quite obviously failed
utterly.


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-08 21:21             ` Julia Lawall
@ 2016-10-09 20:45               ` Nikolaus Rath
  2016-10-10  4:49                 ` Julia Lawall
  2016-10-10  4:54                 ` Julia Lawall
  0 siblings, 2 replies; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-09 20:45 UTC (permalink / raw)
  To: cocci

On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> > Write separate rules for that.  You would need one case for a local
>> > variable and one case fora parameter.  You can actually probably just drop
>> > the rule you have currently.  I would imagine something like the
>> > following:
>> >
>> > @@
>> > symbol f, se; // avoid unneeded warnings from Coccinelle
>> > @@
>> >
>> > struct fuse_session *
>> > -f
>> > +se
>> >  ;
>> > <...
>> > -f
>> > +se
>> > ...>
>> > @@
>> > identifier fn;
>> > @@
>> >
>> > fn(...,struct fuse_session *f,...) { <...
>> > -f
>> > +se
>> > ...> }
>> >
>> > I think that the symbol declaration has effect in the rest of the semantic
>> > patch, and does not have to be repeated.  If you get warnings for the
>> > second rule, just copy it down.
>>
>> I don't get Coccinelle warnings, but if I just use the two rules as
>> you gave them, then it looks as if the second one isn't working:
>>
>> @@ -584,9 +584,9 @@ static struct fuse_ll_pipe *fuse_ll_get_
>>
>>  static void fuse_ll_clear_pipe(struct fuse_session *f)
>>  {
>> -	struct fuse_ll_pipe *llp = pthread_getspecific(f->pipe_key);
>> +	struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
>>  	if (llp) {
>> -		pthread_setspecific(f->pipe_key, NULL);
>> +		pthread_setspecific(se->pipe_key, NULL);
>>  		fuse_ll_pipe_free(llp);
>>  	}
>>  }
>>
>>
>> Is the problem that "...," does not match nothing, i.e. *f must not be
>> the first argument of the function?
>
> It should match nothing.  What version of Coccinelle do you have?

I used 1.0.0-rc22 (from Debian stable). However, I just downloaded the
pre-compiled version from http://coccinelle.lip6.fr/download.php and it
gives the same result.

In case you want to try yourself: the sources that I'm running this on
are available at https://github.com/libfuse/libfuse.


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-09 20:45               ` Nikolaus Rath
@ 2016-10-10  4:49                 ` Julia Lawall
  2016-10-10  4:54                 ` Julia Lawall
  1 sibling, 0 replies; 46+ messages in thread
From: Julia Lawall @ 2016-10-10  4:49 UTC (permalink / raw)
  To: cocci



On Sun, 9 Oct 2016, Nikolaus Rath wrote:

> On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> > Write separate rules for that.  You would need one case for a local
> >> > variable and one case fora parameter.  You can actually probably just drop
> >> > the rule you have currently.  I would imagine something like the
> >> > following:
> >> >
> >> > @@
> >> > symbol f, se; // avoid unneeded warnings from Coccinelle
> >> > @@
> >> >
> >> > struct fuse_session *
> >> > -f
> >> > +se
> >> >  ;
> >> > <...
> >> > -f
> >> > +se
> >> > ...>
> >> > @@
> >> > identifier fn;
> >> > @@
> >> >
> >> > fn(...,struct fuse_session *f,...) { <...
> >> > -f
> >> > +se
> >> > ...> }
> >> >
> >> > I think that the symbol declaration has effect in the rest of the semantic
> >> > patch, and does not have to be repeated.  If you get warnings for the
> >> > second rule, just copy it down.
> >>
> >> I don't get Coccinelle warnings, but if I just use the two rules as
> >> you gave them, then it looks as if the second one isn't working:
> >>
> >> @@ -584,9 +584,9 @@ static struct fuse_ll_pipe *fuse_ll_get_
> >>
> >>  static void fuse_ll_clear_pipe(struct fuse_session *f)
> >>  {
> >> -	struct fuse_ll_pipe *llp = pthread_getspecific(f->pipe_key);
> >> +	struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
> >>  	if (llp) {
> >> -		pthread_setspecific(f->pipe_key, NULL);
> >> +		pthread_setspecific(se->pipe_key, NULL);
> >>  		fuse_ll_pipe_free(llp);
> >>  	}
> >>  }
> >>
> >>
> >> Is the problem that "...," does not match nothing, i.e. *f must not be
> >> the first argument of the function?
> >
> > It should match nothing.  What version of Coccinelle do you have?
>
> I used 1.0.0-rc22 (from Debian stable). However, I just downloaded the
> pre-compiled version from http://coccinelle.lip6.fr/download.php and it
> gives the same result.

OK, any rc is quite old.

> In case you want to try yourself: the sources that I'm running this on
> are available at https://github.com/libfuse/libfuse.

Thanks, I'll check on it.

julia

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-09 20:45               ` Nikolaus Rath
  2016-10-10  4:49                 ` Julia Lawall
@ 2016-10-10  4:54                 ` Julia Lawall
  2016-10-10 15:56                   ` Nikolaus Rath
  1 sibling, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-10  4:54 UTC (permalink / raw)
  To: cocci



On Sun, 9 Oct 2016, Nikolaus Rath wrote:

> On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> > Write separate rules for that.  You would need one case for a local
> >> > variable and one case fora parameter.  You can actually probably just drop
> >> > the rule you have currently.  I would imagine something like the
> >> > following:
> >> >
> >> > @@
> >> > symbol f, se; // avoid unneeded warnings from Coccinelle
> >> > @@
> >> >
> >> > struct fuse_session *
> >> > -f
> >> > +se
> >> >  ;
> >> > <...
> >> > -f
> >> > +se
> >> > ...>
> >> > @@
> >> > identifier fn;
> >> > @@
> >> >
> >> > fn(...,struct fuse_session *f,...) { <...

Oops, the first line should be:

fn(...,struct fuse_session *
-f
+se
  ,...) { <...

The rule works fine even when f is the first argument.

julia

> >> > -f
> >> > +se
> >> > ...> }
> >> >
> >> > I think that the symbol declaration has effect in the rest of the semantic
> >> > patch, and does not have to be repeated.  If you get warnings for the
> >> > second rule, just copy it down.
> >>
> >> I don't get Coccinelle warnings, but if I just use the two rules as
> >> you gave them, then it looks as if the second one isn't working:
> >>
> >> @@ -584,9 +584,9 @@ static struct fuse_ll_pipe *fuse_ll_get_
> >>
> >>  static void fuse_ll_clear_pipe(struct fuse_session *f)
> >>  {
> >> -	struct fuse_ll_pipe *llp = pthread_getspecific(f->pipe_key);
> >> +	struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
> >>  	if (llp) {
> >> -		pthread_setspecific(f->pipe_key, NULL);
> >> +		pthread_setspecific(se->pipe_key, NULL);
> >>  		fuse_ll_pipe_free(llp);
> >>  	}
> >>  }
> >>
> >>
> >> Is the problem that "...," does not match nothing, i.e. *f must not be
> >> the first argument of the function?
> >
> > It should match nothing.  What version of Coccinelle do you have?
>
> I used 1.0.0-rc22 (from Debian stable). However, I just downloaded the
> pre-compiled version from http://coccinelle.lip6.fr/download.php and it
> gives the same result.
>
> In case you want to try yourself: the sources that I'm running this on
> are available at https://github.com/libfuse/libfuse.
>
>
> Best,
> -Nikolaus
>
> --
> GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
> Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
>              ?Time flies like an arrow, fruit flies like a Banana.?
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-09 20:38                               ` Nikolaus Rath
@ 2016-10-10  6:48                                 ` SF Markus Elfring
  2016-10-10  6:50                                   ` Julia Lawall
  0 siblings, 1 reply; 46+ messages in thread
From: SF Markus Elfring @ 2016-10-10  6:48 UTC (permalink / raw)
  To: cocci

>>> The only effect your emails had on me was a big "WTF!?".
>>
>> All of them (including the provided small SmPL script examples on
>> 2016-10-05)?
> 
> You wrote three emails on that day. I assume you mean this one?

There are further possibilities to improve your learning experience around
the replacement of data types and variable names, aren't there?


> ,----
> | > 2. ..and how would I go about if instead of the type, I want to replace
> | >    a variable name? (my_type *ptr --> my_type *pointer).
> | 
> | Would you like to try another small SmPL script out like the following?
> | 
> | 
> | @name_replacement@
> | @@
> |  my_type *
> | -ptr
> | +pointer
> |  ;
> | 
> | 
> | How will your software development experiments evolve for the desired
> | application of the semantic patch language?
> `----
> 
> I'm afraid the answer is yes.

Interesting ?


> Even though the snippet was relevant,

Nice. - Thanks for this kind of feedback.


> its presentation triggered the same WTF effect.

Are you really at the beginning of a learning process where almost every
new information can make you upset anyhow?

* How would this fit to your academic education?

* Did you start reading the Coccinelle manual?


>>> What's the point of all these random questions that you bring up in
>>> response to every sentence?
>>
>> Did you inspect any items from the GitHub issue tracker?
> [...]
> 
> Well, I tried to make a point here., but it quite obviously failed utterly.

I find that a constructive discussion consists of several questions and some
corresponding answers, doesn't it?

I am wondering about the learning style that you seem to present here
in comparison to some information which was published in your blog.
Are there any further challenges to clarify around a term like "mental capacity"?

Can any additional techniques or tools help to avoid unwanted
communication difficulties so that another software development "fusion"
would be achievable?

Regards,
Markus

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

* [Cocci] Usage of "expressions" and "identifiers" with SmPL
  2016-10-10  6:48                                 ` SF Markus Elfring
@ 2016-10-10  6:50                                   ` Julia Lawall
  0 siblings, 0 replies; 46+ messages in thread
From: Julia Lawall @ 2016-10-10  6:50 UTC (permalink / raw)
  To: cocci

OK, Markus, out you go...

julia

On Mon, 10 Oct 2016, SF Markus Elfring wrote:

> >>> The only effect your emails had on me was a big "WTF!?".
> >>
> >> All of them (including the provided small SmPL script examples on
> >> 2016-10-05)?
> >
> > You wrote three emails on that day. I assume you mean this one?
>
> There are further possibilities to improve your learning experience around
> the replacement of data types and variable names, aren't there?
>
>
> > ,----
> > | > 2. ..and how would I go about if instead of the type, I want to replace
> > | >    a variable name? (my_type *ptr --> my_type *pointer).
> > |
> > | Would you like to try another small SmPL script out like the following?
> > |
> > |
> > | @name_replacement@
> > | @@
> > |  my_type *
> > | -ptr
> > | +pointer
> > |  ;
> > |
> > |
> > | How will your software development experiments evolve for the desired
> > | application of the semantic patch language?
> > `----
> >
> > I'm afraid the answer is yes.
>
> Interesting ?
>
>
> > Even though the snippet was relevant,
>
> Nice. - Thanks for this kind of feedback.
>
>
> > its presentation triggered the same WTF effect.
>
> Are you really at the beginning of a learning process where almost every
> new information can make you upset anyhow?
>
> * How would this fit to your academic education?
>
> * Did you start reading the Coccinelle manual?
>
>
> >>> What's the point of all these random questions that you bring up in
> >>> response to every sentence?
> >>
> >> Did you inspect any items from the GitHub issue tracker?
> > [...]
> >
> > Well, I tried to make a point here., but it quite obviously failed utterly.
>
> I find that a constructive discussion consists of several questions and some
> corresponding answers, doesn't it?
>
> I am wondering about the learning style that you seem to present here
> in comparison to some information which was published in your blog.
> Are there any further challenges to clarify around a term like "mental capacity"?
>
> Can any additional techniques or tools help to avoid unwanted
> communication difficulties so that another software development "fusion"
> would be achievable?
>
> Regards,
> Markus
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-10  4:54                 ` Julia Lawall
@ 2016-10-10 15:56                   ` Nikolaus Rath
  2016-10-10 18:45                     ` Nikolaus Rath
  0 siblings, 1 reply; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-10 15:56 UTC (permalink / raw)
  To: cocci

On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Sun, 9 Oct 2016, Nikolaus Rath wrote:
>
>> On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> >> > Write separate rules for that.  You would need one case for a local
>> >> > variable and one case fora parameter.  You can actually probably just drop
>> >> > the rule you have currently.  I would imagine something like the
>> >> > following:
>> >> >
>> >> > @@
>> >> > symbol f, se; // avoid unneeded warnings from Coccinelle
>> >> > @@
>> >> >
>> >> > struct fuse_session *
>> >> > -f
>> >> > +se
>> >> >  ;
>> >> > <...
>> >> > -f
>> >> > +se
>> >> > ...>
>> >> > @@
>> >> > identifier fn;
>> >> > @@
>> >> >
>> >> > fn(...,struct fuse_session *f,...) { <...
>
> Oops, the first line should be:
>
> fn(...,struct fuse_session *
> -f
> +se
>   ,...) { <...
>
> The rule works fine even when f is the first argument.

Ouch, I guess I could have caught that too. Works like a charm now!


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-10 15:56                   ` Nikolaus Rath
@ 2016-10-10 18:45                     ` Nikolaus Rath
  2016-10-10 19:45                       ` Julia Lawall
  0 siblings, 1 reply; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-10 18:45 UTC (permalink / raw)
  To: cocci

On Oct 10 2016, Nikolaus Rath <Nikolaus@rath.org> wrote:
> On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> On Sun, 9 Oct 2016, Nikolaus Rath wrote:
>>
>>> On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>>> >> > Write separate rules for that.  You would need one case for a local
>>> >> > variable and one case fora parameter.  You can actually probably just drop
>>> >> > the rule you have currently.  I would imagine something like the
>>> >> > following:
>>> >> >
>>> >> > @@
>>> >> > symbol f, se; // avoid unneeded warnings from Coccinelle
>>> >> > @@
>>> >> >
>>> >> > struct fuse_session *
>>> >> > -f
>>> >> > +se
>>> >> >  ;
>>> >> > <...
>>> >> > -f
>>> >> > +se
>>> >> > ...>
>>> >> > @@
>>> >> > identifier fn;
>>> >> > @@
>>> >> >
>>> >> > fn(...,struct fuse_session *f,...) { <...
>>
>> Oops, the first line should be:
>>
>> fn(...,struct fuse_session *
>> -f
>> +se
>>   ,...) { <...
>>
>> The rule works fine even when f is the first argument.
>
> Ouch, I guess I could have caught that too. Works like a charm now!

I claimed success too early. There are still the following cases left:


static void do_destroy(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
	struct fuse_session *f = req->se;
[....]

I tried to adapt the rules myself as follows:

@@
symbol f, se;
@@
struct fuse_session *
-f
+se
;
<...
-f
+se
...>

@@
symbol f, se;
expression expr;
@@
struct fuse_session *
-f
+se
= expr;
<...
-f
+se
...>


@@
identifier fn;
@@
fn(...,struct fuse_session *
-f
+se
,...) { <...
-f
+se
...> }


But this gives an error:


Fatal error: exception Failure("meta: parse error: 
 = File "se-rename.cocci", line 14, column 7,  charpos = 79
    around = 'f', whole content = symbol f, se;
")


What am I doing wrong?

Thanks!
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-10 18:45                     ` Nikolaus Rath
@ 2016-10-10 19:45                       ` Julia Lawall
  2016-10-10 21:27                         ` Nikolaus Rath
  0 siblings, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-10 19:45 UTC (permalink / raw)
  To: cocci



On Mon, 10 Oct 2016, Nikolaus Rath wrote:

> On Oct 10 2016, Nikolaus Rath <Nikolaus@rath.org> wrote:
> > On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> On Sun, 9 Oct 2016, Nikolaus Rath wrote:
> >>
> >>> On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >>> >> > Write separate rules for that.  You would need one case for a local
> >>> >> > variable and one case fora parameter.  You can actually probably just drop
> >>> >> > the rule you have currently.  I would imagine something like the
> >>> >> > following:
> >>> >> >
> >>> >> > @@
> >>> >> > symbol f, se; // avoid unneeded warnings from Coccinelle
> >>> >> > @@
> >>> >> >
> >>> >> > struct fuse_session *
> >>> >> > -f
> >>> >> > +se
> >>> >> >  ;
> >>> >> > <...
> >>> >> > -f
> >>> >> > +se
> >>> >> > ...>
> >>> >> > @@
> >>> >> > identifier fn;
> >>> >> > @@
> >>> >> >
> >>> >> > fn(...,struct fuse_session *f,...) { <...
> >>
> >> Oops, the first line should be:
> >>
> >> fn(...,struct fuse_session *
> >> -f
> >> +se
> >>   ,...) { <...
> >>
> >> The rule works fine even when f is the first argument.
> >
> > Ouch, I guess I could have caught that too. Works like a charm now!
>
> I claimed success too early. There are still the following cases left:
>
>
> static void do_destroy(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
> {
> 	struct fuse_session *f = req->se;
> [....]
>
> I tried to adapt the rules myself as follows:
>
> @@
> symbol f, se;
> @@
> struct fuse_session *
> -f
> +se
> ;
> <...
> -f
> +se
> ...>
>
> @@
> symbol f, se;
> expression expr;
> @@
> struct fuse_session *
> -f
> +se
> = expr;
> <...
> -f
> +se
> ...>
>
>
> @@
> identifier fn;
> @@
> fn(...,struct fuse_session *
> -f
> +se
> ,...) { <...
> -f
> +se
> ...> }
>
>
> But this gives an error:
>
>
> Fatal error: exception Failure("meta: parse error:
>  = File "se-rename.cocci", line 14, column 7,  charpos = 79
>     around = 'f', whole content = symbol f, se;
> ")
>
>
> What am I doing wrong?

What version of Coccinelle are you using?  Before 1.0.6, it was not
possible to declare something to be a symbol more than once.  In any case,
once it is declared as a symbol, it is always a symbol.

julia

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-10 19:45                       ` Julia Lawall
@ 2016-10-10 21:27                         ` Nikolaus Rath
  2016-10-10 21:33                           ` Julia Lawall
  0 siblings, 1 reply; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-10 21:27 UTC (permalink / raw)
  To: cocci

On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> I claimed success too early. There are still the following cases left:
>>
>>
>> static void do_destroy(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
>> {
>> 	struct fuse_session *f = req->se;
>> [....]
>>
>> I tried to adapt the rules myself as follows:
>>
>> @@
>> symbol f, se;
>> @@
>> struct fuse_session *
>> -f
>> +se
>> ;
>> <...
>> -f
>> +se
>> ...>
>>
>> @@
>> symbol f, se;
>> expression expr;
>> @@
>> struct fuse_session *
>> -f
>> +se
>> = expr;
>> <...
>> -f
>> +se
>> ...>
>>
>>
>> @@
>> identifier fn;
>> @@
>> fn(...,struct fuse_session *
>> -f
>> +se
>> ,...) { <...
>> -f
>> +se
>> ...> }
>>
>>
>> But this gives an error:
>>
>>
>> Fatal error: exception Failure("meta: parse error:
>>  = File "se-rename.cocci", line 14, column 7,  charpos = 79
>>     around = 'f', whole content = symbol f, se;
>> ")
>>
>>
>> What am I doing wrong?
>
> What version of Coccinelle are you using?  Before 1.0.6, it was not
> possible to declare something to be a symbol more than once.  In any case,
> once it is declared as a symbol, it is always a symbol.

Ok, we're getting there. I've removed the second 'symbol' line, and
(permanently) updated to 1.0.6. However, now it seems to simply run
forever:

$ ../coccinelle-1.0.6/spatch.opt --sp-file ~/in-progress/libfuse/se-rename.cocci --in-place lib/ include/ test/ example/ util/
init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
warning: patch output can only be created when only one
directory is specified or when the -patch flag is used
HANDLING: lib/fuse.c
(ONCE) Expected tokens fuse_session f
Skipping:lib/fuse_opt.c
HANDLING: lib/helper.c
Skipping:lib/mount_bsd.c
Skipping:lib/fuse_loop_mt.c
Skipping:lib/fuse_loop.c
HANDLING: lib/cuse_lowlevel.c
diff = 
[...]
HANDLING: lib/fuse_lowlevel.c

At this point it has been hanging for about 15 minutes now, steady
eating CPU time. 

Is it supposed to take that long? The fuse_lowlevel.c file is 74k with
2465 lines of code.

Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-10 21:27                         ` Nikolaus Rath
@ 2016-10-10 21:33                           ` Julia Lawall
  2016-10-10 23:00                             ` Nikolaus Rath
  0 siblings, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-10 21:33 UTC (permalink / raw)
  To: cocci



On Mon, 10 Oct 2016, Nikolaus Rath wrote:

> On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> I claimed success too early. There are still the following cases left:
> >>
> >>
> >> static void do_destroy(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
> >> {
> >> 	struct fuse_session *f = req->se;
> >> [....]
> >>
> >> I tried to adapt the rules myself as follows:
> >>
> >> @@
> >> symbol f, se;
> >> @@
> >> struct fuse_session *
> >> -f
> >> +se
> >> ;
> >> <...
> >> -f
> >> +se
> >> ...>
> >>
> >> @@
> >> symbol f, se;
> >> expression expr;
> >> @@
> >> struct fuse_session *
> >> -f
> >> +se
> >> = expr;
> >> <...
> >> -f
> >> +se
> >> ...>
> >>
> >>
> >> @@
> >> identifier fn;
> >> @@
> >> fn(...,struct fuse_session *
> >> -f
> >> +se
> >> ,...) { <...
> >> -f
> >> +se
> >> ...> }
> >>
> >>
> >> But this gives an error:
> >>
> >>
> >> Fatal error: exception Failure("meta: parse error:
> >>  = File "se-rename.cocci", line 14, column 7,  charpos = 79
> >>     around = 'f', whole content = symbol f, se;
> >> ")
> >>
> >>
> >> What am I doing wrong?
> >
> > What version of Coccinelle are you using?  Before 1.0.6, it was not
> > possible to declare something to be a symbol more than once.  In any case,
> > once it is declared as a symbol, it is always a symbol.
>
> Ok, we're getting there. I've removed the second 'symbol' line, and
> (permanently) updated to 1.0.6. However, now it seems to simply run
> forever:
>
> $ ../coccinelle-1.0.6/spatch.opt --sp-file ~/in-progress/libfuse/se-rename.cocci --in-place lib/ include/ test/ example/ util/
> init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
> warning: patch output can only be created when only one
> directory is specified or when the -patch flag is used
> HANDLING: lib/fuse.c
> (ONCE) Expected tokens fuse_session f
> Skipping:lib/fuse_opt.c
> HANDLING: lib/helper.c
> Skipping:lib/mount_bsd.c
> Skipping:lib/fuse_loop_mt.c
> Skipping:lib/fuse_loop.c
> HANDLING: lib/cuse_lowlevel.c
> diff =
> [...]
> HANDLING: lib/fuse_lowlevel.c
>
> At this point it has been hanging for about 15 minutes now, steady
> eating CPU time.
>
> Is it supposed to take that long? The fuse_lowlevel.c file is 74k with
> 2465 lines of code.

You can use --show-trying to see what function it is getting stuck on.  If
the function has a lot of ifs and loops, it may indeed take a long
time.  ... follows possible paths in the execution graph and a sequence of
ifs makes the number of paths grow exponentially.

A solution is to add a timeout, eg --timeout 120 (120 seconds).  You will
need to check a file on which there is a timeout manually.

Tracing paths around loops is not really relevant in your case, so you can
also safely use the option --no-loops, which will avoid taking the back
edges.

julia

>
> Best,
> -Nikolaus
>
> --
> GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
> Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
>
>              ?Time flies like an arrow, fruit flies like a Banana.?
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-10 21:33                           ` Julia Lawall
@ 2016-10-10 23:00                             ` Nikolaus Rath
  2016-10-11  6:51                               ` Julia Lawall
  0 siblings, 1 reply; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-10 23:00 UTC (permalink / raw)
  To: cocci

On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> Ok, we're getting there. I've removed the second 'symbol' line, and
>> (permanently) updated to 1.0.6. However, now it seems to simply run
>> forever:
>>
>> $ ../coccinelle-1.0.6/spatch.opt --sp-file
>> ~/in-progress/libfuse/se-rename.cocci --in-place lib/ include/ test/
>> example/ util/
>> init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
>> warning: patch output can only be created when only one
>> directory is specified or when the -patch flag is used
>> HANDLING: lib/fuse.c
>> (ONCE) Expected tokens fuse_session f
>> Skipping:lib/fuse_opt.c
>> HANDLING: lib/helper.c
>> Skipping:lib/mount_bsd.c
>> Skipping:lib/fuse_loop_mt.c
>> Skipping:lib/fuse_loop.c
>> HANDLING: lib/cuse_lowlevel.c
>> diff =
>> [...]
>> HANDLING: lib/fuse_lowlevel.c
>>
>> At this point it has been hanging for about 15 minutes now, steady
>> eating CPU time.
>>
>> Is it supposed to take that long? The fuse_lowlevel.c file is 74k with
>> 2465 lines of code.
>
> You can use --show-trying to see what function it is getting stuck on.  If
> the function has a lot of ifs and loops, it may indeed take a long
> time.  ... follows possible paths in the execution graph and a sequence of
> ifs makes the number of paths grow exponentially.
>
> A solution is to add a timeout, eg --timeout 120 (120 seconds).  You will
> need to check a file on which there is a timeout manually.
>
> Tracing paths around loops is not really relevant in your case, so you can
> also safely use the option --no-loops, which will avoid taking the back
> edges.
 
I tried doing both, but it still gets stuck:

init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
HANDLING: lib/fuse_lowlevel.c
-----------------------------------------------------------------------
rule starting on line 1 = 
-----------------------------------------------------------------------
[...]
-----------------------------------------------------------------------
rule starting on line 13 = 
-----------------------------------------------------------------------
[...]
   trying function: do_init: fuse_lowlevel.c:1812


The do_init() function doesn't seem all that terrible to me though:
https://github.com/libfuse/libfuse/blob/58273972f0b20/lib/fuse_lowlevel.c#L1812

Best,
-Nikolaus
-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-10 23:00                             ` Nikolaus Rath
@ 2016-10-11  6:51                               ` Julia Lawall
  2016-10-12 15:08                                 ` Nikolaus Rath
  0 siblings, 1 reply; 46+ messages in thread
From: Julia Lawall @ 2016-10-11  6:51 UTC (permalink / raw)
  To: cocci



On Mon, 10 Oct 2016, Nikolaus Rath wrote:

> On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> Ok, we're getting there. I've removed the second 'symbol' line, and
> >> (permanently) updated to 1.0.6. However, now it seems to simply run
> >> forever:
> >>
> >> $ ../coccinelle-1.0.6/spatch.opt --sp-file
> >> ~/in-progress/libfuse/se-rename.cocci --in-place lib/ include/ test/
> >> example/ util/
> >> init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
> >> warning: patch output can only be created when only one
> >> directory is specified or when the -patch flag is used
> >> HANDLING: lib/fuse.c
> >> (ONCE) Expected tokens fuse_session f
> >> Skipping:lib/fuse_opt.c
> >> HANDLING: lib/helper.c
> >> Skipping:lib/mount_bsd.c
> >> Skipping:lib/fuse_loop_mt.c
> >> Skipping:lib/fuse_loop.c
> >> HANDLING: lib/cuse_lowlevel.c
> >> diff =
> >> [...]
> >> HANDLING: lib/fuse_lowlevel.c
> >>
> >> At this point it has been hanging for about 15 minutes now, steady
> >> eating CPU time.
> >>
> >> Is it supposed to take that long? The fuse_lowlevel.c file is 74k with
> >> 2465 lines of code.
> >
> > You can use --show-trying to see what function it is getting stuck on.  If
> > the function has a lot of ifs and loops, it may indeed take a long
> > time.  ... follows possible paths in the execution graph and a sequence of
> > ifs makes the number of paths grow exponentially.
> >
> > A solution is to add a timeout, eg --timeout 120 (120 seconds).  You will
> > need to check a file on which there is a timeout manually.
> >
> > Tracing paths around loops is not really relevant in your case, so you can
> > also safely use the option --no-loops, which will avoid taking the back
> > edges.
>
> I tried doing both, but it still gets stuck:
>
> init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
> HANDLING: lib/fuse_lowlevel.c
> -----------------------------------------------------------------------
> rule starting on line 1 =
> -----------------------------------------------------------------------
> [...]
> -----------------------------------------------------------------------
> rule starting on line 13 =
> -----------------------------------------------------------------------
> [...]
>    trying function: do_init: fuse_lowlevel.c:1812
>
>
> The do_init() function doesn't seem all that terrible to me though:
> https://github.com/libfuse/libfuse/blob/58273972f0b20/lib/fuse_lowlevel.c#L1812

Yes it does.  Look at lines 1852-1877.  There are 2^13 execution paths
there, and there is another such stack of ifs later in the function.

So you did add a timeout and it is still getting stuck?  Try a very short
timeout just to see what happens.

julia

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-11  6:51                               ` Julia Lawall
@ 2016-10-12 15:08                                 ` Nikolaus Rath
  2016-10-12 20:37                                   ` Julia Lawall
  0 siblings, 1 reply; 46+ messages in thread
From: Nikolaus Rath @ 2016-10-12 15:08 UTC (permalink / raw)
  To: cocci

On Oct 11 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Mon, 10 Oct 2016, Nikolaus Rath wrote:
>
>> On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> >> Ok, we're getting there. I've removed the second 'symbol' line, and
>> >> (permanently) updated to 1.0.6. However, now it seems to simply run
>> >> forever:
>> >>
>> >> $ ../coccinelle-1.0.6/spatch.opt --sp-file
>> >> ~/in-progress/libfuse/se-rename.cocci --in-place lib/ include/ test/
>> >> example/ util/
>> >> init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
>> >> warning: patch output can only be created when only one
>> >> directory is specified or when the -patch flag is used
>> >> HANDLING: lib/fuse.c
>> >> (ONCE) Expected tokens fuse_session f
>> >> Skipping:lib/fuse_opt.c
>> >> HANDLING: lib/helper.c
>> >> Skipping:lib/mount_bsd.c
>> >> Skipping:lib/fuse_loop_mt.c
>> >> Skipping:lib/fuse_loop.c
>> >> HANDLING: lib/cuse_lowlevel.c
>> >> diff =
>> >> [...]
>> >> HANDLING: lib/fuse_lowlevel.c
>> >>
>> >> At this point it has been hanging for about 15 minutes now, steady
>> >> eating CPU time.
>> >>
>> >> Is it supposed to take that long? The fuse_lowlevel.c file is 74k with
>> >> 2465 lines of code.
>> >
>> > You can use --show-trying to see what function it is getting stuck on.  If
>> > the function has a lot of ifs and loops, it may indeed take a long
>> > time.  ... follows possible paths in the execution graph and a sequence of
>> > ifs makes the number of paths grow exponentially.
>> >
>> > A solution is to add a timeout, eg --timeout 120 (120 seconds).  You will
>> > need to check a file on which there is a timeout manually.
>> >
>> > Tracing paths around loops is not really relevant in your case, so you can
>> > also safely use the option --no-loops, which will avoid taking the back
>> > edges.
>>
>> I tried doing both, but it still gets stuck:
>>
>> init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
>> HANDLING: lib/fuse_lowlevel.c
>> -----------------------------------------------------------------------
>> rule starting on line 1 =
>> -----------------------------------------------------------------------
>> [...]
>> -----------------------------------------------------------------------
>> rule starting on line 13 =
>> -----------------------------------------------------------------------
>> [...]
>>    trying function: do_init: fuse_lowlevel.c:1812
>>
>>
>> The do_init() function doesn't seem all that terrible to me though:
>> https://github.com/libfuse/libfuse/blob/58273972f0b20/lib/fuse_lowlevel.c#L1812
>
> Yes it does.  Look at lines 1852-1877.  There are 2^13 execution paths
> there, and there is another such stack of ifs later in the function.
>
> So you did add a timeout and it is still getting stuck?  Try a very short
> timeout just to see what happens.

Sorry for the confusion. No, when I add the timeout then it aborts. But
I thought that with --no-loops it would not trace out all the different
paths and should complete more quickly.

Also, it seems that with --timeout it aborts completely (instead of just
going to the next function):

     trying function: do_fallocate: fuse_lowlevel.c:1798
     trying function: do_init: fuse_lowlevel.c:1812
timeout (we abort)
Fatal error: exception Common.Timeout

$

Is that intended?

Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             ?Time flies like an arrow, fruit flies like a Banana.?

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

* [Cocci] Replacing one (specific!) type with another
  2016-10-12 15:08                                 ` Nikolaus Rath
@ 2016-10-12 20:37                                   ` Julia Lawall
  0 siblings, 0 replies; 46+ messages in thread
From: Julia Lawall @ 2016-10-12 20:37 UTC (permalink / raw)
  To: cocci



On Wed, 12 Oct 2016, Nikolaus Rath wrote:

> On Oct 11 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> > On Mon, 10 Oct 2016, Nikolaus Rath wrote:
> >
> >> On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> >> Ok, we're getting there. I've removed the second 'symbol' line, and
> >> >> (permanently) updated to 1.0.6. However, now it seems to simply run
> >> >> forever:
> >> >>
> >> >> $ ../coccinelle-1.0.6/spatch.opt --sp-file
> >> >> ~/in-progress/libfuse/se-rename.cocci --in-place lib/ include/ test/
> >> >> example/ util/
> >> >> init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
> >> >> warning: patch output can only be created when only one
> >> >> directory is specified or when the -patch flag is used
> >> >> HANDLING: lib/fuse.c
> >> >> (ONCE) Expected tokens fuse_session f
> >> >> Skipping:lib/fuse_opt.c
> >> >> HANDLING: lib/helper.c
> >> >> Skipping:lib/mount_bsd.c
> >> >> Skipping:lib/fuse_loop_mt.c
> >> >> Skipping:lib/fuse_loop.c
> >> >> HANDLING: lib/cuse_lowlevel.c
> >> >> diff =
> >> >> [...]
> >> >> HANDLING: lib/fuse_lowlevel.c
> >> >>
> >> >> At this point it has been hanging for about 15 minutes now, steady
> >> >> eating CPU time.
> >> >>
> >> >> Is it supposed to take that long? The fuse_lowlevel.c file is 74k with
> >> >> 2465 lines of code.
> >> >
> >> > You can use --show-trying to see what function it is getting stuck on.  If
> >> > the function has a lot of ifs and loops, it may indeed take a long
> >> > time.  ... follows possible paths in the execution graph and a sequence of
> >> > ifs makes the number of paths grow exponentially.
> >> >
> >> > A solution is to add a timeout, eg --timeout 120 (120 seconds).  You will
> >> > need to check a file on which there is a timeout manually.
> >> >
> >> > Tracing paths around loops is not really relevant in your case, so you can
> >> > also safely use the option --no-loops, which will avoid taking the back
> >> > edges.
> >>
> >> I tried doing both, but it still gets stuck:
> >>
> >> init_defs_builtins: /home/nikratio/tmp/coccinelle-1.0.6/standard.h
> >> HANDLING: lib/fuse_lowlevel.c
> >> -----------------------------------------------------------------------
> >> rule starting on line 1 =
> >> -----------------------------------------------------------------------
> >> [...]
> >> -----------------------------------------------------------------------
> >> rule starting on line 13 =
> >> -----------------------------------------------------------------------
> >> [...]
> >>    trying function: do_init: fuse_lowlevel.c:1812
> >>
> >>
> >> The do_init() function doesn't seem all that terrible to me though:
> >> https://github.com/libfuse/libfuse/blob/58273972f0b20/lib/fuse_lowlevel.c#L1812
> >
> > Yes it does.  Look at lines 1852-1877.  There are 2^13 execution paths
> > there, and there is another such stack of ifs later in the function.
> >
> > So you did add a timeout and it is still getting stuck?  Try a very short
> > timeout just to see what happens.
>
> Sorry for the confusion. No, when I add the timeout then it aborts. But
> I thought that with --no-loops it would not trace out all the different
> paths and should complete more quickly.

--no-loops just eliminates the back edges of loops.  That is not your
problem, so it won't help.

> Also, it seems that with --timeout it aborts completely (instead of just
> going to the next function):
>
>      trying function: do_fallocate: fuse_lowlevel.c:1798
>      trying function: do_init: fuse_lowlevel.c:1812
> timeout (we abort)
> Fatal error: exception Common.Timeout
>
> $
>
> Is that intended?

Yes.  In general, there can be (both positive and negative) dependencies
between rules, and incompletely processing one function could lead to an
inconsistent state.  Coccinelle could perhaps analyze the dependencies in
the specific semantic patch at hand, and firgure out whether there could
be a problem, but for now it doesn't do that.

julia

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

end of thread, other threads:[~2016-10-12 20:37 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-05  3:27 [Cocci] Replacing one (specific!) type with another Nikolaus Rath
2016-10-05  5:45 ` Julia Lawall
2016-10-05 16:09   ` Nikolaus Rath
2016-10-05 16:39     ` Michael Stefaniuc
2016-10-05 17:21     ` [Cocci] Replacing one variable name " SF Markus Elfring
2016-10-05 22:34       ` Nikolaus Rath
2016-10-06  5:42         ` SF Markus Elfring
2016-10-06  5:56         ` Julia Lawall
2016-10-05 20:02     ` [Cocci] Replacing one (specific!) type " Julia Lawall
2016-10-05 22:38       ` Nikolaus Rath
2016-10-06  5:55         ` Julia Lawall
2016-10-08  3:16           ` Nikolaus Rath
2016-10-08  5:50             ` Julia Lawall
2016-10-08 20:45               ` Nikolaus Rath
2016-10-08 21:23                 ` Julia Lawall
2016-10-09  6:32                 ` SF Markus Elfring
2016-10-08  6:48             ` [Cocci] Usage of "expressions" and "identifiers" with SmPL SF Markus Elfring
2016-10-08  6:57               ` Julia Lawall
     [not found]               ` <alpine.DEB.2.10.1610080850470.7750@hadrien>
2016-10-08  7:49                 ` SF Markus Elfring
2016-10-08  7:56                   ` Julia Lawall
2016-10-08  8:26                     ` SF Markus Elfring
2016-10-08  8:38                       ` Julia Lawall
2016-10-08  9:25                         ` SF Markus Elfring
2016-10-08 20:28                           ` Nikolaus Rath
2016-10-09  7:49                             ` SF Markus Elfring
2016-10-09 20:38                               ` Nikolaus Rath
2016-10-10  6:48                                 ` SF Markus Elfring
2016-10-10  6:50                                   ` Julia Lawall
2016-10-06  6:30         ` [Cocci] Replacing one (specific!) type with another SF Markus Elfring
2016-10-08  4:22       ` Nikolaus Rath
2016-10-08  5:31         ` Julia Lawall
2016-10-08 20:52           ` Nikolaus Rath
2016-10-08 21:21             ` Julia Lawall
2016-10-09 20:45               ` Nikolaus Rath
2016-10-10  4:49                 ` Julia Lawall
2016-10-10  4:54                 ` Julia Lawall
2016-10-10 15:56                   ` Nikolaus Rath
2016-10-10 18:45                     ` Nikolaus Rath
2016-10-10 19:45                       ` Julia Lawall
2016-10-10 21:27                         ` Nikolaus Rath
2016-10-10 21:33                           ` Julia Lawall
2016-10-10 23:00                             ` Nikolaus Rath
2016-10-11  6:51                               ` Julia Lawall
2016-10-12 15:08                                 ` Nikolaus Rath
2016-10-12 20:37                                   ` Julia Lawall
2016-10-05  5:51 ` SF Markus Elfring

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.