Coccinelle Archive on lore.kernel.org
 help / color / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] Adjusting some calls according to pass-through functions
Date: Sun, 29 Nov 2020 13:25:02 +0100 (CET)
Message-ID: <alpine.DEB.2.22.394.2011291323290.2671@hadrien> (raw)
In-Reply-To: <3b134eb3-7ccf-454c-3266-64cfaec5a307@web.de>


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



On Sun, 29 Nov 2020, Markus Elfring wrote:

> >> @Replacement@
> >> expression action, input1, input2, input3, target;
> >> identifier gs;
> >> @@
> >> -\( g_string_assign@gs \| g_string_append@gs \| g_string_append_c@gs \) (target, input1);
> >>  action (
> >> +        gs (
> >>              target
> >> +            , input1)
> >>              ,
> >> (            input2, input3
> >> |            input2
> >> )       );
> >
> > I find this way of writing disjunctions really unreadable.
>
> I am using different coding styles for SmPL disjunctions because of specific reasons.
>
>
> > You are saving some precious whitespace characters at the cost of making
> > any distinction between what is obligatory and what is optional.
>
> I tend to increase such distinction possibilities.
>
>
> >> The implementation of a function like “format_column_declaration” contains
> >> the following statements.
> >> https://gitlab.gnome.org/GNOME/evolution-data-server/-/blob/3de7ea5fdb5d5db4a097a4d888d77bd2778c1c30/src/addressbook/libedata-book/e-book-sqlite.c#L1898
> >>
> >> 	g_string_append (string, info->name);
> >> 	g_string_append_c (string, ' ');
> >>
> >> 	g_string_append (string, info->type);
> >>
> >> 	if (info->extra) {
> >> 		g_string_append_c (string, ' ');
> >> 		g_string_append (string, info->extra);
> >> 	}
> >
> > The rule matches for example on the first line and on the second line.
>
> Yes. - The transformation approach should work so in principle.
>
>
> > The match on the first line makes a change in the second line.  The match
> > on the second line removes the second line.  This is a conflict,
> > as reported.
>
> I imagine that the error message can be improved somehow.
>
>
> > The problem would be solved in this case by making two separate rules.
>
> I find this suggestion unclear at the moment.

A rule for each of the functions you have in the big disjunction you have
on the first line of your rule.  But it only helps in your case because in
your C code, the first two lines have different function names.

>
> Two changes should be performed in combination for a code replacement.
> How should a separation help then?
>
> Can the shown change pattern be applied recursively?

You can follow the example in demos/iteration.cocci.

julia

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

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

  parent reply index

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-28 17:21 [Cocci] Checking the influence of an omitted semicolon on a code adjustment Markus Elfring
2020-11-28 17:45 ` Julia Lawall
2020-11-28 18:56   ` Markus Elfring
2020-11-28 19:00     ` Julia Lawall
2020-11-28 19:11       ` Markus Elfring
2020-11-28 19:49         ` Julia Lawall
2020-11-28 20:04           ` Markus Elfring
     [not found]             ` <0148bab2-6148-e403-985d-df2e7cade490@web.de>
2020-11-29 11:54               ` [Cocci] Adjusting some calls according to pass-through functions Julia Lawall
     [not found]                 ` <3b134eb3-7ccf-454c-3266-64cfaec5a307@web.de>
2020-11-29 12:25                   ` Julia Lawall [this message]
     [not found]                     ` <978f08c3-21ed-d434-d2ef-163335ae990e@web.de>
2020-11-29 12:52                       ` Julia Lawall
     [not found]                         ` <1dc8f835-11b1-0ec0-8ba4-45cffdf13465@web.de>
2020-11-29 13:47                           ` Julia Lawall
     [not found]                     ` <cb266001-ed38-da76-389c-5a7bf7f59e9e@web.de>
2020-11-29 13:43                       ` Julia Lawall
     [not found]                         ` <79d4245d-6f34-7b8d-d632-99afcc1d228a@web.de>
2020-11-29 14:44                           ` Julia Lawall
     [not found]                             ` <beeb673b-65b5-fdef-f300-c86a4bd0abc7@web.de>
2020-11-29 15:18                               ` Julia Lawall
     [not found]                                 ` <cf0e2d68-d76b-5892-b97e-36a270732028@web.de>
2020-11-29 15:52                                   ` Julia Lawall
     [not found]                                     ` <b548f18b-2fa7-1fcf-5bbb-3011d8a270e5@web.de>
2020-11-29 16:24                                       ` Julia Lawall

Reply instructions:

You may reply publicly 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=alpine.DEB.2.22.394.2011291323290.2671@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@systeme.lip6.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