Coccinelle archive on lore.kernel.org
 help / color / Atom feed
From: Strace Labs <stracelabs@gmail.com>
To: Markus Elfring <Markus.Elfring@web.de>,
	Julia Lawall <julia.lawall@inria.fr>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] Replacing printf() parameters according to used data types
Date: Fri, 29 Nov 2019 12:47:45 -0200
Message-ID: <CABvP5W0kVE+yBYa7gWLfsegb75fMyMcLSDbsnFUGRnnVoRLtDQ@mail.gmail.com> (raw)
In-Reply-To: <02fa7455-e76e-7d7d-0d64-41b2803a8025@web.de>

[-- 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

  reply index

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=CABvP5W0kVE+yBYa7gWLfsegb75fMyMcLSDbsnFUGRnnVoRLtDQ@mail.gmail.com \
    --to=stracelabs@gmail.com \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@systeme.lip6.fr \
    --cc=julia.lawall@inria.fr \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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