Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] Replacing printf/format calls based on the data-type
@ 2019-11-28  2:11 Strace Labs
  2019-11-28  7:07 ` Julia Lawall
  2019-11-28  7:50 ` Markus Elfring
  0 siblings, 2 replies; 31+ messages in thread
From: Strace Labs @ 2019-11-28  2:11 UTC (permalink / raw)
  To: cocci

[-- Attachment #1.1: Type: text/plain, Size: 1485 bytes --]

Hi,

I am working on a semantic patch for replacing specific format string token
based on the used data-type.
so, I have several calls of my_printf() and some special macros pointing to
them around my code.

e.g: part of my code.
.....
struct mydata *m;
struct mydata h;
.....
my_printf("%s", m->name);
.....
my_printf("%s", h.name);
.....
my_printf("whatever id %d following the string %s\n", id, m->name);
....
Macro_to_my_printf("Hey id %d, let's see %s\n", id, h.name);
.....
Macro2_to_my_printf(fd, "Hey id %d, let's see %s\n", id, m->name);
.....

My current humble *.cocci

$ cat fix-my_printf.cocci
@r1_heap@
struct mydata *SMD;
format F =~ "s";
@@
-my_printf("%@F@", SMD->name);
+my_printf("%m", SMD);

@r1_stack@
struct mydata SMD;
format F =~ "s";
@@
-my_printf("%@F@", SMD.name);
+my_printf("%m", &SMD);
$

But, I can match only with partial content as can be seen below.

$ spatch --partial-match --sp-file fix-my_printf.cocci
sample-format-string.c | egrep "^(\+|-)"
HANDLING: sample-format-string.c
diff =
HANDLING: /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c
diff =
--- /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c
+++
/var/folders/ld/6tg9c6qj4fx4c85q26mcqrsh0000gn/T/cocci-output-24659-130f86-sample-format-string.c
- my_printf("%s", m->name);
+ my_printf("%m", m);
- my_printf("%s", h.name);
+ my_printf("%m", &h);
$

Anyone could give me a light about how to proceed to match the entire
".....string format..." ?

Thanks in advance,

[-- Attachment #1.2: Type: text/html, Size: 2299 bytes --]

<div dir="ltr">Hi,<div><br></div><div>I am working on a semantic patch for replacing specific format string token based on the used data-type.</div><div>so, I have several calls of my_printf() and some special macros pointing to them around my code.</div><div><br></div><div>e.g: part of my code.</div><div>.....</div><div>struct mydata *m;<br></div><div>struct mydata h;<br></div><div>.....</div><div>my_printf(&quot;%s&quot;, m-&gt;name);</div><div>.....<br>my_printf(&quot;%s&quot;, <a href="http://h.name" target="_blank">h.name</a>);</div><div>.....<br>	my_printf(&quot;whatever id %d following the string %s\n&quot;, id, m-&gt;name);<br></div><div>....</div><div><div>Macro_to_my_printf(&quot;Hey id %d, let&#39;s see %s\n&quot;, id, <a href="http://h.name" target="_blank">h.name</a>);<br></div><div>.....</div><div>Macro2_to_my_printf(fd, &quot;Hey id %d, let&#39;s see %s\n&quot;, id, m-&gt;name);<br></div><div></div></div><div>.....<br></div><div><br></div><div>My current humble *.cocci</div><div><br></div><div>$ cat fix-my_printf.cocci<br>@r1_heap@<br>struct mydata *SMD;<br>format F =~ &quot;s&quot;;<br>@@<br>-my_printf(&quot;%@F@&quot;, SMD-&gt;name);<br>+my_printf(&quot;%m&quot;, SMD);<br><br>@r1_stack@<br>struct mydata SMD;<br>format F =~ &quot;s&quot;;<br>@@<br>-my_printf(&quot;%@F@&quot;, SMD.name);<br>+my_printf(&quot;%m&quot;, &amp;SMD);<br>$</div><div><br></div><div>But, I can match only with partial content as can be seen below.</div><div><br></div><div>$ spatch --partial-match --sp-file fix-my_printf.cocci sample-format-string.c | egrep &quot;^(\+|-)&quot;<br>HANDLING: sample-format-string.c<br>diff =<br>HANDLING: /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c<br>diff =<br>--- /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c<br>+++ /var/folders/ld/6tg9c6qj4fx4c85q26mcqrsh0000gn/T/cocci-output-24659-130f86-sample-format-string.c<br>- 	my_printf(&quot;%s&quot;, m-&gt;name);<br>+ 	my_printf(&quot;%m&quot;, m);<br>- 	my_printf(&quot;%s&quot;, <a href="http://h.name" target="_blank">h.name</a>);<br>+ 	my_printf(&quot;%m&quot;, &amp;h);<br>$<br></div><div><br></div><div>Anyone could give me a light about how to proceed to match the entire &quot;.....string format...&quot; ?</div><div><br></div><div>Thanks in advance,</div></div>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf/format calls based on the data-type
  2019-11-28  2:11 [Cocci] Replacing printf/format calls based on the data-type Strace Labs
@ 2019-11-28  7:07 ` Julia Lawall
  2019-11-28 17:45   ` Strace Labs
  2019-11-29 14:48   ` [Cocci] Replacing printf() parameters according to used data types Markus Elfring
  2019-11-28  7:50 ` Markus Elfring
  1 sibling, 2 replies; 31+ messages in thread
From: Julia Lawall @ 2019-11-28  7:07 UTC (permalink / raw)
  To: Strace Labs; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 1824 bytes --]



--- Please note the new email address ---


On Thu, 28 Nov 2019, Strace Labs wrote:

> Hi,
> I am working on a semantic patch for replacing specific format string token based on the used data-type.
> so, I have several calls of my_printf() and some special macros pointing to them around my code.
>
> e.g: part of my code.
> .....
> struct mydata *m;
> struct mydata h;
> .....
> my_printf("%s", m->name);
> .....
> my_printf("%s", h.name);
> .....
> my_printf("whatever id %d following the string %s\n", id, m->name);
> ....
> Macro_to_my_printf("Hey id %d, let's see %s\n", id, h.name);
> .....
> Macro2_to_my_printf(fd, "Hey id %d, let's see %s\n", id, m->name);
> .....
>
> My current humble *.cocci
>
> $ cat fix-my_printf.cocci
> @r1_heap@
> struct mydata *SMD;
> format F =~ "s";
> @@
> -my_printf("%@F@", SMD->name);
> +my_printf("%m", SMD);
>
> @r1_stack@
> struct mydata SMD;
> format F =~ "s";
> @@
> -my_printf("%@F@", SMD.name);
> +my_printf("%m", &SMD);
> $
>
> But, I can match only with partial content as can be seen below.
>
> $ spatch --partial-match --sp-file fix-my_printf.cocci sample-format-string.c | egrep "^(\+|-)"
> HANDLING: sample-format-string.c
> diff =
> HANDLING: /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c
> diff =
> --- /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c
> +++ /var/folders/ld/6tg9c6qj4fx4c85q26mcqrsh0000gn/T/cocci-output-24659-130f86-sample-format-string.c
> - my_printf("%s", m->name);
> + my_printf("%m", m);
> - my_printf("%s", h.name);
> + my_printf("%m", &h);
> $
>
> Anyone could give me a light about how to proceed to match the entire ".....string format..." ?

I think that what you are asking is why you can't write a pattern like:

foo("...
-%@d@
+%x
  ...")

At the moment, there seems to be a bug.  I will check on that.

julia

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-28  2:11 [Cocci] Replacing printf/format calls based on the data-type Strace Labs
  2019-11-28  7:07 ` Julia Lawall
@ 2019-11-28  7:50 ` Markus Elfring
  2019-11-29  0:35   ` Jorge Pereira
  1 sibling, 1 reply; 31+ messages in thread
From: Markus Elfring @ 2019-11-28  7:50 UTC (permalink / raw)
  To: stracelabs; +Cc: cocci

> @r1_stack@
> struct mydata SMD;
> format F =~ "s";
> @@
> -my_printf("%@F@", SMD.name);
> +my_printf("%m", &SMD);
> $
>
> But, I can match only with partial content as can be seen below.

I find this information for “partial content” unclear at the moment.

* Would you like to transform any more source code variants by using
  additional SmPL ellipses and disjunctions?

* How do you think about to extend and improve the shown change specifications?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf/format calls based on the data-type
  2019-11-28  7:07 ` Julia Lawall
@ 2019-11-28 17:45   ` Strace Labs
  2019-11-29 14:48   ` [Cocci] Replacing printf() parameters according to used data types Markus Elfring
  1 sibling, 0 replies; 31+ messages in thread
From: Strace Labs @ 2019-11-28 17:45 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 3239 bytes --]

Hi Julia,

I am not sure if I was clear. but, let me try to explain again.

1. I have the code.

$ cat sample.c
int foo() {
int id;
struct mydata h1, *h2, s1, *s2;

// works fine
  my_printf("%s", h1.name);
  my_printf("%s", h2->name);

// don't work
my_printf("%d it would work but dunno mydata=%m\n", id, h2);
my_printf("%d here also, tt=%s and %m\n", id, h2->name, s2);
}
$

2. My fix-format.cocci

$ cat fix-format.cocci
@r1_heap@
struct mydata *SMD;
format F =~ "s";
expression f;
@@
-f("%@F@", SMD->name);
+f("%m", SMD);

@r1_stack@
struct mydata SMD;
format F =~ "s";
expression f;
@@
-f("%@F@", SMD.name);
+f("%m", &SMD);

$

3. therefore, It is not matching with *my_printf("%d it would work but
dunno mydata=%m\n", id, h2);*

e.g:

$ spatch --sp-file fix-format.cocci sample.c
HANDLING: /tmp/sample.c
diff =
--- /tmp/sample.c
+++ /tmp/T/cocci-output-92962-556a08-sample.c
@@ -4,8 +4,8 @@ int foo() {
  struct mydata h1, *h2, s1, *s2;

  // works fine
- my_printf("%s", h1.name);
- my_printf("%s", h2->name);
+ my_printf("%m", &h1);
+ my_printf("%m", h2);

  // don't work
  my_printf("%d it would work but dunno mydata=%m\n", id, h2);
$

so, is it possible to fix my format-string?

On Thu, Nov 28, 2019 at 5:08 AM Julia Lawall <julia.lawall@inria.fr> wrote:

>
>
> --- Please note the new email address ---
>
>
> On Thu, 28 Nov 2019, Strace Labs wrote:
>
> > Hi,
> > I am working on a semantic patch for replacing specific format string
> token based on the used data-type.
> > so, I have several calls of my_printf() and some special macros pointing
> to them around my code.
> >
> > e.g: part of my code.
> > .....
> > struct mydata *m;
> > struct mydata h;
> > .....
> > my_printf("%s", m->name);
> > .....
> > my_printf("%s", h.name);
> > .....
> > my_printf("whatever id %d following the string %s\n", id, m->name);
> > ....
> > Macro_to_my_printf("Hey id %d, let's see %s\n", id, h.name);
> > .....
> > Macro2_to_my_printf(fd, "Hey id %d, let's see %s\n", id, m->name);
> > .....
> >
> > My current humble *.cocci
> >
> > $ cat fix-my_printf.cocci
> > @r1_heap@
> > struct mydata *SMD;
> > format F =~ "s";
> > @@
> > -my_printf("%@F@", SMD->name);
> > +my_printf("%m", SMD);
> >
> > @r1_stack@
> > struct mydata SMD;
> > format F =~ "s";
> > @@
> > -my_printf("%@F@", SMD.name);
> > +my_printf("%m", &SMD);
> > $
> >
> > But, I can match only with partial content as can be seen below.
> >
> > $ spatch --partial-match --sp-file fix-my_printf.cocci
> sample-format-string.c | egrep "^(\+|-)"
> > HANDLING: sample-format-string.c
> > diff =
> > HANDLING: /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c
> > diff =
> > --- /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c
> > +++
> /var/folders/ld/6tg9c6qj4fx4c85q26mcqrsh0000gn/T/cocci-output-24659-130f86-sample-format-string.c
> > - my_printf("%s", m->name);
> > + my_printf("%m", m);
> > - my_printf("%s", h.name);
> > + my_printf("%m", &h);
> > $
> >
> > Anyone could give me a light about how to proceed to match the entire
> ".....string format..." ?
>
> I think that what you are asking is why you can't write a pattern like:
>
> foo("...
> -%@d@
> +%x
>   ...")
>
> At the moment, there seems to be a bug.  I will check on that.
>
> julia

[-- Attachment #1.2: Type: text/html, Size: 4946 bytes --]

<div dir="ltr"><div dir="ltr">Hi Julia,<div><br></div><div>I am not sure if I was clear. but, let me try to explain again.</div><div><br></div><div>1. I have the code.</div><div><br></div><div>$ cat sample.c<br>int foo() {<br>	int id;<br>	struct mydata h1, *h2, s1, *s2;<br><br>	// works fine<br> 	my_printf(&quot;%s&quot;, <a href="http://h1.name">h1.name</a>);<br> 	my_printf(&quot;%s&quot;, h2-&gt;name);<br><br>	// don&#39;t work<br>	my_printf(&quot;%d it would work but dunno mydata=%m\n&quot;, id, h2);<br>	my_printf(&quot;%d here also, tt=%s and %m\n&quot;, id, h2-&gt;name, s2);<br>}<br>$<br></div><div><br></div><div>2. My fix-format.cocci</div><div><br></div><div>$ cat fix-format.cocci<br>@r1_heap@<br>struct mydata *SMD;<br>format F =~ &quot;s&quot;;<br>expression f;<br>@@<br>-f(&quot;%@F@&quot;, SMD-&gt;name);<br>+f(&quot;%m&quot;, SMD);<br><br>@r1_stack@<br>struct mydata SMD;<br>format F =~ &quot;s&quot;;<br>expression f;<br>@@<br>-f(&quot;%@F@&quot;, SMD.name);<br>+f(&quot;%m&quot;, &amp;SMD);<br><br>$<br></div><div><br></div><div>3. therefore, It is not matching with <b>my_printf(&quot;%d it would work but dunno mydata=%m\n&quot;, id, h2);</b></div><div><br></div><div>e.g:</div><div><br></div><div>$ spatch --sp-file fix-format.cocci sample.c<br>HANDLING: /tmp/sample.c<br>diff =<br>--- /tmp/sample.c<br>+++ /tmp/T/cocci-output-92962-556a08-sample.c<br>@@ -4,8 +4,8 @@ int foo() {<br> 	struct mydata h1, *h2, s1, *s2;<br><br> 	// works fine<br>- 	my_printf(&quot;%s&quot;, <a href="http://h1.name">h1.name</a>);<br>- 	my_printf(&quot;%s&quot;, h2-&gt;name);<br>+ 	my_printf(&quot;%m&quot;, &amp;h1);<br>+ 	my_printf(&quot;%m&quot;, h2);<br><br> 	// don&#39;t work<br> 	my_printf(&quot;%d it would work but dunno mydata=%m\n&quot;, id, h2);<br>$<br></div><div><br></div><div>so, is it possible to fix my format-string?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 28, 2019 at 5:08 AM Julia Lawall &lt;<a href="mailto:julia.lawall@inria.fr">julia.lawall@inria.fr</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
--- Please note the new email address ---<br>
<br>
<br>
On Thu, 28 Nov 2019, Strace Labs wrote:<br>
<br>
&gt; Hi,<br>
&gt; I am working on a semantic patch for replacing specific format string token based on the used data-type.<br>
&gt; so, I have several calls of my_printf() and some special macros pointing to them around my code.<br>
&gt;<br>
&gt; e.g: part of my code.<br>
&gt; .....<br>
&gt; struct mydata *m;<br>
&gt; struct mydata h;<br>
&gt; .....<br>
&gt; my_printf(&quot;%s&quot;, m-&gt;name);<br>
&gt; .....<br>
&gt; my_printf(&quot;%s&quot;, <a href="http://h.name" rel="noreferrer" target="_blank">h.name</a>);<br>
&gt; .....<br>
&gt; my_printf(&quot;whatever id %d following the string %s\n&quot;, id, m-&gt;name);<br>
&gt; ....<br>
&gt; Macro_to_my_printf(&quot;Hey id %d, let&#39;s see %s\n&quot;, id, <a href="http://h.name" rel="noreferrer" target="_blank">h.name</a>);<br>
&gt; .....<br>
&gt; Macro2_to_my_printf(fd, &quot;Hey id %d, let&#39;s see %s\n&quot;, id, m-&gt;name);<br>
&gt; .....<br>
&gt;<br>
&gt; My current humble *.cocci<br>
&gt;<br>
&gt; $ cat fix-my_printf.cocci<br>
&gt; @r1_heap@<br>
&gt; struct mydata *SMD;<br>
&gt; format F =~ &quot;s&quot;;<br>
&gt; @@<br>
&gt; -my_printf(&quot;%@F@&quot;, SMD-&gt;name);<br>
&gt; +my_printf(&quot;%m&quot;, SMD);<br>
&gt;<br>
&gt; @r1_stack@<br>
&gt; struct mydata SMD;<br>
&gt; format F =~ &quot;s&quot;;<br>
&gt; @@<br>
&gt; -my_printf(&quot;%@F@&quot;, SMD.name);<br>
&gt; +my_printf(&quot;%m&quot;, &amp;SMD);<br>
&gt; $<br>
&gt;<br>
&gt; But, I can match only with partial content as can be seen below.<br>
&gt;<br>
&gt; $ spatch --partial-match --sp-file fix-my_printf.cocci sample-format-string.c | egrep &quot;^(\+|-)&quot;<br>
&gt; HANDLING: sample-format-string.c<br>
&gt; diff =<br>
&gt; HANDLING: /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c<br>
&gt; diff =<br>
&gt; --- /Volumes/Users/jpereira/Devel/Sandbox/sample-format-string.c<br>
&gt; +++ /var/folders/ld/6tg9c6qj4fx4c85q26mcqrsh0000gn/T/cocci-output-24659-130f86-sample-format-string.c<br>
&gt; - my_printf(&quot;%s&quot;, m-&gt;name);<br>
&gt; + my_printf(&quot;%m&quot;, m);<br>
&gt; - my_printf(&quot;%s&quot;, <a href="http://h.name" rel="noreferrer" target="_blank">h.name</a>);<br>
&gt; + my_printf(&quot;%m&quot;, &amp;h);<br>
&gt; $<br>
&gt;<br>
&gt; Anyone could give me a light about how to proceed to match the entire &quot;.....string format...&quot; ?<br>
<br>
I think that what you are asking is why you can&#39;t write a pattern like:<br>
<br>
foo(&quot;...<br>
-%@d@<br>
+%x<br>
  ...&quot;)<br>
<br>
At the moment, there seems to be a bug.  I will check on that.<br>
<br>
julia</blockquote></div></div>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-28  7:50 ` Markus Elfring
@ 2019-11-29  0:35   ` Jorge Pereira
  2019-11-29  8:29     ` Markus Elfring
  0 siblings, 1 reply; 31+ messages in thread
From: Jorge Pereira @ 2019-11-29  0:35 UTC (permalink / raw)
  To: stracelabs, Markus Elfring; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 980 bytes --]

For now, I just would like to detect and patch the mentioned example. I could imagine that could be possible do using Python,.

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Markus Elfring <Markus.Elfring@web.de>
Sent: Thursday, November 28, 2019 4:50:55 AM
To: stracelabs@gmail.com <stracelabs@gmail.com>
Cc: cocci@systeme.lip6.fr <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] Replacing printf() parameters according to used data types

> @r1_stack@
> struct mydata SMD;
> format F =~ "s";
> @@
> -my_printf("%@F@", SMD.name);
> +my_printf("%m", &SMD);
> $
>
> But, I can match only with partial content as can be seen below.

I find this information for “partial content” unclear at the moment.

* Would you like to transform any more source code variants by using
  additional SmPL ellipses and disjunctions?

* How do you think about to extend and improve the shown change specifications?

Regards,
Markus

[-- Attachment #1.2: Type: text/html, Size: 2224 bytes --]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>
<div dir="auto" style="direction:ltr; margin:0; padding:0; font-family:sans-serif; font-size:11pt; color:black">
For now, I just would like to detect and patch the mentioned example. I could imagine that could be possible do using Python,.<br>
<br>
</div>
<div dir="auto" style="direction:ltr; margin:0; padding:0; font-family:sans-serif; font-size:11pt; color:black">
<span id="x_OutlookSignature">
<div dir="auto" style="direction:ltr; margin:0; padding:0; font-family:sans-serif; font-size:11pt; color:black">
Get <a href="https://aka.ms/ghei36">Outlook for Android</a></div>
</span><br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Markus Elfring &lt;Markus.Elfring@web.de&gt;<br>
<b>Sent:</b> Thursday, November 28, 2019 4:50:55 AM<br>
<b>To:</b> stracelabs@gmail.com &lt;stracelabs@gmail.com&gt;<br>
<b>Cc:</b> cocci@systeme.lip6.fr &lt;cocci@systeme.lip6.fr&gt;<br>
<b>Subject:</b> Re: [Cocci] Replacing printf() parameters according to used data types</font>
<div>&nbsp;</div>
</div>
</div>
<font size="2"><span style="font-size:11pt;">
<div class="PlainText">&gt; @r1_stack@<br>
&gt; struct mydata SMD;<br>
&gt; format F =~ &quot;s&quot;;<br>
&gt; @@<br>
&gt; -my_printf(&quot;%@F@&quot;, SMD.name);<br>
&gt; &#43;my_printf(&quot;%m&quot;, &amp;SMD);<br>
&gt; $<br>
&gt;<br>
&gt; But, I can match only with partial content as can be seen below.<br>
<br>
I find this information for “partial content” unclear at the moment.<br>
<br>
* Would you like to transform any more source code variants by using<br>
&nbsp; additional SmPL ellipses and disjunctions?<br>
<br>
* How do you think about to extend and improve the shown change specifications?<br>
<br>
Regards,<br>
Markus<br>
</div>
</span></font>
</body>
</html>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29  0:35   ` Jorge Pereira
@ 2019-11-29  8:29     ` Markus Elfring
  2019-11-29 10:57       ` Strace Labs
  0 siblings, 1 reply; 31+ messages in thread
From: Markus Elfring @ 2019-11-29  8:29 UTC (permalink / raw)
  To: Jorge Pereira; +Cc: cocci

> For now, I just would like to detect and patch the mentioned example.

Did you try out to work with SmPL ellipses and disjunctions for this purpose?


> I could imagine that could be possible do using Python,.

The application of the semantic patch language (Coccinelle software) should be safer here,
shouldn't it?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29  8:29     ` Markus Elfring
@ 2019-11-29 10:57       ` Strace Labs
  2019-11-29 12:33         ` Markus Elfring
  0 siblings, 1 reply; 31+ messages in thread
From: Strace Labs @ 2019-11-29 10:57 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 456 bytes --]

>. Did you try out to work with SmPL ellipses and disjunctions for this
purpose?

I didn't it, do you have any suggestions or sample that is it possible to
solve my problem? something to based on.

 >> II could imagine that could be possible do using Python,.

> The application of the semantic patch language (Coccinelle software)
should be safer here, shouldn't it?

I mean, the Coccinelle/Python support.


-- 
Sent from my iPowerBall®

[-- Attachment #1.2: Type: text/html, Size: 869 bytes --]





<div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="auto">
<br>
</div>
<div>
&gt;. Did you try out to work with SmPL ellipses and disjunctions for this purpose? </div>
<div dir="auto" style="text-align:left">
 </div>
<div dir="auto" style="text-align:left">
I didn&#39;t it, do you have any suggestions or sample that is it possible to solve my problem? something to based on.</div>
<div>
<br>
</div>
<div> &gt;&gt; II could imagine that could be possible do using Python,. </div>
<div>
<br>
</div>
<div>&gt; The application of the semantic patch language (Coccinelle software) should be safer here, shouldn&#39;t it? <br>
</div>
<div>
<br>
</div>
<div dir="auto" style="text-align:left">
I mean, the Coccinelle/Python support.</div>
</div>

<br><br>-- <br>Sent from my iPowerBall®<br>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29 10:57       ` Strace Labs
@ 2019-11-29 12:33         ` Markus Elfring
  2019-11-29 14:47           ` Strace Labs
  0 siblings, 1 reply; 31+ messages in thread
From: Markus Elfring @ 2019-11-29 12:33 UTC (permalink / raw)
  To: stracelabs; +Cc: Jorge Pereira, cocci

>>. Did you try out to work with SmPL ellipses and disjunctions for this purpose? 
>  
> I didn't it, do you have any suggestions or sample that is it possible
> to solve my problem? something to based on.

Can you get further development ideas from a transformation approach
like the following?

@replacement@
struct mydata SMD;
struct mydata* SMDP;
format F =~ "s";
@@
 my_printf(
-          "%@F@"
+          "%m"
           ,
(
+           &
             SMD
-               .name
|
            SMDP
-               ->name
)
          );



> I mean, the Coccinelle/Python support.

This programming interface contains also open issues for further considerations
as you can see from a topic like “Propagating values back from Python script
to SmPL rule with other metavariable type than “identifier””.
https://github.com/coccinelle/coccinelle/issues/86

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29 12:33         ` Markus Elfring
@ 2019-11-29 14:47           ` Strace Labs
  2019-11-29 16:08             ` Markus Elfring
  2019-11-29 20:55             ` Julia Lawall
  0 siblings, 2 replies; 31+ messages in thread
From: Strace Labs @ 2019-11-29 14:47 UTC (permalink / raw)
  To: Markus Elfring, Julia Lawall; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 1997 bytes --]

Markus,

so, that suggestion works the same as my previous shared statement. but,
only for calls like: *my_printf("%s", h1.name <http://h1.name>);*,
not for *my_printf("%d here also, tt=%s | %s and %m\n", id, h2->name,
h2->name, s2);*

e.g:

Code sample

int foo() {
int id;
struct mydata h1, *h2, s1, *s2;

// works fine
my_printf("%s", h1.name);
my_printf("%s", h2->name);
my_printf("%s");

// don't match.
my_printf("%s %d", h2->name, id);
my_printf("%s %s", h2->name, h2->name);
my_printf("%d it would work but dunno mydata=%m\n", id, h2);
my_printf("%d here also, tt=%s | %s and %m\n", id, h2->name, h2->name, s2);
}

so, I am not sure if Coccinelle is able to do that. I've read all samples
available in the Kernel and Coccinelle repo's and I didn't see any similar
case.

I think that if @Julia Lawall <julia.lawall@inria.fr> don't know, No one in
the world knows. 😂



On Fri, Nov 29, 2019 at 10:33 AM Markus Elfring <Markus.Elfring@web.de>
wrote:

> >>. Did you try out to work with SmPL ellipses and disjunctions for this
> purpose?
> >
> > I didn't it, do you have any suggestions or sample that is it possible
> > to solve my problem? something to based on.
>
> Can you get further development ideas from a transformation approach
> like the following?
>
> @replacement@
> struct mydata SMD;
> struct mydata* SMDP;
> format F =~ "s";
> @@
>  my_printf(
> -          "%@F@"
> +          "%m"
>            ,
> (
> +           &
>              SMD
> -               .name
> |
>             SMDP
> -               ->name
> )
>           );
>
>
>
> > I mean, the Coccinelle/Python support.
>
> This programming interface contains also open issues for further
> considerations
> as you can see from a topic like “Propagating values back from Python
> script
> to SmPL rule with other metavariable type than “identifier””.
> https://github.com/coccinelle/coccinelle/issues/86
>
> Regards,
> Markus
>

[-- Attachment #1.2: Type: text/html, Size: 3147 bytes --]

<div dir="ltr"><div dir="ltr">Markus,<div><br></div><div>so, that suggestion works the same as my previous shared statement. but, only for calls like: <b>my_printf(&quot;%s&quot;, <a href="http://h1.name" target="_blank">h1.name</a>);</b>,</div><div>not for <b>my_printf(&quot;%d here also, tt=%s | %s and %m\n&quot;, id, h2-&gt;name, h2-&gt;name, s2);</b></div></div><div><br></div>e.g:<div><br></div><div>Code sample</div><div><br><font face="monospace">int foo() {<br>	int id;<br>	struct mydata h1, *h2, s1, *s2;<br><br>	// works fine<br>	my_printf(&quot;%s&quot;, <a href="http://h1.name" target="_blank">h1.name</a>);<br>	my_printf(&quot;%s&quot;, h2-&gt;name);<br>	my_printf(&quot;%s&quot;);<br><br>	// don&#39;t match.<br>	my_printf(&quot;%s %d&quot;, h2-&gt;name, id);<br>	my_printf(&quot;%s %s&quot;, h2-&gt;name, h2-&gt;name);<br>	my_printf(&quot;%d it would work but dunno mydata=%m\n&quot;, id, h2);<br>	my_printf(&quot;%d here also, tt=%s | %s and %m\n&quot;, id, h2-&gt;name, h2-&gt;name, s2);<br>}</font><br></div><div><br></div><div>so, I am not sure if Coccinelle is able to do that. I&#39;ve read all samples available in the Kernel and Coccinelle repo&#39;s and I didn&#39;t see any similar case.</div><div><br></div><div>I think that if <a class="gmail_plusreply" id="m_1967091305000335020plusReplyChip-0" href="mailto:julia.lawall@inria.fr" target="_blank">@Julia Lawall</a> don&#39;t know, No one in the world knows. 😂</div><div><br></div><div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 29, 2019 at 10:33 AM Markus Elfring &lt;<a href="mailto:Markus.Elfring@web.de" target="_blank">Markus.Elfring@web.de</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt;&gt;. Did you try out to work with SmPL ellipses and disjunctions for this purpose? <br>
&gt;  <br>
&gt; I didn&#39;t it, do you have any suggestions or sample that is it possible<br>
&gt; to solve my problem? something to based on.<br>
<br>
Can you get further development ideas from a transformation approach<br>
like the following?<br>
<br>
@replacement@<br>
struct mydata SMD;<br>
struct mydata* SMDP;<br>
format F =~ &quot;s&quot;;<br>
@@<br>
 my_printf(<br>
-          &quot;%@F@&quot;<br>
+          &quot;%m&quot;<br>
           ,<br>
(<br>
+           &amp;<br>
             SMD<br>
-               .name<br>
|<br>
            SMDP<br>
-               -&gt;name<br>
)<br>
          );<br>
<br>
<br>
<br>
&gt; I mean, the Coccinelle/Python support.<br>
<br>
This programming interface contains also open issues for further considerations<br>
as you can see from a topic like “Propagating values back from Python script<br>
to SmPL rule with other metavariable type than “identifier””.<br>
<a href="https://github.com/coccinelle/coccinelle/issues/86" rel="noreferrer" target="_blank">https://github.com/coccinelle/coccinelle/issues/86</a><br>
<br>
Regards,<br>
Markus<br>
</blockquote></div></div></div>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-28  7:07 ` Julia Lawall
  2019-11-28 17:45   ` Strace Labs
@ 2019-11-29 14:48   ` Markus Elfring
  1 sibling, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-11-29 14:48 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

> At the moment, there seems to be a bug.  I will check on that.

I am also curious how the support will evolve further around
advanced data processing for format strings with the semantic
patch language.

Can another transformation approach become interesting for
a corresponding clarification?

@replacement@
struct mydata SMD;
format F =~ "s";
@@
 my_printf("%
-           @F@
+           m
           ",
+          &
           SMD
-             .name
          );

elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci Strace_Labs2.cocci
…
warning: replacement: metavariable F not used in the - or context code
warning: iso fld_to_ptr does not match the code below on line 10
…

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29 14:47           ` Strace Labs
@ 2019-11-29 16:08             ` Markus Elfring
  2019-11-29 17:19               ` Strace Labs
  2019-11-29 20:55             ` Julia Lawall
  1 sibling, 1 reply; 31+ messages in thread
From: Markus Elfring @ 2019-11-29 16:08 UTC (permalink / raw)
  To: stracelabs, Julia Lawall; +Cc: cocci

> so, that suggestion works the same as my previous shared statement.

I suggest to take another look at presented implementation details.


> but, only for calls like: *my_printf("%s", h1.name);*,

I limited my suggestion intentionally.


> not for *my_printf("%d here also, tt=%s | %s and %m\n", id, h2->name, h2->name, s2);*

Such a function call is using more parameters. Would you get into
the mood then to specify additional metavariables in SmPL script variants?


> so, I am not sure if Coccinelle is able to do that.

I hope that more useful data processing for format strings will become
supported by the semantic patch language.
Yesterday an information was given that another functionality is also
work in progress.


> I've read all samples available in the Kernel and Coccinelle repo's

I find such information interesting and promising.


> and I didn't see any similar case.

This observation can be fine.
How often do you fiddle with source code transformations around
format strings?


> I think that if Julia Lawall don't know, No one in the world knows.

Such an impression can occur. - But I would like to point further
possibilities out for desired knowledge distribution.

* Would you like to contact any more related developers?

* How do you think about to improve your own expertise
  (around the discussed free software) in any ways?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29 16:08             ` Markus Elfring
@ 2019-11-29 17:19               ` Strace Labs
  2019-11-29 17:45                 ` Markus Elfring
  0 siblings, 1 reply; 31+ messages in thread
From: Strace Labs @ 2019-11-29 17:19 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 2022 bytes --]

On Fri, Nov 29, 2019 at 2:09 PM Markus Elfring <Markus.Elfring@web.de>
wrote:

> > so, that suggestion works the same as my previous shared statement.
>
> I suggest to take another look at presented implementation details.
>
>
I did it, even digging the grammar and ALL samples and didn't find anything
similar to handle format strings with multiple parameters as mentioned.


>
> > but, only for calls like: *my_printf("%s", h1.name);*,
>
> I limited my suggestion intentionally.
>
>
> > not for *my_printf("%d here also, tt=%s | %s and %m\n", id, h2->name,
> h2->name, s2);*
>
> Such a function call is using more parameters. Would you get into
> the mood then to specify additional metavariables in SmPL script variants?
>
>

I can't because the calls around the code have different uses with
different variants.



> > so, I am not sure if Coccinelle is able to do that.
>
> I hope that more useful data processing for format strings will become
> supported by the semantic patch language.
> Yesterday an information was given that another functionality is also
> work in progress.
>



Interesting.



>
> > I've read all samples available in the Kernel and Coccinelle repo's
>
> I find such information interesting and promising.
>
>
> > and I didn't see any similar case.
>
> This observation can be fine.
> How often do you fiddle with source code transformations around
> format strings?
>
>


Well, I've used it before but for me, it is the first "complex" case that I
am working on. even I still digging trying to figure out how to do that but
I still not sure if the Coccelinne is capable to do that yes or no.




>
> > I think that if Julia Lawall don't know, No one in the world knows.
>
> Such an impression can occur. - But I would like to point further
> possibilities out for desired knowledge distribution.
>
> * Would you like to contact any more related developers?

* How do you think about to improve your own expertise
>   (around the discussed free software) in any ways?
>
> Regards,
> Markus
>

[-- Attachment #1.2: Type: text/html, Size: 3526 bytes --]

<div dir="ltr"><div dir="ltr">On Fri, Nov 29, 2019 at 2:09 PM Markus Elfring &lt;<a href="mailto:Markus.Elfring@web.de">Markus.Elfring@web.de</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; so, that suggestion works the same as my previous shared statement.<br>
<br>
I suggest to take another look at presented implementation details.<br>
<br></blockquote><div><br></div><div>I did it, even digging the grammar and ALL samples and didn&#39;t find anything similar to handle format strings with multiple parameters as mentioned.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
&gt; but, only for calls like: *my_printf(&quot;%s&quot;, <a href="http://h1.name" rel="noreferrer" target="_blank">h1.name</a>);*,<br>
<br>
I limited my suggestion intentionally.<br>
<br>
<br>
&gt; not for *my_printf(&quot;%d here also, tt=%s | %s and %m\n&quot;, id, h2-&gt;name, h2-&gt;name, s2);*<br>
<br>
Such a function call is using more parameters. Would you get into<br>
the mood then to specify additional metavariables in SmPL script variants?<br>
<br></blockquote><div><br></div><div><br></div><div>I can&#39;t because the calls around the code have different uses with different variants. </div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
&gt; so, I am not sure if Coccinelle is able to do that.<br>
<br>
I hope that more useful data processing for format strings will become<br>
supported by the semantic patch language.<br>
Yesterday an information was given that another functionality is also<br>
work in progress.<br></blockquote><div><br></div><div><br></div><div><br></div><div>Interesting.</div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
&gt; I&#39;ve read all samples available in the Kernel and Coccinelle repo&#39;s<br>
<br>
I find such information interesting and promising.<br>
<br>
<br>
&gt; and I didn&#39;t see any similar case.<br>
<br>
This observation can be fine.<br>
How often do you fiddle with source code transformations around<br>
format strings?<br>
<br></blockquote><div><br></div><div><br></div><div><br></div><div>Well, I&#39;ve used it before but for me, it is the first &quot;complex&quot; case that I am working on. even I still digging trying to figure out how to do that but I still not sure if the Coccelinne is capable to do that yes or no.</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
&gt; I think that if Julia Lawall don&#39;t know, No one in the world knows.<br>
<br>
Such an impression can occur. - But I would like to point further<br>
possibilities out for desired knowledge distribution.<br>
<br>
* Would you like to contact any more related developers?</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
* How do you think about to improve your own expertise<br>
  (around the discussed free software) in any ways?<br>
<br>
Regards,<br>
Markus<br>
</blockquote></div></div>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29 17:19               ` Strace Labs
@ 2019-11-29 17:45                 ` Markus Elfring
  0 siblings, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-11-29 17:45 UTC (permalink / raw)
  To: stracelabs; +Cc: cocci

>     I suggest to take another look at presented implementation details.
>
> I did it,

Such a try is generally nice.


> even digging the grammar and ALL samples and didn't find anything similar
> to handle format strings with multiple parameters as mentioned.

Can this view trigger opportunities to improve corresponding clarification attempts?


>     > not for *my_printf("%d here also, tt=%s | %s and %m\n", id, h2->name, h2->name, s2);*
>
>     Such a function call is using more parameters. Would you get into
>     the mood then to specify additional metavariables in SmPL script variants?
>
> I can't because the calls around the code have different uses with different variants. 

I suggest to reconsider your conclusion.
How will corresponding software development experiments evolve?


>     How often do you fiddle with source code transformations around
>     format strings?
>
> Well, I've used it before but for me, it is the first "complex" case
> that I am working on.

I hope that such information can help also in our communication.
Are you looking for further help according to an usual learning experience?


> even I still digging trying to figure out how to do that

Do you find the available software documentation helpful?
https://github.com/coccinelle/coccinelle/blob/ed1eb8e06f800739d3992158d36945c0c4c6f0c7/docs/manual/cocci_syntax.tex#L337


> but I still not sure if the Coccelinne is capable to do that yes or no.

How would you like to reduce involved uncertainty?

Which level of understanding did you achieve for the following functionality
so far?
* SmPL ellipsis
* SmPL disjunction

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29 14:47           ` Strace Labs
  2019-11-29 16:08             ` Markus Elfring
@ 2019-11-29 20:55             ` Julia Lawall
  2019-11-30  2:25               ` Strace Labs
  2019-11-30 15:11               ` [Cocci] Replacing printf() parameters according to used data types Markus Elfring
  1 sibling, 2 replies; 31+ messages in thread
From: Julia Lawall @ 2019-11-29 20:55 UTC (permalink / raw)
  To: Strace Labs; +Cc: Markus Elfring, cocci

Maybe this will help you:

@r@
format list d;
@@

"%@d@"

@script:ocaml s@
d << r.d;
res;
@@
res := make_expr ("\""^(String.concat "%s" (Str.split_delim
(Str.regexp_string "%d") d))^"\"")


@@
format list r.d;
expression s.res;
@@

-"%@d@"
+res

---------------

Example:

int main() {
  printf("some %d more\n", 12);
}

int main() {
  printf("%d more\n", 12);
}

int main() {
  printf("more %d\n", 12);
}

int main() {
  printf("%d more %d\n", 12);
}

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29 20:55             ` Julia Lawall
@ 2019-11-30  2:25               ` Strace Labs
  2019-11-30  6:35                 ` Julia Lawall
                                   ` (2 more replies)
  2019-11-30 15:11               ` [Cocci] Replacing printf() parameters according to used data types Markus Elfring
  1 sibling, 3 replies; 31+ messages in thread
From: Strace Labs @ 2019-11-30  2:25 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Markus Elfring, cocci

[-- Attachment #1.1: Type: text/plain, Size: 2710 bytes --]

Hi Julia,

Thanks for the suggestion. But, It is working partially... I am not sure if
Coccinelle is able to filter the %fmt e.g: %s only called with a parameter
of specific data-type. In my case, *{struct mydata }.name* and *{ struct
mydata *}->name*.

##### * Cocci*
@r1@
format list d;
identifier fn;
@@

fn("%@d@", ...)

@script:ocaml s1@
d << r1.d;
res;
@@
res := make_expr ("\""^(String.concat "%m"
(Str.split_delim(Str.regexp_string "%s") d))^"\"")

@main depends on s1 && r1@
format list r1.d;
expression s1.res;
identifier r1.fn;
struct mydata SMD;
struct mydata* SMDP;
@@

 fn(
-"%@d@"
+res
,
(
+ &
  SMD
- .name
|
  SMDP
- ->name
)
 );

*#####  .c Code sample*
int foo() {
int id;
struct mydata h1, *h2, s1, *s2;
char *city;

// works fine
my_printf("%s", s2->name);

// works without any criterions about the data type of %fmt
my_printf("sss %s gggg", h1.name);
my_printf("33131231313 %d %s %d %s hhhhh", id, s1.name, (*h2)->name,
h2->name);
my_printf("aaaa %s hhhhh", h2->name);
my_printf("%s", s2->name);

// should do nothing
my_printf("%s");
my_printf("%s", city);

// don't match.
my_printf("a %s %d", h2->name, id);
my_printf("ddddd %s %s %s", h2->name, city, h2->name);
my_printf("%d it would work but dunno mydata=%m\n", id, h2);
my_printf("%d here also, tt=%s | %s and %m\n", id, h2->name, h2->name, s2);
}

*#### Result*
HANDLING: /Volumes/Users/test/Coccinella/sample.c
diff =
--- /Volumes/Users/test/Coccinella/sample.c
+++ /tmp/cocci-output-99329-3a9829-sample.c
@@ -5,13 +5,13 @@ int foo() {
  char *city;

  // works fine
- my_printf("%s", s2->name);
+ my_printf("%m", s2);

  // works without any criterious about the data type of %fmt
- my_printf("sss %s gggg", h1.name);
+ my_printf("sss %m gggg", &h1);
  my_printf("33131231313 %d %s %d %s hhhhh", id, s1.name, (*h2)->name,
h2->name);
- my_printf("aaaa %s hhhhh", h2->name);
- my_printf("%s", s2->name);
+ my_printf("aaaa %m hhhhh", h2);
+ my_printf("%m", s2);

  // should do nothing
  my_printf("%s");


Basically, I intend to replace alls "%s" called with "mydata->name" by "%m"
with "mydata" or "&mydata"





On Fri, Nov 29, 2019 at 6:55 PM Julia Lawall <julia.lawall@inria.fr> wrote:

> Maybe this will help you:
>
> @r@
> format list d;
> @@
>
> "%@d@"
>
> @script:ocaml s@
> d << r.d;
> res;
> @@
> res := make_expr ("\""^(String.concat "%s" (Str.split_delim
> (Str.regexp_string "%d") d))^"\"")
>
>
> @@
> format list r.d;
> expression s.res;
> @@
>
> -"%@d@"
> +res
>
> ---------------
>
> Example:
>
> int main() {
>   printf("some %d more\n", 12);
> }
>
> int main() {
>   printf("%d more\n", 12);
> }
>
> int main() {
>   printf("more %d\n", 12);
> }
>
> int main() {
>   printf("%d more %d\n", 12);
> }
>
> julia
>

[-- Attachment #1.2: Type: text/html, Size: 4320 bytes --]

<div dir="ltr"><div>Hi Julia,</div><div><br></div><div>Thanks for the suggestion. But, It is working partially... I am not sure if Coccinelle is able to filter the %fmt e.g: %s only called with a parameter of specific data-type. In my case, <i>{struct mydata }.name</i> and <i>{ struct mydata *}-&gt;name</i>.</div><div><br></div><div>##### <b> Cocci</b></div><div>@r1@<br>format list d;<br>identifier fn;<br>@@<br><br>fn(&quot;%@d@&quot;, ...)<br><br>@script:ocaml s1@<br>d &lt;&lt; r1.d;<br>res;<br>@@<br>res := make_expr (&quot;\&quot;&quot;^(String.concat &quot;%m&quot; (Str.split_delim(Str.regexp_string &quot;%s&quot;) d))^&quot;\&quot;&quot;)<br><br>@main depends on s1 &amp;&amp; r1@<br>format list r1.d;<br>expression s1.res;<br>identifier r1.fn;<br>struct mydata SMD;<br>struct mydata* SMDP;<br>@@<br><br> fn(<br>-&quot;%@d@&quot;<br>+res<br>,<br>(<br>+ &amp;<br>  SMD<br>- .name<br>|<br>  SMDP<br>- -&gt;name<br>)<br> );<br> </div><div><b>#####  .c Code sample</b><br>int foo() {<br>	int id;<br>	struct mydata h1, *h2, s1, *s2;<br>	char *city;<br><br>	// works fine<br>	my_printf(&quot;%s&quot;, s2-&gt;name);<br><br>	// works without any criterions about the data type of %fmt<br>	my_printf(&quot;sss %s gggg&quot;, <a href="http://h1.name">h1.name</a>);<br>	my_printf(&quot;33131231313 %d %s %d %s hhhhh&quot;, id, <a href="http://s1.name">s1.name</a>, (*h2)-&gt;name, h2-&gt;name);<br>	my_printf(&quot;aaaa %s hhhhh&quot;, h2-&gt;name);<br>	my_printf(&quot;%s&quot;, s2-&gt;name);<br>	<br>	// should do nothing<br>	my_printf(&quot;%s&quot;);<br>	my_printf(&quot;%s&quot;, city);<br><br>	// don&#39;t match.<br>	my_printf(&quot;a %s %d&quot;, h2-&gt;name, id);<br>	my_printf(&quot;ddddd %s %s %s&quot;, h2-&gt;name, city, h2-&gt;name);<br>	my_printf(&quot;%d it would work but dunno mydata=%m\n&quot;, id, h2);<br>	my_printf(&quot;%d here also, tt=%s | %s and %m\n&quot;, id, h2-&gt;name, h2-&gt;name, s2);<br>}<br></div><div><br></div><div><b>#### Result</b></div><div>HANDLING: /Volumes/Users/test/Coccinella/sample.c<br>diff =<br>--- /Volumes/Users/test/Coccinella/sample.c<br>+++ /tmp/cocci-output-99329-3a9829-sample.c<br>@@ -5,13 +5,13 @@ int foo() {<br> 	char *city;<br><br> 	// works fine<br>-	my_printf(&quot;%s&quot;, s2-&gt;name);<br>+	my_printf(&quot;%m&quot;, s2);<br><br> 	// works without any criterious about the data type of %fmt<br>-	my_printf(&quot;sss %s gggg&quot;, <a href="http://h1.name">h1.name</a>);<br>+	my_printf(&quot;sss %m gggg&quot;, &amp;h1);<br> 	my_printf(&quot;33131231313 %d %s %d %s hhhhh&quot;, id, <a href="http://s1.name">s1.name</a>, (*h2)-&gt;name, h2-&gt;name);<br>-	my_printf(&quot;aaaa %s hhhhh&quot;, h2-&gt;name);<br>-	my_printf(&quot;%s&quot;, s2-&gt;name);<br>+	my_printf(&quot;aaaa %m hhhhh&quot;, h2);<br>+	my_printf(&quot;%m&quot;, s2);<br><br> 	// should do nothing<br> 	my_printf(&quot;%s&quot;);<br></div><div><br></div><div><br></div><div>Basically, I intend to replace alls &quot;%s&quot; called with &quot;mydata-&gt;name&quot; by &quot;%m&quot; with &quot;mydata&quot; or &quot;&amp;mydata&quot;</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 29, 2019 at 6:55 PM Julia Lawall &lt;<a href="mailto:julia.lawall@inria.fr">julia.lawall@inria.fr</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Maybe this will help you:<br>
<br>
@r@<br>
format list d;<br>
@@<br>
<br>
&quot;%@d@&quot;<br>
<br>
@script:ocaml s@<br>
d &lt;&lt; r.d;<br>
res;<br>
@@<br>
res := make_expr (&quot;\&quot;&quot;^(String.concat &quot;%s&quot; (Str.split_delim<br>
(Str.regexp_string &quot;%d&quot;) d))^&quot;\&quot;&quot;)<br>
<br>
<br>
@@<br>
format list r.d;<br>
expression s.res;<br>
@@<br>
<br>
-&quot;%@d@&quot;<br>
+res<br>
<br>
---------------<br>
<br>
Example:<br>
<br>
int main() {<br>
  printf(&quot;some %d more\n&quot;, 12);<br>
}<br>
<br>
int main() {<br>
  printf(&quot;%d more\n&quot;, 12);<br>
}<br>
<br>
int main() {<br>
  printf(&quot;more %d\n&quot;, 12);<br>
}<br>
<br>
int main() {<br>
  printf(&quot;%d more %d\n&quot;, 12);<br>
}<br>
<br>
julia<br>
</blockquote></div></div></div>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-30  2:25               ` Strace Labs
@ 2019-11-30  6:35                 ` Julia Lawall
  2019-11-30  8:46                 ` Markus Elfring
  2019-12-01  8:00                 ` [Cocci] Changing format string usage with SmPL? Markus Elfring
  2 siblings, 0 replies; 31+ messages in thread
From: Julia Lawall @ 2019-11-30  6:35 UTC (permalink / raw)
  To: Strace Labs; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 3268 bytes --]



--- Please note the new email address ---


On Sat, 30 Nov 2019, Strace Labs wrote:

> Hi Julia,
>
> Thanks for the suggestion. But, It is working partially... I am not sure if
> Coccinelle is able to filter the %fmt e.g: %s only called with a parameter
> of specific data-type. In my case, {struct mydata }.name and { struct mydata
> *}->name.
>
> #####  Cocci
> @r1@
> format list d;
> identifier fn;
> @@
>
> fn("%@d@", ...)

There is no need to put ... here if you want to specify something else.

julia

> @script:ocaml s1@
> d << r1.d;
> res;
> @@
> res := make_expr ("\""^(String.concat "%m"
> (Str.split_delim(Str.regexp_string "%s") d))^"\"")
>
> @main depends on s1 && r1@
> format list r1.d;
> expression s1.res;
> identifier r1.fn;
> struct mydata SMD;
> struct mydata* SMDP;
> @@
>
>  fn(
> -"%@d@"
> +res
> ,
> (
> + &
>   SMD
> - .name
> |
>   SMDP
> - ->name
> )
>  );
>  
> #####  .c Code sample
> int foo() {
> int id;
> struct mydata h1, *h2, s1, *s2;
> char *city;
>
> // works fine
> my_printf("%s", s2->name);
>
> // works without any criterions about the data type of %fmt
> my_printf("sss %s gggg", h1.name);
> my_printf("33131231313 %d %s %d %s hhhhh", id, s1.name, (*h2)->name,
> h2->name);
> my_printf("aaaa %s hhhhh", h2->name);
> my_printf("%s", s2->name);
>
> // should do nothing
> my_printf("%s");
> my_printf("%s", city);
>
> // don't match.
> my_printf("a %s %d", h2->name, id);
> my_printf("ddddd %s %s %s", h2->name, city, h2->name);
> my_printf("%d it would work but dunno mydata=%m\n", id, h2);
> my_printf("%d here also, tt=%s | %s and %m\n", id, h2->name, h2->name, s2);
> }
>
> #### Result
> HANDLING: /Volumes/Users/test/Coccinella/sample.c
> diff =
> --- /Volumes/Users/test/Coccinella/sample.c
> +++ /tmp/cocci-output-99329-3a9829-sample.c
> @@ -5,13 +5,13 @@ int foo() {
>   char *city;
>
>   // works fine
> - my_printf("%s", s2->name);
> + my_printf("%m", s2);
>
>   // works without any criterious about the data type of %fmt
> - my_printf("sss %s gggg", h1.name);
> + my_printf("sss %m gggg", &h1);
>   my_printf("33131231313 %d %s %d %s hhhhh", id, s1.name, (*h2)->name,
> h2->name);
> - my_printf("aaaa %s hhhhh", h2->name);
> - my_printf("%s", s2->name);
> + my_printf("aaaa %m hhhhh", h2);
> + my_printf("%m", s2);
>
>   // should do nothing
>   my_printf("%s");
>
>
> Basically, I intend to replace alls "%s" called with "mydata->name" by "%m"
> with "mydata" or "&mydata"
>
>
>
>
>
> On Fri, Nov 29, 2019 at 6:55 PM Julia Lawall <julia.lawall@inria.fr> wrote:
>       Maybe this will help you:
>
>       @r@
>       format list d;
>       @@
>
>       "%@d@"
>
>       @script:ocaml s@
>       d << r.d;
>       res;
>       @@
>       res := make_expr ("\""^(String.concat "%s" (Str.split_delim
>       (Str.regexp_string "%d") d))^"\"")
>
>
>       @@
>       format list r.d;
>       expression s.res;
>       @@
>
>       -"%@d@"
>       +res
>
>       ---------------
>
>       Example:
>
>       int main() {
>         printf("some %d more\n", 12);
>       }
>
>       int main() {
>         printf("%d more\n", 12);
>       }
>
>       int main() {
>         printf("more %d\n", 12);
>       }
>
>       int main() {
>         printf("%d more %d\n", 12);
>       }
>
>       julia
>
>
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-30  2:25               ` Strace Labs
  2019-11-30  6:35                 ` Julia Lawall
@ 2019-11-30  8:46                 ` Markus Elfring
  2019-12-01  8:00                 ` [Cocci] Changing format string usage with SmPL? Markus Elfring
  2 siblings, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-11-30  8:46 UTC (permalink / raw)
  To: stracelabs, Julia Lawall; +Cc: cocci

> I am not sure if Coccinelle is able to filter the %fmt e.g: %s only called with
> a parameter of specific data-type.

I would expect general support for such a task by the semantic patch language.


> Basically, I intend to replace alls "%s" called with "mydata->name" by "%m" with "mydata" or "&mydata"

I find that this is a succinct description for your source code transformation goal.


The usage of the other SmPL code seems to indicate that your understanding
grew for the application of previously mentioned syntax elements in significant ways.
We will probably be more curious then how the data processing for SmPL ellipses
(triple dots) within format strings can become better together with a different
selection of metavariables for possible SmPL disjunctions.

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing printf() parameters according to used data types
  2019-11-29 20:55             ` Julia Lawall
  2019-11-30  2:25               ` Strace Labs
@ 2019-11-30 15:11               ` Markus Elfring
  1 sibling, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-11-30 15:11 UTC (permalink / raw)
  To: Julia Lawall, stracelabs; +Cc: cocci

> Maybe this will help you:
>
> @r@
> format list d;
> @@
>
> "%@d@"
>
> @script:ocaml s@
> d << r.d;
> res;
> @@
> res := make_expr ("\""^(String.concat "%s" (Str.split_delim
> (Str.regexp_string "%d") d))^"\"")

Such a replacement approach might look promising.
But I got the impression that another aspect can be more important
for the safe data processing of format strings.
The passed function parameters should fit to the specified
data conversions in the string.

Can the Coccinelle software help any more to group or mark
update candidates from the expression list in appropriate ways?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-11-30  2:25               ` Strace Labs
  2019-11-30  6:35                 ` Julia Lawall
  2019-11-30  8:46                 ` Markus Elfring
@ 2019-12-01  8:00                 ` Markus Elfring
  2019-12-03  3:30                   ` Strace Labs
  2 siblings, 1 reply; 31+ messages in thread
From: Markus Elfring @ 2019-12-01  8:00 UTC (permalink / raw)
  To: stracelabs, Julia Lawall; +Cc: cocci

> Basically, I intend to replace alls "%s" called with "mydata->name" by "%m" with "mydata" or "&mydata"

How far would you get the desired source code transformation based on
software extensions around a search pattern like the following?

@find@
expression action;
expression list context, inputs;
format list fl;
@@
 action(context, "%@fl@", inputs)


Which algorithm will become sufficient for your data processing needs
around the usage of functions with variadic arguments because of format strings?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-01  8:00                 ` [Cocci] Changing format string usage with SmPL? Markus Elfring
@ 2019-12-03  3:30                   ` Strace Labs
  2019-12-03  5:18                     ` Julia Lawall
  2019-12-03 10:01                     ` Markus Elfring
  0 siblings, 2 replies; 31+ messages in thread
From: Strace Labs @ 2019-12-03  3:30 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 2088 bytes --]

On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring <Markus.Elfring@web.de> wrote:

> > Basically, I intend to replace alls "%s" called with "mydata->name" by
> "%m" with "mydata" or "&mydata"
>
> How far would you get the desired source code transformation based on
> software extensions around a search pattern like the following.
> ..........
> Which algorithm will become sufficient for your data processing needs
> around the usage of functions with variadic arguments because of format
> strings?
>
>
Actually, I really didn't get why you're asking about that. because we are
talking about X and you're asking for Y. but, either way. that is not the
point. the point is because I am studying about the Coccinelle and I am
just trying to figure out if the tool could detect "%s" called with
"mydata->name" and then replace by "%m" and remove the "->name"

e.g: Once if we have:

int foo() {
  int id;
  struct mydata h1, *h2, s1, *s2;
  char *city = "Hello";
  my_printf("%s", s2->name);
  my_printf("hi hi %s gggg", h1.name);
  my_printf("1234 %d *%s* @ %d *%s* | *%s* -> city=%s", id, *s1.name
<http://s1.name>*, 12, *(*h2).name*, *h2->name*, city);
  my_printf("aaaa %s hhhhh", h2->name);
  my_printf("%s", city);
}

Then, replace by:

int foo() {
  int id;
  struct mydata h1, *h2, s1, *s2;
  char *city = "Hello";
  *my_printf("%m", s2);*
  *my_printf("hi hi %s gggg", &h1);*
  my_printf("1234 %d *%m* @ %d *%m* | *%m* -> city=%s", id, *s1.name
<http://s1.name>*, 12, *(*h2).name*, *h2->name*, city);
*  my_printf("aaaa %s hhhhh", h2);*
  my_printf("%s", city);
}

But, I've read again the other samples and the documentation. therefore, I
didn't figure out how it should be. btw, thank you Julia for the suggestion
performing the *Ocalm/make_expr/replace*. (Due to something wrong with the
Coccinelle distributed by Brew/Osx. I just rewrote your sample using Python
and the result was the same. But, I can't just replace all "%s" by "%m". As
I said, it should be only if the "%s" was declared to use "mydata->name".

so, I still fighting yet. thanks in Advance.

Regards,
> Markus
>

[-- Attachment #1.2: Type: text/html, Size: 3244 bytes --]

<div dir="ltr"><div dir="ltr">On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring &lt;<a href="mailto:Markus.Elfring@web.de">Markus.Elfring@web.de</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; Basically, I intend to replace alls &quot;%s&quot; called with &quot;mydata-&gt;name&quot; by &quot;%m&quot; with &quot;mydata&quot; or &quot;&amp;mydata&quot;<br>
<br>
How far would you get the desired source code transformation based on<br>
software extensions around a search pattern like the following.<br>..........<br>
Which algorithm will become sufficient for your data processing needs<br>
around the usage of functions with variadic arguments because of format strings?<br>
<br></blockquote><div><br></div><div>Actually, I really didn&#39;t get why you&#39;re asking about that. because we are talking about X and you&#39;re asking for Y. but, either way. that is not the point. the point is because I am studying about the Coccinelle and I am just trying to figure out if the tool could detect &quot;%s&quot; called with &quot;mydata-&gt;name&quot; and then replace by &quot;%m&quot; and remove the &quot;-&gt;name&quot;</div><div><br></div><div>e.g: Once if we have:</div><div><br></div><div>int foo() {<br>  int id;<br>  struct mydata h1, *h2, s1, *s2;<br>  char *city = &quot;Hello&quot;;<br>  my_printf(&quot;%s&quot;, s2-&gt;name);<br>  my_printf(&quot;hi hi %s gggg&quot;, <a href="http://h1.name">h1.name</a>);<br>  my_printf(&quot;1234 %d <b>%s</b> @ %d <b>%s</b> | <b>%s</b> -&gt; city=%s&quot;, id, <b><a href="http://s1.name">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br>  my_printf(&quot;aaaa %s hhhhh&quot;, h2-&gt;name);<br>  my_printf(&quot;%s&quot;, city);<br></div><div>}</div><div><br></div><div>Then, replace by:</div><div><br></div><div><div>int foo() {<br>  int id;<br>  struct mydata h1, *h2, s1, *s2;<br>  char *city = &quot;Hello&quot;;<br>  <b>my_printf(&quot;%m&quot;, s2);</b><br>  <b>my_printf(&quot;hi hi %s gggg&quot;, &amp;h1);</b><br>  my_printf(&quot;1234 %d <b>%m</b> @ %d <b>%m</b> | <b>%m</b> -&gt; city=%s&quot;, id, <b><a href="http://s1.name">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br><b>  my_printf(&quot;aaaa %s hhhhh&quot;, h2);</b><br>  my_printf(&quot;%s&quot;, city);<br></div><div>}</div></div><div><br></div><div>But, I&#39;ve read again the other samples and the documentation. therefore, I didn&#39;t figure out how it should be. btw, thank you Julia for the suggestion performing the <i>Ocalm/make_expr/replace</i>. (Due to something wrong with the Coccinelle distributed by Brew/Osx. I just rewrote your sample using Python and the result was the same. But, I can&#39;t just replace all &quot;%s&quot; by &quot;%m&quot;. As I said, it should be only if the &quot;%s&quot; was declared to use &quot;mydata-&gt;name&quot;.</div><div><br></div><div>so, I still fighting yet. thanks in Advance.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Regards,<br>
Markus<br>
</blockquote></div></div>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-03  3:30                   ` Strace Labs
@ 2019-12-03  5:18                     ` Julia Lawall
  2019-12-03 13:28                       ` Markus Elfring
                                         ` (2 more replies)
  2019-12-03 10:01                     ` Markus Elfring
  1 sibling, 3 replies; 31+ messages in thread
From: Julia Lawall @ 2019-12-03  5:18 UTC (permalink / raw)
  To: Strace Labs; +Cc: Markus Elfring, cocci

[-- Attachment #1.1: Type: text/plain, Size: 3439 bytes --]

> De: "Strace Labs" <stracelabs@gmail.com>
> À: "Markus Elfring" <Markus.Elfring@web.de>
> Cc: "Julia Lawall" <julia.lawall@inria.fr>, cocci@systeme.lip6.fr
> Envoyé: Mardi 3 Décembre 2019 11:30:14
> Objet: Re: [Cocci] Changing format string usage with SmPL?

> On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring < [ mailto:Markus.Elfring@web.de |
> Markus.Elfring@web.de ] > wrote:

>>> Basically, I intend to replace alls "%s" called with "mydata->name" by "%m" with
>> > "mydata" or "&mydata"

>> How far would you get the desired source code transformation based on
>> software extensions around a search pattern like the following.
>> ..........
>> Which algorithm will become sufficient for your data processing needs
>> around the usage of functions with variadic arguments because of format strings?

> Actually, I really didn't get why you're asking about that. because we are
> talking about X and you're asking for Y. but, either way. that is not the
> point. the point is because I am studying about the Coccinelle and I am just
> trying to figure out if the tool could detect "%s" called with "mydata->name"
> and then replace by "%m" and remove the "->name"

> e.g: Once if we have:

> int foo() {
> int id;
> struct mydata h1, *h2, s1, *s2;
> char *city = "Hello";
> my_printf("%s", s2->name);
> my_printf("hi hi %s gggg", [ http://h1.name/ | h1.name ] );
> my_printf("1234 %d %s @ %d %s | %s -> city=%s", id, [ http://s1.name/ | s1.name
> ] , 12, (*h2).name , h2->name , city);
> my_printf("aaaa %s hhhhh", h2->name);
> my_printf("%s", city);
> }

> Then, replace by:

> int foo() {
> int id;
> struct mydata h1, *h2, s1, *s2;
> char *city = "Hello";
> my_printf("%m", s2);
> my_printf("hi hi %s gggg", &h1);
> my_printf("1234 %d %m @ %d %m | %m -> city=%s", id, [ http://s1.name/ | s1.name
> ] , 12, (*h2).name , h2->name , city);
> my_printf("aaaa %s hhhhh", h2);
> my_printf("%s", city);
> }

> But, I've read again the other samples and the documentation. therefore, I
> didn't figure out how it should be. btw, thank you Julia for the suggestion
> performing the Ocalm/make_expr/replace . (Due to something wrong with the
> Coccinelle distributed by Brew/Osx. I just rewrote your sample using Python and
> the result was the same. But, I can't just replace all "%s" by "%m". As I said,
> it should be only if the "%s" was declared to use "mydata->name".

> so, I still fighting yet. thanks in Advance.

OK, if you may have more than one argument to your print, then you can find the offset using an expression list metavariable: 

@r@ 
expression list[n] between; 
@@ 

print(s,between,h2->name,...) 

Then you can use r.n in your python rule to figure out where is the %s to change. Unfortunately, this will not work well if there are multiple name references in the argument list. Because you will be trying to change the format string in multiple ways, eg once where between has length 2 and once where between has length 4. Substantial hacks would be required to deal with this. 

It would be nice if you could do 

@r@ 
expression list[bn] between; 
expression list[an] after; 
position p; 
@@ 
print@p(s,between,name,after) 

@@ 
format list[r.bn] f1; 
format list[r.an] f2; 
position r.p; 
@@ 
print@p( 
- "%@f1@%s%@f2@" 
+ "%@f1@%m%@f2@" 
, l) 

I don't know if that would work, though. 

julia 

>> Regards,
>> Markus

[-- Attachment #1.2: Type: text/html, Size: 6278 bytes --]

<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De: </b>"Strace Labs" &lt;stracelabs@gmail.com&gt;<br><b>À: </b>"Markus Elfring" &lt;Markus.Elfring@web.de&gt;<br><b>Cc: </b>"Julia Lawall" &lt;julia.lawall@inria.fr&gt;, cocci@systeme.lip6.fr<br><b>Envoyé: </b>Mardi 3 Décembre 2019 11:30:14<br><b>Objet: </b>Re: [Cocci] Changing format string usage with SmPL?<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr"><div dir="ltr">On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring &lt;<a href="mailto:Markus.Elfring@web.de" target="_blank">Markus.Elfring@web.de</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; Basically, I intend to replace alls "%s" called with "mydata-&gt;name" by "%m" with "mydata" or "&amp;mydata"<br><br>
How far would you get the desired source code transformation based on<br>
software extensions around a search pattern like the following.<br>..........<br>
Which algorithm will become sufficient for your data processing needs<br>
around the usage of functions with variadic arguments because of format strings?<br><br></blockquote><br><div>Actually, I really didn't get why you're asking about that. because we are talking about X and you're asking for Y. but, either way. that is not the point. the point is because I am studying about the Coccinelle and I am just trying to figure out if the tool could detect "%s" called with "mydata-&gt;name" and then replace by "%m" and remove the "-&gt;name"</div><br><div>e.g: Once if we have:</div><br><div>int foo() {<br>&nbsp; int id;<br>&nbsp; struct mydata h1, *h2, s1, *s2;<br>&nbsp; char *city = "Hello";<br>&nbsp; my_printf("%s", s2-&gt;name);<br>&nbsp; my_printf("hi hi %s gggg", <a href="http://h1.name" target="_blank">h1.name</a>);<br>&nbsp; my_printf("1234 %d <b>%s</b> @ %d <b>%s</b>&nbsp;| <b>%s</b> -&gt; city=%s", id, <b><a href="http://s1.name" target="_blank">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br>&nbsp; my_printf("aaaa %s hhhhh", h2-&gt;name);<br>&nbsp; my_printf("%s", city);<br></div><div>}</div><br><div>Then, replace by:</div><br><div><div>int foo() {<br>&nbsp; int id;<br>&nbsp; struct mydata h1, *h2, s1, *s2;<br>&nbsp; char *city = "Hello";<br><b>my_printf("%m", s2);</b><br><b>my_printf("hi hi %s gggg", &amp;h1);</b><br>&nbsp; my_printf("1234 %d <b>%m</b>&nbsp;@ %d <b>%m</b>&nbsp;| <b>%m</b>&nbsp;-&gt; city=%s", id, <b><a href="http://s1.name" target="_blank">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br><b>&nbsp; my_printf("aaaa %s hhhhh", h2);</b><br>&nbsp; my_printf("%s", city);<br></div><div>}</div></div><br><div>But, I've read again the other samples and the documentation. therefore, I didn't figure out how it should be. btw, thank you Julia for the suggestion performing the <i>Ocalm/make_expr/replace</i>. (Due to something wrong with the Coccinelle distributed by Brew/Osx. I just rewrote your sample using Python and the result was the same. But, I can't just replace all "%s" by "%m". As I said, it should be only if the "%s" was declared to use "mydata-&gt;name".</div><br><div>so, I still fighting yet. thanks in Advance.</div></div></div></blockquote><div>OK, if you may have more than one argument to your print, then you can find the offset using an expression list metavariable:<br></div><div><br data-mce-bogus="1"></div><div>@r@<br data-mce-bogus="1"></div><div>expression list[n] between;<br data-mce-bogus="1"></div><div>@@<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>print(s,between,h2-&gt;name,...)<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Then you can use r.n in your python rule to figure out where is the %s to change.&nbsp; Unfortunately, this will not work well if there are multiple name references in the argument list.&nbsp; Because you will be trying to change the format string in multiple ways, eg once where between has length 2 and once where between has length 4.&nbsp; Substantial hacks would be required to deal with this.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>It would be nice if you could do<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>@r@<br data-mce-bogus="1"></div><div>expression list[bn] between;<br data-mce-bogus="1"></div><div>expression list[an] after;<br data-mce-bogus="1"></div><div>position p;<br data-mce-bogus="1"></div><div>@@<br data-mce-bogus="1"></div><div>print@p(s,between,name,after)<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>@@<br data-mce-bogus="1"></div><div>format list[r.bn] f1;<br data-mce-bogus="1"></div><div>format list[r.an] f2;<br data-mce-bogus="1"></div><div>position r.p;<br data-mce-bogus="1"></div><div>@@<br data-mce-bogus="1"></div><div>print@p(</div><div>-&nbsp;&nbsp;&nbsp; "%@f1@%s%@f2@"<br data-mce-bogus="1"></div><div>+&nbsp;&nbsp; "%@f1@%m%@f2@"<br data-mce-bogus="1"></div><div>, l)<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>I don't know if that would work, though.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>julia<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Regards,<br>
Markus<br></blockquote></div></div><br></blockquote></div></div></body></html>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-03  3:30                   ` Strace Labs
  2019-12-03  5:18                     ` Julia Lawall
@ 2019-12-03 10:01                     ` Markus Elfring
  1 sibling, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-12-03 10:01 UTC (permalink / raw)
  To: stracelabs, Julia Lawall; +Cc: cocci

> > Which algorithm will become sufficient for your data processing needs
> > around the usage of functions with variadic arguments because of format strings?
>
> Actually, I really didn't get why you're asking about that.

I suggest to take another look at affected software aspects.


> because we are talking about X and you're asking for Y.

I presented another approach to tackle your use case.


> the point is because I am studying about the Coccinelle

This is nice.


> and I am just trying to figure out if the tool could detect "%s"
> called with "mydata->name" and then replace by "%m" and remove the "->name"

It can be achieved for such format string parameters.
But I hope that the software development attention will grow
for the handling of multiple data conversions for several arguments.


> But, I've read again the other samples and the documentation.
> therefore, I didn't figure out how it should be.

Would you like to help to improve this area also for your needs?


> btw, thank you Julia for the suggestion performing the /Ocalm/make_expr/replace/.
> (Due to something wrong with the Coccinelle distributed by Brew/Osx.
> I just rewrote your sample using Python and the result was the same.

Both programming languages can perform string replacements as usual.


> But, I can't just replace all "%s" by "%m".

Will you become aware of more temporary software limitations
because mentioned implementation details can refer also to work in progress?


> As I said, it should be only if the "%s" was declared to use "mydata->name".

Such a requirement seems to be clear.


> so, I still fighting yet.

Can it be that your design imaginations are too limited
for the discussed use case so far?

How do you think about to develop a few corresponding SmPL script variants
which can handle more concrete function calls besides searching for a solution
according to the desired general source code transformation?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-03  5:18                     ` Julia Lawall
@ 2019-12-03 13:28                       ` Markus Elfring
  2019-12-03 15:43                       ` [Cocci] Generation of expression lists by SmPL script rules? Markus Elfring
  2019-12-03 17:28                       ` [Cocci] Changing format string usage with SmPL? Strace Labs
  2 siblings, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-12-03 13:28 UTC (permalink / raw)
  To: Julia Lawall, stracelabs; +Cc: cocci

> OK, if you may have more than one argument to your print,
> then you can find the offset using an expression list metavariable:
>
> @r@
> expression list[n] between;
> @@
>
> print(s,between,h2->name,...)
>
> Then you can use r.n in your python rule to figure out where is the %s to change.

This data processing approach sounds promising.


> Unfortunately, this will not work well if there are multiple name references in the argument list.

I hope that the Coccinelle software can help more with the analysis
for format strings.


> Because you will be trying to change the format string in multiple ways,
> eg once where between has length 2 and once where between has length 4.

This can probably happen.


> Substantial hacks would be required to deal with this.

How can corresponding collateral evolution be better supported?


> It would be nice if you could do
>
> @r@
> expression list[bn] between;
> expression list[an] after;
> position p;
> @@
> print@p(s,between,name,after)
>
> @@
> format list[r.bn] f1;
> format list[r.an] f2;
> position r.p;
> @@
> print@p(
> -    "%@f1@%s%@f2@"
> +   "%@f1@%m%@f2@"
> , l)
>
> I don't know if that would work, though.

I find this information interesting.
How will the clarification be continued for affected open issues?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Generation of expression lists by SmPL script rules?
  2019-12-03  5:18                     ` Julia Lawall
  2019-12-03 13:28                       ` Markus Elfring
@ 2019-12-03 15:43                       ` Markus Elfring
  2019-12-03 17:28                       ` [Cocci] Changing format string usage with SmPL? Strace Labs
  2 siblings, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-12-03 15:43 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

> OK, if you may have more than one argument to your print,
> then you can find the offset using an expression list metavariable:

How challenging would it be to add support for the construction
of such expression lists by programming interfaces (besides “make_expr”)
of Coccinelle's software library?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-03  5:18                     ` Julia Lawall
  2019-12-03 13:28                       ` Markus Elfring
  2019-12-03 15:43                       ` [Cocci] Generation of expression lists by SmPL script rules? Markus Elfring
@ 2019-12-03 17:28                       ` Strace Labs
  2019-12-04  0:21                         ` Strace Labs
                                           ` (2 more replies)
  2 siblings, 3 replies; 31+ messages in thread
From: Strace Labs @ 2019-12-03 17:28 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 4013 bytes --]

Unfortunately, it doesn't work. But, I am working on some solutions using
Python.

therefore, once we have something like:

...
@r1@
format list fl;
identifier fn;
expression list e;
position p;
@@

fn("%@fl@", e@p)
....

Then, I could handle the *format list* using *make_expr()* as well. But, Is
it possible to rename/handle the *expression list?*


On Tue, Dec 3, 2019 at 3:18 AM Julia Lawall <julia.lawall@inria.fr> wrote:

> ------------------------------
>
> *De: *"Strace Labs" <stracelabs@gmail.com>
> *À: *"Markus Elfring" <Markus.Elfring@web.de>
> *Cc: *"Julia Lawall" <julia.lawall@inria.fr>, cocci@systeme.lip6.fr
> *Envoyé: *Mardi 3 Décembre 2019 11:30:14
> *Objet: *Re: [Cocci] Changing format string usage with SmPL?
>
> On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring <Markus.Elfring@web.de>
> wrote:
>
>> > Basically, I intend to replace alls "%s" called with "mydata->name" by
>> "%m" with "mydata" or "&mydata"
>>
>> How far would you get the desired source code transformation based on
>> software extensions around a search pattern like the following.
>> ..........
>> Which algorithm will become sufficient for your data processing needs
>> around the usage of functions with variadic arguments because of format
>> strings?
>>
>>
> Actually, I really didn't get why you're asking about that. because we are
> talking about X and you're asking for Y. but, either way. that is not the
> point. the point is because I am studying about the Coccinelle and I am
> just trying to figure out if the tool could detect "%s" called with
> "mydata->name" and then replace by "%m" and remove the "->name"
>
> e.g: Once if we have:
>
> int foo() {
>   int id;
>   struct mydata h1, *h2, s1, *s2;
>   char *city = "Hello";
>   my_printf("%s", s2->name);
>   my_printf("hi hi %s gggg", h1.name);
>   my_printf("1234 %d *%s* @ %d *%s* | *%s* -> city=%s", id, *s1.name
> <http://s1.name>*, 12, *(*h2).name*, *h2->name*, city);
>   my_printf("aaaa %s hhhhh", h2->name);
>   my_printf("%s", city);
> }
>
> Then, replace by:
>
> int foo() {
>   int id;
>   struct mydata h1, *h2, s1, *s2;
>   char *city = "Hello";
> *my_printf("%m", s2);*
> *my_printf("hi hi %s gggg", &h1);*
>   my_printf("1234 %d *%m* @ %d *%m* | *%m* -> city=%s", id, *s1.name
> <http://s1.name>*, 12, *(*h2).name*, *h2->name*, city);
> *  my_printf("aaaa %s hhhhh", h2);*
>   my_printf("%s", city);
> }
>
> But, I've read again the other samples and the documentation. therefore, I
> didn't figure out how it should be. btw, thank you Julia for the suggestion
> performing the *Ocalm/make_expr/replace*. (Due to something wrong with
> the Coccinelle distributed by Brew/Osx. I just rewrote your sample using
> Python and the result was the same. But, I can't just replace all "%s" by
> "%m". As I said, it should be only if the "%s" was declared to use
> "mydata->name".
>
> so, I still fighting yet. thanks in Advance.
>
> OK, if you may have more than one argument to your print, then you can
> find the offset using an expression list metavariable:
>
> @r@
> expression list[n] between;
> @@
>
> print(s,between,h2->name,...)
>
> Then you can use r.n in your python rule to figure out where is the %s to
> change.  Unfortunately, this will not work well if there are multiple name
> references in the argument list.  Because you will be trying to change the
> format string in multiple ways, eg once where between has length 2 and once
> where between has length 4.  Substantial hacks would be required to deal
> with this.
>
> It would be nice if you could do
>
> @r@
> expression list[bn] between;
> expression list[an] after;
> position p;
> @@
> print@p(s,between,name,after)
>
> @@
> format list[r.bn] f1;
> format list[r.an] f2;
> position r.p;
> @@
> print@p(
> -    "%@f1@%s%@f2@"
> +   "%@f1@%m%@f2@"
> , l)
>
> I don't know if that would work, though.
>
> julia
>
> Regards,
>> Markus
>>
>
>

[-- Attachment #1.2: Type: text/html, Size: 7068 bytes --]

<div dir="ltr"><div dir="ltr">Unfortunately, it doesn&#39;t work. But, I am working on some solutions using Python. </div><div dir="ltr"><br></div><div>therefore, once we have something like:</div><div><br></div><div>...</div><div>@r1@<br>format list fl;<br>identifier fn;<br>expression list e;<br>position p;<br>@@<br><br>fn(&quot;%@fl@&quot;, e@p)<br></div><div>....</div><div><br></div><div>Then, I could handle the <b>format list</b> using <b>make_expr()</b> as well. But, Is it possible to rename/handle the <b>expression list?</b></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 3, 2019 at 3:18 AM Julia Lawall &lt;<a href="mailto:julia.lawall@inria.fr">julia.lawall@inria.fr</a>&gt; wrote:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><hr id="gmail-m_5206298212494274740zwchr"><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>De: </b>&quot;Strace Labs&quot; &lt;<a href="mailto:stracelabs@gmail.com" target="_blank">stracelabs@gmail.com</a>&gt;<br><b>À: </b>&quot;Markus Elfring&quot; &lt;<a href="mailto:Markus.Elfring@web.de" target="_blank">Markus.Elfring@web.de</a>&gt;<br><b>Cc: </b>&quot;Julia Lawall&quot; &lt;<a href="mailto:julia.lawall@inria.fr" target="_blank">julia.lawall@inria.fr</a>&gt;, <a href="mailto:cocci@systeme.lip6.fr" target="_blank">cocci@systeme.lip6.fr</a><br><b>Envoyé: </b>Mardi 3 Décembre 2019 11:30:14<br><b>Objet: </b>Re: [Cocci] Changing format string usage with SmPL?<br></blockquote></div><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr"><div dir="ltr">On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring &lt;<a href="mailto:Markus.Elfring@web.de" target="_blank">Markus.Elfring@web.de</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; Basically, I intend to replace alls &quot;%s&quot; called with &quot;mydata-&gt;name&quot; by &quot;%m&quot; with &quot;mydata&quot; or &quot;&amp;mydata&quot;<br><br>
How far would you get the desired source code transformation based on<br>
software extensions around a search pattern like the following.<br>..........<br>
Which algorithm will become sufficient for your data processing needs<br>
around the usage of functions with variadic arguments because of format strings?<br><br></blockquote><br><div>Actually, I really didn&#39;t get why you&#39;re asking about that. because we are talking about X and you&#39;re asking for Y. but, either way. that is not the point. the point is because I am studying about the Coccinelle and I am just trying to figure out if the tool could detect &quot;%s&quot; called with &quot;mydata-&gt;name&quot; and then replace by &quot;%m&quot; and remove the &quot;-&gt;name&quot;</div><br><div>e.g: Once if we have:</div><br><div>int foo() {<br>  int id;<br>  struct mydata h1, *h2, s1, *s2;<br>  char *city = &quot;Hello&quot;;<br>  my_printf(&quot;%s&quot;, s2-&gt;name);<br>  my_printf(&quot;hi hi %s gggg&quot;, <a href="http://h1.name" target="_blank">h1.name</a>);<br>  my_printf(&quot;1234 %d <b>%s</b> @ %d <b>%s</b> | <b>%s</b> -&gt; city=%s&quot;, id, <b><a href="http://s1.name" target="_blank">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br>  my_printf(&quot;aaaa %s hhhhh&quot;, h2-&gt;name);<br>  my_printf(&quot;%s&quot;, city);<br></div><div>}</div><br><div>Then, replace by:</div><br><div><div>int foo() {<br>  int id;<br>  struct mydata h1, *h2, s1, *s2;<br>  char *city = &quot;Hello&quot;;<br><b>my_printf(&quot;%m&quot;, s2);</b><br><b>my_printf(&quot;hi hi %s gggg&quot;, &amp;h1);</b><br>  my_printf(&quot;1234 %d <b>%m</b> @ %d <b>%m</b> | <b>%m</b> -&gt; city=%s&quot;, id, <b><a href="http://s1.name" target="_blank">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br><b>  my_printf(&quot;aaaa %s hhhhh&quot;, h2);</b><br>  my_printf(&quot;%s&quot;, city);<br></div><div>}</div></div><br><div>But, I&#39;ve read again the other samples and the documentation. therefore, I didn&#39;t figure out how it should be. btw, thank you Julia for the suggestion performing the <i>Ocalm/make_expr/replace</i>. (Due to something wrong with the Coccinelle distributed by Brew/Osx. I just rewrote your sample using Python and the result was the same. But, I can&#39;t just replace all &quot;%s&quot; by &quot;%m&quot;. As I said, it should be only if the &quot;%s&quot; was declared to use &quot;mydata-&gt;name&quot;.</div><br><div>so, I still fighting yet. thanks in Advance.</div></div></div></blockquote><div>OK, if you may have more than one argument to your print, then you can find the offset using an expression list metavariable:<br></div><div><br></div><div>@r@<br></div><div>expression list[n] between;<br></div><div>@@<br></div><div><br></div><div>print(s,between,h2-&gt;name,...)<br></div><div><br></div><div>Then you can use r.n in your python rule to figure out where is the %s to change.  Unfortunately, this will not work well if there are multiple name references in the argument list.  Because you will be trying to change the format string in multiple ways, eg once where between has length 2 and once where between has length 4.  Substantial hacks would be required to deal with this.<br></div><div><br></div><div>It would be nice if you could do<br></div><div><br></div><div>@r@<br></div><div>expression list[bn] between;<br></div><div>expression list[an] after;<br></div><div>position p;<br></div><div>@@<br></div><div>print@p(s,between,name,after)<br></div><div><br></div><div>@@<br></div><div>format list[<a href="http://r.bn" target="_blank">r.bn</a>] f1;<br></div><div>format list[<a href="http://r.an" target="_blank">r.an</a>] f2;<br></div><div>position r.p;<br></div><div>@@<br></div><div>print@p(</div><div>-    &quot;%@f1@%s%@f2@&quot;<br></div><div>+   &quot;%@f1@%m%@f2@&quot;<br></div><div>, l)<br></div><div><br></div><div>I don&#39;t know if that would work, though.<br></div><div><br></div><div>julia<br></div><div><br></div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Regards,<br>
Markus<br></blockquote></div></div><br></blockquote></div></div></div></blockquote></div></div>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-03 17:28                       ` [Cocci] Changing format string usage with SmPL? Strace Labs
@ 2019-12-04  0:21                         ` Strace Labs
  2019-12-06 19:36                           ` Markus Elfring
  2019-12-07  7:49                           ` Markus Elfring
  2019-12-04  6:47                         ` Julia Lawall
  2019-12-06 19:20                         ` Markus Elfring
  2 siblings, 2 replies; 31+ messages in thread
From: Strace Labs @ 2019-12-04  0:21 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 6937 bytes --]

After some research, I could create a Python function called
fmt_replace_by_pos() to replace the %fmt by the Indice position.

*1. Input test*

int foo() {
   int id;
   struct mydata h1, *h2, s1, *s2;
   char *city = "Hello";
   my_printf("test: char*=%s mydata=%s int=%d mydata*=%s (*mydata)=%s",
city, h1.name, id, s2->name, (*h2)->name);
}

*2. My *.cocci* (~> https://pastebin.com/a6Tfav4x )

@initialize:python@
@@
import re

def fmt_parser(_st):
# a bunch of (non-% or %%), and then (% followed by non-%).
REG = re.compile('([^%]|%%)*(%[^%])')
retval = {}
pos = 0  # where to start searching for next time
i = 0
while True:
match = REG.match(_st, pos)
if match is None:
return retval
fmt = match.group(2)
pos = match.end()
idx = pos - len(fmt)
retval[i] = { 'idx': idx, 'fmt': fmt }
i += 1

def fmt_replace_by_pos(_str, _idx, _fmt):
try:
fmts  = fmt_parser(_str)
new   = _str

if _idx == -1:
_idx = [item for item in range(0, len(fmts))]

for _i in _idx:
f     = fmts[_i]
idx   = f['idx']
fmt   = f['fmt']
fmt_l = len(fmt)
new   = new[:idx] + _fmt + new[idx + fmt_l:]

return ''.join(new)
except Exception as e:
print("** ERROR: Something wrong in fmt_replace_by_pos():\n
{}\n".format(str(e)))

@r1@
format list fl;
identifier fn;
expression list e;
position p;
@@

fn("%@fl@", e@p)

@script:python s1@
fl << r1.fl;
fn << r1.fn;
e << r1.e;
p << r1.p;
new_fmt;
to_e;
@@
// Update the %fmt by the position (Position currently hardcode)
new_fmt = fmt_replace_by_pos(coccinelle.fl, { 1, 3, 4 }, "%m")
coccinelle.new_fmt = cocci.make_expr("\"{}\"".format(new_fmt))

@main depends on s1 && r1@
format list r1.fl;
expression s1.new_fmt;
identifier r1.fn;
expression list r1.e;
expression list s1.to_e;
position r1.p;
//struct mydata SMD;
//struct mydata* SMDP;
@@

 fn(
-"%@fl@"
+new_fmt
,
e@p
 );

*3. Execution*

# spatch --sp-file fix-format.cocci sample.c
init_defs_builtins:
/usr/local/Cellar/coccinelle/1.0.9/bin/../lib/coccinelle/standard.h
warning: main: inherited metavariable to_e not used in the -, +, or context
code
HANDLING: sample.c
diff =
--- sample.c
+++ /tmp/cocci-output-17883-e8cce6-sample.c
@@ -4,7 +4,8 @@ int foo() {
  struct mydata h1, *h2, s1, *s2;
  char *city = "Hello";

- my_printf("test: char*=%s mydata=%s int=%d mydata*=%s (*mydata)=%s",
city, h1.name, id, s2->name, (*h2)->name);
+ my_printf("test: char*=%s mydata=*%m* int=%d mydata*=*%m* (*mydata)=*%m*",
+  city, h1.name, id, s2->name, (*h2)->name);
 }

#

Therefore, I could find the %fmt and replace by whatever I want based on
the *expression-list. *currently struggled on that.







On Tue, Dec 3, 2019 at 3:28 PM Strace Labs <stracelabs@gmail.com> wrote:

> Unfortunately, it doesn't work. But, I am working on some solutions using
> Python.
>
> therefore, once we have something like:
>
> ...
> @r1@
> format list fl;
> identifier fn;
> expression list e;
> position p;
> @@
>
> fn("%@fl@", e@p)
> ....
>
> Then, I could handle the *format list* using *make_expr()* as well. But,
> Is it possible to rename/handle the *expression list?*
>
>
> On Tue, Dec 3, 2019 at 3:18 AM Julia Lawall <julia.lawall@inria.fr> wrote:
>
>> ------------------------------
>>
>> *De: *"Strace Labs" <stracelabs@gmail.com>
>> *À: *"Markus Elfring" <Markus.Elfring@web.de>
>> *Cc: *"Julia Lawall" <julia.lawall@inria.fr>, cocci@systeme.lip6.fr
>> *Envoyé: *Mardi 3 Décembre 2019 11:30:14
>> *Objet: *Re: [Cocci] Changing format string usage with SmPL?
>>
>> On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring <Markus.Elfring@web.de>
>> wrote:
>>
>>> > Basically, I intend to replace alls "%s" called with "mydata->name" by
>>> "%m" with "mydata" or "&mydata"
>>>
>>> How far would you get the desired source code transformation based on
>>> software extensions around a search pattern like the following.
>>> ..........
>>> Which algorithm will become sufficient for your data processing needs
>>> around the usage of functions with variadic arguments because of format
>>> strings?
>>>
>>>
>> Actually, I really didn't get why you're asking about that. because we
>> are talking about X and you're asking for Y. but, either way. that is not
>> the point. the point is because I am studying about the Coccinelle and I am
>> just trying to figure out if the tool could detect "%s" called with
>> "mydata->name" and then replace by "%m" and remove the "->name"
>>
>> e.g: Once if we have:
>>
>> int foo() {
>>   int id;
>>   struct mydata h1, *h2, s1, *s2;
>>   char *city = "Hello";
>>   my_printf("%s", s2->name);
>>   my_printf("hi hi %s gggg", h1.name);
>>   my_printf("1234 %d *%s* @ %d *%s* | *%s* -> city=%s", id, *s1.name
>> <http://s1.name>*, 12, *(*h2).name*, *h2->name*, city);
>>   my_printf("aaaa %s hhhhh", h2->name);
>>   my_printf("%s", city);
>> }
>>
>> Then, replace by:
>>
>> int foo() {
>>   int id;
>>   struct mydata h1, *h2, s1, *s2;
>>   char *city = "Hello";
>> *my_printf("%m", s2);*
>> *my_printf("hi hi %s gggg", &h1);*
>>   my_printf("1234 %d *%m* @ %d *%m* | *%m* -> city=%s", id, *s1.name
>> <http://s1.name>*, 12, *(*h2).name*, *h2->name*, city);
>> *  my_printf("aaaa %s hhhhh", h2);*
>>   my_printf("%s", city);
>> }
>>
>> But, I've read again the other samples and the documentation. therefore,
>> I didn't figure out how it should be. btw, thank you Julia for the
>> suggestion performing the *Ocalm/make_expr/replace*. (Due to something
>> wrong with the Coccinelle distributed by Brew/Osx. I just rewrote your
>> sample using Python and the result was the same. But, I can't just replace
>> all "%s" by "%m". As I said, it should be only if the "%s" was declared to
>> use "mydata->name".
>>
>> so, I still fighting yet. thanks in Advance.
>>
>> OK, if you may have more than one argument to your print, then you can
>> find the offset using an expression list metavariable:
>>
>> @r@
>> expression list[n] between;
>> @@
>>
>> print(s,between,h2->name,...)
>>
>> Then you can use r.n in your python rule to figure out where is the %s to
>> change.  Unfortunately, this will not work well if there are multiple name
>> references in the argument list.  Because you will be trying to change the
>> format string in multiple ways, eg once where between has length 2 and once
>> where between has length 4.  Substantial hacks would be required to deal
>> with this.
>>
>> It would be nice if you could do
>>
>> @r@
>> expression list[bn] between;
>> expression list[an] after;
>> position p;
>> @@
>> print@p(s,between,name,after)
>>
>> @@
>> format list[r.bn] f1;
>> format list[r.an] f2;
>> position r.p;
>> @@
>> print@p(
>> -    "%@f1@%s%@f2@"
>> +   "%@f1@%m%@f2@"
>> , l)
>>
>> I don't know if that would work, though.
>>
>> julia
>>
>> Regards,
>>> Markus
>>>
>>
>>

[-- Attachment #1.2: Type: text/html, Size: 11620 bytes --]

<div dir="ltr"><div dir="ltr">After some research, I could create a Python function called fmt_replace_by_pos() to replace the %fmt by the Indice position.<div><br></div><div><b>1. Input test</b></div><div><br></div><div>int foo() {<br>   int id;<br>   struct mydata h1, *h2, s1, *s2;<br>   char *city = &quot;Hello&quot;;<br>   my_printf(&quot;test: char*=%s mydata=%s int=%d mydata*=%s (*mydata)=%s&quot;, city, <a href="http://h1.name" target="_blank">h1.name</a>, id, s2-&gt;name, (*h2)-&gt;name);<br>}<br></div><div><br></div><div><b>2. My *.cocci</b> (~&gt; <a href="https://pastebin.com/a6Tfav4x" target="_blank">https://pastebin.com/a6Tfav4x</a> )</div><div><br></div><font face="monospace">@initialize:python@<br>@@<br>import re<br><br>def fmt_parser(_st):<br>	# a bunch of (non-% or %%), and then (% followed by non-%).<br>	REG = re.compile(&#39;([^%]|%%)*(%[^%])&#39;)<br>	retval = {}<br>	pos = 0  # where to start searching for next time<br>	i = 0<br>	while True:<br>		match = REG.match(_st, pos)<br>		if match is None:<br>			return retval<br>		fmt = match.group(2)<br>		pos = match.end()<br>		idx = pos - len(fmt)<br>		retval[i] = { &#39;idx&#39;: idx, &#39;fmt&#39;: fmt }<br>		i += 1<br><br>def fmt_replace_by_pos(_str, _idx, _fmt):<br>	try:<br>		fmts  = fmt_parser(_str)<br>		new   = _str<br><br>		if _idx == -1:<br>			_idx = [item for item in range(0, len(fmts))]<br><br>		for _i in _idx:<br>			f     = fmts[_i]<br>			idx   = f[&#39;idx&#39;]<br>			fmt   = f[&#39;fmt&#39;]<br>			fmt_l = len(fmt)<br>			new   = new[:idx] + _fmt + new[idx + fmt_l:]<br>		<br>		return &#39;&#39;.join(new)<br>	except Exception as e:<br>		print(&quot;** ERROR: Something wrong in fmt_replace_by_pos():\n {}\n&quot;.format(str(e)))<br><br>@r1@<br>format list fl;<br>identifier fn;<br>expression list e;<br>position p;<br>@@<br><br>fn(&quot;%@fl@&quot;, e@p)<br><br>@script:python s1@<br>fl &lt;&lt; r1.fl;<br>fn &lt;&lt; r1.fn;<br>e &lt;&lt; r1.e;<br>p &lt;&lt; r1.p;<br>new_fmt;<br>to_e;<br>@@<br>// Update the %fmt by the position (Position currently hardcode)<br>new_fmt = fmt_replace_by_pos(coccinelle.fl, { 1, 3, 4 }, &quot;%m&quot;)<br>coccinelle.new_fmt = cocci.make_expr(&quot;\&quot;{}\&quot;&quot;.format(new_fmt))</font></div><div dir="ltr"><font face="monospace"><br>@main depends on s1 &amp;&amp; r1@<br>format list r1.fl;<br>expression s1.new_fmt;<br>identifier r1.fn;<br>expression list r1.e;<br>expression list s1.to_e;<br>position r1.p;<br>//struct mydata SMD;<br>//struct mydata* SMDP;<br>@@<br><br> fn(<br>-&quot;%@fl@&quot;<br>+new_fmt<br>,<br>e@p<br></font><div><font face="monospace"> ); </font></div></div><div><br></div><b>3. Execution</b><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr"># spatch --sp-file fix-format.cocci sample.c<br>init_defs_builtins: /usr/local/Cellar/coccinelle/1.0.9/bin/../lib/coccinelle/standard.h<br>warning: main: inherited metavariable to_e not used in the -, +, or context code<br>HANDLING: sample.c<br>diff =<br>--- sample.c<br>+++ /tmp/cocci-output-17883-e8cce6-sample.c<br>@@ -4,7 +4,8 @@ int foo() {<br> 	struct mydata h1, *h2, s1, *s2;<br> 	char *city = &quot;Hello&quot;;<br><br>-	my_printf(&quot;test: char*=%s mydata=%s int=%d mydata*=%s (*mydata)=%s&quot;, city, <a href="http://h1.name" target="_blank">h1.name</a>, id, s2-&gt;name, (*h2)-&gt;name);<br>+	my_printf(&quot;test: char*=%s mydata=<b>%m</b> int=%d mydata*=<b>%m</b> (*mydata)=<b>%m</b>&quot;,<br>+		  city, <a href="http://h1.name" target="_blank">h1.name</a>, id, s2-&gt;name, (*h2)-&gt;name);<br> }<br></div><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">#</div><div dir="ltr" class="gmail_attr"><br></div><div class="gmail_attr">Therefore, I could find the %fmt and replace by whatever I want based on the <i><b>expression-list</b>. </i>currently struggled on that.</div><div class="gmail_attr"><br></div><div class="gmail_attr"><br></div><div class="gmail_attr"><br></div><div class="gmail_attr"><br></div><div class="gmail_attr"><br></div><div class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">On Tue, Dec 3, 2019 at 3:28 PM Strace Labs &lt;<a href="mailto:stracelabs@gmail.com" target="_blank">stracelabs@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Unfortunately, it doesn&#39;t work. But, I am working on some solutions using Python. </div><div dir="ltr"><br></div><div>therefore, once we have something like:</div><div><br></div><div>...</div><div>@r1@<br>format list fl;<br>identifier fn;<br>expression list e;<br>position p;<br>@@<br><br>fn(&quot;%@fl@&quot;, e@p)<br></div><div>....</div><div><br></div><div>Then, I could handle the <b>format list</b> using <b>make_expr()</b> as well. But, Is it possible to rename/handle the <b>expression list?</b></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 3, 2019 at 3:18 AM Julia Lawall &lt;<a href="mailto:julia.lawall@inria.fr" target="_blank">julia.lawall@inria.fr</a>&gt; wrote:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><hr id="m_8155605281521584323gmail-m_-6728304308782957728gmail-m_5206298212494274740zwchr"><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>De: </b>&quot;Strace Labs&quot; &lt;<a href="mailto:stracelabs@gmail.com" target="_blank">stracelabs@gmail.com</a>&gt;<br><b>À: </b>&quot;Markus Elfring&quot; &lt;<a href="mailto:Markus.Elfring@web.de" target="_blank">Markus.Elfring@web.de</a>&gt;<br><b>Cc: </b>&quot;Julia Lawall&quot; &lt;<a href="mailto:julia.lawall@inria.fr" target="_blank">julia.lawall@inria.fr</a>&gt;, <a href="mailto:cocci@systeme.lip6.fr" target="_blank">cocci@systeme.lip6.fr</a><br><b>Envoyé: </b>Mardi 3 Décembre 2019 11:30:14<br><b>Objet: </b>Re: [Cocci] Changing format string usage with SmPL?<br></blockquote></div><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr"><div dir="ltr">On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring &lt;<a href="mailto:Markus.Elfring@web.de" target="_blank">Markus.Elfring@web.de</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; Basically, I intend to replace alls &quot;%s&quot; called with &quot;mydata-&gt;name&quot; by &quot;%m&quot; with &quot;mydata&quot; or &quot;&amp;mydata&quot;<br><br>
How far would you get the desired source code transformation based on<br>
software extensions around a search pattern like the following.<br>..........<br>
Which algorithm will become sufficient for your data processing needs<br>
around the usage of functions with variadic arguments because of format strings?<br><br></blockquote><br><div>Actually, I really didn&#39;t get why you&#39;re asking about that. because we are talking about X and you&#39;re asking for Y. but, either way. that is not the point. the point is because I am studying about the Coccinelle and I am just trying to figure out if the tool could detect &quot;%s&quot; called with &quot;mydata-&gt;name&quot; and then replace by &quot;%m&quot; and remove the &quot;-&gt;name&quot;</div><br><div>e.g: Once if we have:</div><br><div>int foo() {<br>  int id;<br>  struct mydata h1, *h2, s1, *s2;<br>  char *city = &quot;Hello&quot;;<br>  my_printf(&quot;%s&quot;, s2-&gt;name);<br>  my_printf(&quot;hi hi %s gggg&quot;, <a href="http://h1.name" target="_blank">h1.name</a>);<br>  my_printf(&quot;1234 %d <b>%s</b> @ %d <b>%s</b> | <b>%s</b> -&gt; city=%s&quot;, id, <b><a href="http://s1.name" target="_blank">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br>  my_printf(&quot;aaaa %s hhhhh&quot;, h2-&gt;name);<br>  my_printf(&quot;%s&quot;, city);<br></div><div>}</div><br><div>Then, replace by:</div><br><div><div>int foo() {<br>  int id;<br>  struct mydata h1, *h2, s1, *s2;<br>  char *city = &quot;Hello&quot;;<br><b>my_printf(&quot;%m&quot;, s2);</b><br><b>my_printf(&quot;hi hi %s gggg&quot;, &amp;h1);</b><br>  my_printf(&quot;1234 %d <b>%m</b> @ %d <b>%m</b> | <b>%m</b> -&gt; city=%s&quot;, id, <b><a href="http://s1.name" target="_blank">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br><b>  my_printf(&quot;aaaa %s hhhhh&quot;, h2);</b><br>  my_printf(&quot;%s&quot;, city);<br></div><div>}</div></div><br><div>But, I&#39;ve read again the other samples and the documentation. therefore, I didn&#39;t figure out how it should be. btw, thank you Julia for the suggestion performing the <i>Ocalm/make_expr/replace</i>. (Due to something wrong with the Coccinelle distributed by Brew/Osx. I just rewrote your sample using Python and the result was the same. But, I can&#39;t just replace all &quot;%s&quot; by &quot;%m&quot;. As I said, it should be only if the &quot;%s&quot; was declared to use &quot;mydata-&gt;name&quot;.</div><br><div>so, I still fighting yet. thanks in Advance.</div></div></div></blockquote><div>OK, if you may have more than one argument to your print, then you can find the offset using an expression list metavariable:<br></div><div><br></div><div>@r@<br></div><div>expression list[n] between;<br></div><div>@@<br></div><div><br></div><div>print(s,between,h2-&gt;name,...)<br></div><div><br></div><div>Then you can use r.n in your python rule to figure out where is the %s to change.  Unfortunately, this will not work well if there are multiple name references in the argument list.  Because you will be trying to change the format string in multiple ways, eg once where between has length 2 and once where between has length 4.  Substantial hacks would be required to deal with this.<br></div><div><br></div><div>It would be nice if you could do<br></div><div><br></div><div>@r@<br></div><div>expression list[bn] between;<br></div><div>expression list[an] after;<br></div><div>position p;<br></div><div>@@<br></div><div>print@p(s,between,name,after)<br></div><div><br></div><div>@@<br></div><div>format list[<a href="http://r.bn" target="_blank">r.bn</a>] f1;<br></div><div>format list[<a href="http://r.an" target="_blank">r.an</a>] f2;<br></div><div>position r.p;<br></div><div>@@<br></div><div>print@p(</div><div>-    &quot;%@f1@%s%@f2@&quot;<br></div><div>+   &quot;%@f1@%m%@f2@&quot;<br></div><div>, l)<br></div><div><br></div><div>I don&#39;t know if that would work, though.<br></div><div><br></div><div>julia<br></div><div><br></div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Regards,<br>
Markus<br></blockquote></div></div><br></blockquote></div></div></div></blockquote></div></div>
</blockquote></div></div>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-03 17:28                       ` [Cocci] Changing format string usage with SmPL? Strace Labs
  2019-12-04  0:21                         ` Strace Labs
@ 2019-12-04  6:47                         ` Julia Lawall
  2019-12-06 19:44                           ` Markus Elfring
  2019-12-06 19:20                         ` Markus Elfring
  2 siblings, 1 reply; 31+ messages in thread
From: Julia Lawall @ 2019-12-04  6:47 UTC (permalink / raw)
  To: Strace Labs; +Cc: cocci

[-- Attachment #1.1: Type: text/plain, Size: 4706 bytes --]

> De: "Strace Labs" <stracelabs@gmail.com>
> À: "Julia Lawall" <julia.lawall@inria.fr>
> Cc: "cocci" <cocci@systeme.lip6.fr>
> Envoyé: Mercredi 4 Décembre 2019 01:28:22
> Objet: Re: [Cocci] Changing format string usage with SmPL?

> Unfortunately, it doesn't work. But, I am working on some solutions using
> Python.

> therefore, once we have something like:

> ...
> @r1@
> format list fl;
> identifier fn;
> expression list e;
> position p;
> @@

> fn("%@fl@", e@p)
> ....

> Then, I could handle the format list using make_expr() as well. But, Is it
> possible to rename/handle the expression list?

Could you fix up the expression list first? Then you can write a rule like 

char[] s; 

fn(s, ..., 
- oldcode 
+ newcode 
,...) 

julia 

> On Tue, Dec 3, 2019 at 3:18 AM Julia Lawall < [ mailto:julia.lawall@inria.fr |
> julia.lawall@inria.fr ] > wrote:

>>> De: "Strace Labs" < [ mailto:stracelabs@gmail.com | stracelabs@gmail.com ] >
>>> À: "Markus Elfring" < [ mailto:Markus.Elfring@web.de | Markus.Elfring@web.de ] >
>>> Cc: "Julia Lawall" < [ mailto:julia.lawall@inria.fr | julia.lawall@inria.fr ] >,
>>> [ mailto:cocci@systeme.lip6.fr | cocci@systeme.lip6.fr ]
>>> Envoyé: Mardi 3 Décembre 2019 11:30:14
>>> Objet: Re: [Cocci] Changing format string usage with SmPL?

>>> On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring < [ mailto:Markus.Elfring@web.de |
>>> Markus.Elfring@web.de ] > wrote:

>>>>> Basically, I intend to replace alls "%s" called with "mydata->name" by "%m" with
>>>> > "mydata" or "&mydata"

>>>> How far would you get the desired source code transformation based on
>>>> software extensions around a search pattern like the following.
>>>> ..........
>>>> Which algorithm will become sufficient for your data processing needs
>>>> around the usage of functions with variadic arguments because of format strings?

>>> Actually, I really didn't get why you're asking about that. because we are
>>> talking about X and you're asking for Y. but, either way. that is not the
>>> point. the point is because I am studying about the Coccinelle and I am just
>>> trying to figure out if the tool could detect "%s" called with "mydata->name"
>>> and then replace by "%m" and remove the "->name"

>>> e.g: Once if we have:

>>> int foo() {
>>> int id;
>>> struct mydata h1, *h2, s1, *s2;
>>> char *city = "Hello";
>>> my_printf("%s", s2->name);
>>> my_printf("hi hi %s gggg", [ http://h1.name/ | h1.name ] );
>>> my_printf("1234 %d %s @ %d %s | %s -> city=%s", id, [ http://s1.name/ | s1.name
>>> ] , 12, (*h2).name , h2->name , city);
>>> my_printf("aaaa %s hhhhh", h2->name);
>>> my_printf("%s", city);
>>> }

>>> Then, replace by:

>>> int foo() {
>>> int id;
>>> struct mydata h1, *h2, s1, *s2;
>>> char *city = "Hello";
>>> my_printf("%m", s2);
>>> my_printf("hi hi %s gggg", &h1);
>>> my_printf("1234 %d %m @ %d %m | %m -> city=%s", id, [ http://s1.name/ | s1.name
>>> ] , 12, (*h2).name , h2->name , city);
>>> my_printf("aaaa %s hhhhh", h2);
>>> my_printf("%s", city);
>>> }

>>> But, I've read again the other samples and the documentation. therefore, I
>>> didn't figure out how it should be. btw, thank you Julia for the suggestion
>>> performing the Ocalm/make_expr/replace . (Due to something wrong with the
>>> Coccinelle distributed by Brew/Osx. I just rewrote your sample using Python and
>>> the result was the same. But, I can't just replace all "%s" by "%m". As I said,
>>> it should be only if the "%s" was declared to use "mydata->name".

>>> so, I still fighting yet. thanks in Advance.

>> OK, if you may have more than one argument to your print, then you can find the
>> offset using an expression list metavariable:

>> @r@
>> expression list[n] between;
>> @@

>> print(s,between,h2->name,...)

>> Then you can use r.n in your python rule to figure out where is the %s to
>> change. Unfortunately, this will not work well if there are multiple name
>> references in the argument list. Because you will be trying to change the
>> format string in multiple ways, eg once where between has length 2 and once
>> where between has length 4. Substantial hacks would be required to deal with
>> this.

>> It would be nice if you could do

>> @r@
>> expression list[bn] between;
>> expression list[an] after;
>> position p;
>> @@
>> print@p(s,between,name,after)

>> @@
>> format list[ [ http://r.bn/ | r.bn ] ] f1;
>> format list[ [ http://r.an/ | r.an ] ] f2;
>> position r.p;
>> @@
>> print@p(
>> - "%@f1@%s%@f2@"
>> + "%@f1@%m%@f2@"
>> , l)

>> I don't know if that would work, though.

>> julia

>>>> Regards,
>>>> Markus

[-- Attachment #1.2: Type: text/html, Size: 8688 bytes --]

<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De: </b>"Strace Labs" &lt;stracelabs@gmail.com&gt;<br><b>À: </b>"Julia Lawall" &lt;julia.lawall@inria.fr&gt;<br><b>Cc: </b>"cocci" &lt;cocci@systeme.lip6.fr&gt;<br><b>Envoyé: </b>Mercredi 4 Décembre 2019 01:28:22<br><b>Objet: </b>Re: [Cocci] Changing format string usage with SmPL?<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr"><div dir="ltr">Unfortunately, it doesn't work. But, I am working on some solutions using Python.&nbsp;</div><div dir="ltr"><br></div><div>therefore, once we have something like:</div><br><div>...</div><div>@r1@<br>format list fl;<br>identifier fn;<br>expression list e;<br>position p;<br>@@<br><br>fn("%@fl@", e@p)<br></div><div>....</div><br><div>Then, I could handle the <b>format list</b>&nbsp;using&nbsp;<b>make_expr()</b>&nbsp;as well. But, Is it possible to rename/handle the <b>expression list?</b></div></div></blockquote><div><br></div><div>Could you fix up the expression list first?&nbsp; Then you can write a rule like<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>char[] s;<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>fn(s, ...,<br data-mce-bogus="1"></div><div>- oldcode<br data-mce-bogus="1"></div><div>+ newcode<br data-mce-bogus="1"></div><div>&nbsp;&nbsp; ,...)<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>julia<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 3, 2019 at 3:18 AM Julia Lawall &lt;<a href="mailto:julia.lawall@inria.fr" target="_blank">julia.lawall@inria.fr</a>&gt; wrote:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><hr id="gmail-m_5206298212494274740zwchr"><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>De: </b>"Strace Labs" &lt;<a href="mailto:stracelabs@gmail.com" target="_blank">stracelabs@gmail.com</a>&gt;<br><b>À: </b>"Markus Elfring" &lt;<a href="mailto:Markus.Elfring@web.de" target="_blank">Markus.Elfring@web.de</a>&gt;<br><b>Cc: </b>"Julia Lawall" &lt;<a href="mailto:julia.lawall@inria.fr" target="_blank">julia.lawall@inria.fr</a>&gt;, <a href="mailto:cocci@systeme.lip6.fr" target="_blank">cocci@systeme.lip6.fr</a><br><b>Envoyé: </b>Mardi 3 Décembre 2019 11:30:14<br><b>Objet: </b>Re: [Cocci] Changing format string usage with SmPL?<br></blockquote></div><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr"><div dir="ltr">On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring &lt;<a href="mailto:Markus.Elfring@web.de" target="_blank">Markus.Elfring@web.de</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; Basically, I intend to replace alls "%s" called with "mydata-&gt;name" by "%m" with "mydata" or "&amp;mydata"<br><br>
How far would you get the desired source code transformation based on<br>
software extensions around a search pattern like the following.<br>..........<br>
Which algorithm will become sufficient for your data processing needs<br>
around the usage of functions with variadic arguments because of format strings?<br><br></blockquote><br><div>Actually, I really didn't get why you're asking about that. because we are talking about X and you're asking for Y. but, either way. that is not the point. the point is because I am studying about the Coccinelle and I am just trying to figure out if the tool could detect "%s" called with "mydata-&gt;name" and then replace by "%m" and remove the "-&gt;name"</div><br><div>e.g: Once if we have:</div><br><div>int foo() {<br>&nbsp; int id;<br>&nbsp; struct mydata h1, *h2, s1, *s2;<br>&nbsp; char *city = "Hello";<br>&nbsp; my_printf("%s", s2-&gt;name);<br>&nbsp; my_printf("hi hi %s gggg", <a href="http://h1.name" target="_blank">h1.name</a>);<br>&nbsp; my_printf("1234 %d <b>%s</b> @ %d <b>%s</b>&nbsp;| <b>%s</b> -&gt; city=%s", id, <b><a href="http://s1.name" target="_blank">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br>&nbsp; my_printf("aaaa %s hhhhh", h2-&gt;name);<br>&nbsp; my_printf("%s", city);<br></div><div>}</div><br><div>Then, replace by:</div><br><div><div>int foo() {<br>&nbsp; int id;<br>&nbsp; struct mydata h1, *h2, s1, *s2;<br>&nbsp; char *city = "Hello";<br><b>my_printf("%m", s2);</b><br><b>my_printf("hi hi %s gggg", &amp;h1);</b><br>&nbsp; my_printf("1234 %d <b>%m</b>&nbsp;@ %d <b>%m</b>&nbsp;| <b>%m</b>&nbsp;-&gt; city=%s", id, <b><a href="http://s1.name" target="_blank">s1.name</a></b>, 12, <b>(*h2).name</b>, <b>h2-&gt;name</b>, city);<br><b>&nbsp; my_printf("aaaa %s hhhhh", h2);</b><br>&nbsp; my_printf("%s", city);<br></div><div>}</div></div><br><div>But, I've read again the other samples and the documentation. therefore, I didn't figure out how it should be. btw, thank you Julia for the suggestion performing the <i>Ocalm/make_expr/replace</i>. (Due to something wrong with the Coccinelle distributed by Brew/Osx. I just rewrote your sample using Python and the result was the same. But, I can't just replace all "%s" by "%m". As I said, it should be only if the "%s" was declared to use "mydata-&gt;name".</div><br><div>so, I still fighting yet. thanks in Advance.</div></div></div></blockquote><div>OK, if you may have more than one argument to your print, then you can find the offset using an expression list metavariable:<br></div><br><div>@r@<br></div><div>expression list[n] between;<br></div><div>@@<br></div><br><div>print(s,between,h2-&gt;name,...)<br></div><br><div>Then you can use r.n in your python rule to figure out where is the %s to change.&nbsp; Unfortunately, this will not work well if there are multiple name references in the argument list.&nbsp; Because you will be trying to change the format string in multiple ways, eg once where between has length 2 and once where between has length 4.&nbsp; Substantial hacks would be required to deal with this.<br></div><br><div>It would be nice if you could do<br></div><br><div>@r@<br></div><div>expression list[bn] between;<br></div><div>expression list[an] after;<br></div><div>position p;<br></div><div>@@<br></div><div>print@p(s,between,name,after)<br></div><br><div>@@<br></div><div>format list[<a href="http://r.bn" target="_blank">r.bn</a>] f1;<br></div><div>format list[<a href="http://r.an" target="_blank">r.an</a>] f2;<br></div><div>position r.p;<br></div><div>@@<br></div><div>print@p(</div><div>-&nbsp;&nbsp;&nbsp; "%@f1@%s%@f2@"<br></div><div>+&nbsp;&nbsp; "%@f1@%m%@f2@"<br></div><div>, l)<br></div><br><div>I don't know if that would work, though.<br></div><br><div>julia<br></div><br><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Regards,<br>
Markus<br></blockquote></div></div></blockquote></div></div></div></blockquote></div></div><br></blockquote></div></div></body></html>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-03 17:28                       ` [Cocci] Changing format string usage with SmPL? Strace Labs
  2019-12-04  0:21                         ` Strace Labs
  2019-12-04  6:47                         ` Julia Lawall
@ 2019-12-06 19:20                         ` Markus Elfring
  2 siblings, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-12-06 19:20 UTC (permalink / raw)
  To: stracelabs; +Cc: cocci

> Unfortunately, it doesn't work.

A bit more information would be nice for the explanation of the failure reason.

I assume that you are still looking for better support of format strings
with several conversion parameters.


> But, I am working on some solutions using Python.

I am curious how corresponding approaches will evolve further.


> But, Is it possible to rename/handle the *expression list?*

Renaming can not be performed for the list. Data processing can become more
interesting for the managed elements, can't it?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-04  0:21                         ` Strace Labs
@ 2019-12-06 19:36                           ` Markus Elfring
  2019-12-07  7:49                           ` Markus Elfring
  1 sibling, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-12-06 19:36 UTC (permalink / raw)
  To: stracelabs; +Cc: cocci

> Therefore, I could find the %fmt and replace by whatever I want based on
> the *expression-list. *currently struggled on that.

Are you also looking for direct support of such expression lists by
Coccinelle's programming interface (see also “man coccilib”)?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-04  6:47                         ` Julia Lawall
@ 2019-12-06 19:44                           ` Markus Elfring
  0 siblings, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-12-06 19:44 UTC (permalink / raw)
  To: Julia Lawall, stracelabs; +Cc: cocci

> Could you fix up the expression list first? Then you can write a rule like
>
> char[] s;
>
> fn(s, ...,
> - oldcode
> + newcode
> ,...)

Can it be that such a transformation approach will only work if the number
of passed function parameters will be fixed?

How should the data processing work with variable arguments?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Changing format string usage with SmPL?
  2019-12-04  0:21                         ` Strace Labs
  2019-12-06 19:36                           ` Markus Elfring
@ 2019-12-07  7:49                           ` Markus Elfring
  1 sibling, 0 replies; 31+ messages in thread
From: Markus Elfring @ 2019-12-07  7:49 UTC (permalink / raw)
  To: stracelabs; +Cc: cocci

> After some research, I could create a Python function called
> fmt_replace_by_pos() to replace the %fmt by the Indice position.

I imagine that this development direction can become more interesting.

Now I would like to point a few implementation details out
which can be improved in the shown SmPL script.


> REG = re.compile('([^%]|%%)*(%[^%])')

* I suggest to move the compilation for such a regular expression
  into the initialisation rule.

* I find the need for the alternation unclear.

* The data processing approach can become nicer if Coccinelle's programming interface
  would support also format lists directly.


> retval[i] = { 'idx': idx, 'fmt': fmt }

I wonder about the need for a separate Python dictionary here.


> print("** ERROR: Something wrong in fmt_replace_by_pos():\n
> {}\n".format(str(e)))

Would you like to use the output channel “standard error” instead?


> @main depends on s1 && r1@

The explicit dependency specification can probably be omitted.

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, back to index

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28  2:11 [Cocci] Replacing printf/format calls based on the data-type Strace Labs
2019-11-28  7:07 ` Julia Lawall
2019-11-28 17:45   ` Strace Labs
2019-11-29 14:48   ` [Cocci] Replacing printf() parameters according to used data types Markus Elfring
2019-11-28  7:50 ` Markus Elfring
2019-11-29  0:35   ` Jorge Pereira
2019-11-29  8:29     ` Markus Elfring
2019-11-29 10:57       ` Strace Labs
2019-11-29 12:33         ` Markus Elfring
2019-11-29 14:47           ` Strace Labs
2019-11-29 16:08             ` Markus Elfring
2019-11-29 17:19               ` Strace Labs
2019-11-29 17:45                 ` Markus Elfring
2019-11-29 20:55             ` Julia Lawall
2019-11-30  2:25               ` Strace Labs
2019-11-30  6:35                 ` Julia Lawall
2019-11-30  8:46                 ` Markus Elfring
2019-12-01  8:00                 ` [Cocci] Changing format string usage with SmPL? Markus Elfring
2019-12-03  3:30                   ` Strace Labs
2019-12-03  5:18                     ` Julia Lawall
2019-12-03 13:28                       ` Markus Elfring
2019-12-03 15:43                       ` [Cocci] Generation of expression lists by SmPL script rules? Markus Elfring
2019-12-03 17:28                       ` [Cocci] Changing format string usage with SmPL? Strace Labs
2019-12-04  0:21                         ` Strace Labs
2019-12-06 19:36                           ` Markus Elfring
2019-12-07  7:49                           ` Markus Elfring
2019-12-04  6:47                         ` Julia Lawall
2019-12-06 19:44                           ` Markus Elfring
2019-12-06 19:20                         ` Markus Elfring
2019-12-03 10:01                     ` Markus Elfring
2019-11-30 15:11               ` [Cocci] Replacing printf() parameters according to used data types Markus Elfring

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git