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=-0.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,SPF_HELO_NONE, SPF_PASS autolearn=no 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 24CC4C432C0 for ; Tue, 3 Dec 2019 03:31:18 +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 4CAB020656 for ; Tue, 3 Dec 2019 03:31:16 +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="EIMInjSn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CAB020656 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 xB33UsXa015380; Tue, 3 Dec 2019 04:30:54 +0100 (CET) Received: from systeme.lip6.fr (systeme.lip6.fr [127.0.0.1]) by systeme.lip6.fr (Postfix) with ESMTP id C94A777D7; Tue, 3 Dec 2019 04:30:54 +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 8D7CD4386 for ; Tue, 3 Dec 2019 04:30:52 +0100 (CET) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20:0:0:0:436] (may be forged)) by isis.lip6.fr (8.15.2/8.15.2) with ESMTP id xB33UpDH021704 for ; Tue, 3 Dec 2019 04:30:51 +0100 (CET) Received: by mail-wr1-x436.google.com with SMTP id z7so1763053wrl.13 for ; Mon, 02 Dec 2019 19:30:51 -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=jHlLBYB0mn75meDeuCa49CKzN9c0YYxUm264H50jka4=; b=EIMInjSnnH4C/pvnm7LOZqNXi+E1J8cqCJR8pgJza3ki7sfyO4AKAIQaOeugObj2ki zM6XQwHWg7XCXkX9GxJ5QDXQnSJlPQfPhEoByR4poc5Ya8gq+napehonMdeaIxV8ivcE Lznp+XeWXyy5LDjDyV+JFImcdpRqEW16cN6iX6t1fhaeKfXXrRDlp318oVHgN+W3IPEU iG480uG38pahvMbxiyDWu+GFbTruQWFIHve6l/RoB2F2R+03wXC6+DCuhEJZ41EOw8mG i4T7aJFf8bR42EnKvSk5pJe7PKn/zQci8pXCchVXBjjcJ9HZ4qRvMlTZ/C8URU6dwCsN e64Q== 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=jHlLBYB0mn75meDeuCa49CKzN9c0YYxUm264H50jka4=; b=UWuO6zzmX6s5XmyMs/RYXfLpjodlrFvoymU5YOFyFmRwwPMppBTgqRtNwHoLCrRdId iTBrgReV8pKABTO7snh2HEBPnefTYEtG0UTIXb73oZ9u46TsuKMUy8qBOX6ja1Au/xnw 4VHSRHtvJi/8avxsBNLp7gOQ7gWF2SfoRS5+nU32qItJ88lSsmi7+sMDKCmJzdujM3y8 fgvu6vyz0kDjadBqK1MDYReBL+PelQxDh75JBz38BsUXD3aBsUoOdnsRmW/MkJ+o6UhJ 3AqIVxEeJ2a3accEyOuAbyAyhMb1H1RjWQG1dQlSkAHaOy9CENyrANOcgOpLrCVO7gJJ ZQIw== X-Gm-Message-State: APjAAAWWj6WI+vslCn7TRT5R/61MdLFBL71LRdQQwLvudwIvbEs/F0Gy dIjx8nXEUGtGR6rWBTDQ347D9Fj5jYZ4tyekTCA= X-Google-Smtp-Source: APXvYqymmcqwF3FrA+9QYi1MTVO+BluQLhgeZQ4Q5te8EiVjtazVj0mSI1EVzRQIZOVonGXsnS+HgV3zNTLUeiStnXk= X-Received: by 2002:a05:6000:1241:: with SMTP id j1mr2709487wrx.26.1575343850834; Mon, 02 Dec 2019 19:30:50 -0800 (PST) MIME-Version: 1.0 References: <509ffde0-ec26-a58c-d424-6910bc8e7473@web.de> <02fa7455-e76e-7d7d-0d64-41b2803a8025@web.de> <0c03f84d-a05b-2811-96aa-6f82541fb8a3@web.de> In-Reply-To: <0c03f84d-a05b-2811-96aa-6f82541fb8a3@web.de> From: Strace Labs Date: Tue, 3 Dec 2019 01:30:14 -0200 Message-ID: To: Markus Elfring X-Greylist: Sender IP whitelisted, Sender e-mail whitelisted, not delayed by milter-greylist-4.4.3 (isis.lip6.fr [132.227.60.2]); Tue, 03 Dec 2019 04:30:55 +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]); Tue, 03 Dec 2019 04:30:51 +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] Changing format string usage with SmPL? 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="===============2076038904==" Sender: cocci-bounces@systeme.lip6.fr Errors-To: cocci-bounces@systeme.lip6.fr --===============2076038904== Content-Type: multipart/alternative; boundary="000000000000a0ce750598c4527e" --000000000000a0ce750598c4527e Content-Type: text/plain; charset="UTF-8" On Sun, Dec 1, 2019 at 6:00 AM Markus Elfring 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 *, 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 *, 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 > --000000000000a0ce750598c4527e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Dec 1, 2019 at 6:00 AM Markus Elf= ring <Markus.Elfring@web.de= > wrote:
> Basically, I intend to replace alls "%s&qu= ot; called with "mydata->name" by "%m" with "my= data" 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 str= ings?


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 t= he tool could detect "%s" called with "mydata->name"= and then replace by "%m" and remove the "->name"

e.g: Once if we have:

int f= oo() {
=C2=A0 int id;
=C2=A0 struct mydata h1, *h2, s1, *s2;
=C2= =A0 char *city =3D "Hello";
=C2=A0 my_printf("%s", s= 2->name);
=C2=A0 my_printf("hi hi %s gggg", h1.name);
=C2=A0 my_printf("1234 %d %s @ %d = %s=C2=A0| %s -> city=3D%s", id, s1.name, 12, (*h2).name, h2->name, city);=
=C2=A0 my_printf("aaaa %s hhhhh", h2->name);
=C2=A0 my_= printf("%s", city);
}

Then= , replace by:

int foo() {
=C2=A0 int id;=C2=A0 struct mydata h1, *h2, s1, *s2;
=C2=A0 char *city =3D "Hel= lo";
=C2=A0 my_printf("%m", s2);
=C2=A0 my_p= rintf("hi hi %s gggg", &h1);
=C2=A0 my_printf("12= 34 %d %m=C2=A0@ %d %m=C2=A0| %m=C2=A0-> city=3D%s&q= uot;, id, s1.name, 12, (*h2).name<= /b>, h2->name, city);
=C2=A0 my_printf("aaaa %s hhhhh&= quot;, h2);
=C2=A0 my_printf("%s", city);
}<= /div>

But, I've read again the other samples a= nd the documentation. therefore, I didn't figure out how it should be. = btw, thank you Julia for the suggestion performing the Ocalm/make_expr/r= eplace. (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 sa= id, it should be only if the "%s" was declared to use "mydat= a->name".

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

Regards,
Markus
--000000000000a0ce750598c4527e-- --===============2076038904== 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 --===============2076038904==--