From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7542FC432C0 for ; Fri, 29 Nov 2019 14:48:45 +0000 (UTC) Received: from isis.lip6.fr (isis.lip6.fr [132.227.60.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2B69217AB for ; Fri, 29 Nov 2019 14:48:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KR1LSgrN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2B69217AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=cocci-bounces@systeme.lip6.fr Received: from systeme.lip6.fr (systeme.lip6.fr [132.227.104.7]) by isis.lip6.fr (8.15.2/8.15.2) with ESMTP id xATEmOAg018964; Fri, 29 Nov 2019 15:48:24 +0100 (CET) Received: from systeme.lip6.fr (systeme.lip6.fr [127.0.0.1]) by systeme.lip6.fr (Postfix) with ESMTP id A1D2177E4; Fri, 29 Nov 2019 15:48:24 +0100 (CET) Received: from isis.lip6.fr (isis.lip6.fr [132.227.60.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by systeme.lip6.fr (Postfix) with ESMTPS id BFB9577D2 for ; Fri, 29 Nov 2019 15:48:22 +0100 (CET) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20:0:0:0:42a] (may be forged)) by isis.lip6.fr (8.15.2/8.15.2) with ESMTP id xATEmL76024151 for ; Fri, 29 Nov 2019 15:48:21 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id b18so35510828wrj.8 for ; Fri, 29 Nov 2019 06:48:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/1IslWXQAzWn2ZfD555bdWvOqItUqH+XDjMeHFUT6Dw=; b=KR1LSgrN7lZM8AkKqzvmlMcZyT7v671mwo2EEwyP2Niep+ds8b21uPqdPQ+NOC8WI2 eGXd9XjhJ84uazwYNwWOxZP+VBqxW05nV4nbwmkaoPk7iBr6XYQO/lZJTttAfprrbad6 LA6eAiQdAI7xdHv5vA5gT1P/Bfx1PwvAzV7y3DI1cxmX4qpka16HkgS5HVRRzQtYve6U rOujvsC07BtVsXvbTG1c9af5r481CMSPZMZDh1agl0ZHs1/9okyHes1n6tV2ihZL5RoL WBnF2MNYOqnFNK575yW7GW7XoRw7aJI/qAteMizlOVdpA6CtyKkUm79G0vhiF4KT6/OF FmAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/1IslWXQAzWn2ZfD555bdWvOqItUqH+XDjMeHFUT6Dw=; b=JlV/hyP+PF4cclgWIVpMyLNW7dlbfYKnHLQXuoOzrun7QyHynxa87c0KW+3NNkzFVR wOBNc9mHbTk00lQy0KSHNVdv3eOtXrerrtI9D8V7X89PTcWpqYQT5FJusp22vjvjRQ1G YhtixPpAMkOKva0RQv8C/4wlRAvs6/5DAZMC3w2KHf2IkU7Ud/HkmBpKzoHv0GNt3buJ TcqcBvBK5i/nu6/J1I4TaQyRjoAj06ODOrk1JMOTRj5w+//W/l6NjKd/vTV5i3lwyeAS xwagPaDEr3Lj+8dGUWy5QA4GEy5bb755nhjtOovLq6iEKrAbRLJ9kIdSWP6Uyn8AkFtf dhbQ== X-Gm-Message-State: APjAAAUgru9D9yhOkLKARlM7FEzzmeAlGLcH4jMogWjOdlmdPPjVzu5V Ll4zEJXfo7hxRpjrPcgkBA1n29yjfRF0QKgIUQY= X-Google-Smtp-Source: APXvYqxYHk+2bv3Bq+Ei07HvJKw/9xqgfA4eOQxpQUKKTwtPs+zxCIWMpHYnJiEea93Yzb/pUH8xBKk9SQq3l5X0fdw= X-Received: by 2002:a5d:6408:: with SMTP id z8mr9287935wru.122.1575038901217; Fri, 29 Nov 2019 06:48:21 -0800 (PST) MIME-Version: 1.0 References: <509ffde0-ec26-a58c-d424-6910bc8e7473@web.de> <02fa7455-e76e-7d7d-0d64-41b2803a8025@web.de> In-Reply-To: <02fa7455-e76e-7d7d-0d64-41b2803a8025@web.de> From: Strace Labs Date: Fri, 29 Nov 2019 12:47:45 -0200 Message-ID: To: Markus Elfring , Julia Lawall X-Greylist: Sender IP whitelisted, Sender e-mail whitelisted, not delayed by milter-greylist-4.4.3 (isis.lip6.fr [132.227.60.2]); Fri, 29 Nov 2019 15:48:24 +0100 (CET) X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.4.3 (isis.lip6.fr [IPv6:2001:660:3302:283c:0:0:0:2]); Fri, 29 Nov 2019 15:48:21 +0100 (CET) X-Scanned-By: MIMEDefang 2.78 on 132.227.60.2 X-Scanned-By: MIMEDefang 2.78 Cc: cocci@systeme.lip6.fr Subject: Re: [Cocci] Replacing printf() parameters according to used data types X-BeenThere: cocci@systeme.lip6.fr X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0129876294==" Sender: cocci-bounces@systeme.lip6.fr Errors-To: cocci-bounces@systeme.lip6.fr --===============0129876294== Content-Type: multipart/alternative; boundary="00000000000036ef8505987d52d9" --00000000000036ef8505987d52d9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Markus, so, that suggestion works the same as my previous shared statement. but, only for calls like: *my_printf("%s", h1.name );*, not for *my_printf("%d here also, tt=3D%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=3D%m\n", id, h2); my_printf("%d here also, tt=3D%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 don't know, No one in the world knows. =F0=9F=98=82 On Fri, Nov 29, 2019 at 10:33 AM Markus Elfring 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 =3D~ "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 =E2=80=9CPropagating values back from Py= thon > script > to SmPL rule with other metavariable type than =E2=80=9Cidentifier=E2=80= =9D=E2=80=9D. > https://github.com/coccinelle/coccinelle/issues/86 > > Regards, > Markus > --00000000000036ef8505987d52d9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Markus,

so, that sugge= stion works the same as my previous shared statement. but, only for calls l= ike:=C2=A0my_printf("%s", h1.name);,
not for=C2=A0my_printf("%d he= re also, tt=3D%s | %s and %m\n", id, h2->name, h2->name, s2);

e.g:

Code sample
<= br>int foo() {
int id;
struct mydata h1, *= h2, s1, *s2;

// works fine
my_printf("%s", h1.name);
my_printf("%s&quo= t;, 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=3D%m\n", id, h2);
my_printf("%d here also, t= t=3D%s | %s and %m\n", id, h2->name, h2->name, s2);
}
<= br>

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 th= ink that if=C2=A0@Jul= ia Lawall=C2=A0don't know, No one in the world knows.=C2=A0=F0=9F= =98=82



On Fri, Nov 29, 2019 at 10:33 AM M= arkus Elfring <Markus.Elfring@web.de> wrote:
>>. Did you try out to work with SmPL ellipses= and disjunctions for this purpose?=C2=A0
> =C2=A0
> I didn't it, do you have any suggestions or sample that is it poss= ible
> 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 =3D~ "s";
@@
=C2=A0my_printf(
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "%@F@"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "%m"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0,
(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SMD
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.name
|
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SMDP
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0->name
)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 );



> I mean, the Coccinelle/Python support.

This programming interface contains also open issues for further considerat= ions
as you can see from a topic like =E2=80=9CPropagating values back from Pyth= on script
to SmPL rule with other metavariable type than =E2=80=9Cidentifier=E2=80=9D= =E2=80=9D.
https://github.com/coccinelle/coccinelle/issues/86=

Regards,
Markus
--00000000000036ef8505987d52d9-- --===============0129876294== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci --===============0129876294==--