All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Elia Pinto <gitter.spiros@gmail.com>, cocci@inria.fr
Subject: Re: [cocci] Fixing the adjustment of variable declarations
Date: Wed, 9 Nov 2022 21:21:51 +0100	[thread overview]
Message-ID: <516d8b97-907f-5a7b-41af-ff162ffe7316@web.de> (raw)
In-Reply-To: <CA+EOSBm7wxOoXmhbAP7YhTDXJxNQJJ6QRU8Rb47QV_XmvyyaGg@mail.gmail.com>

> The semantic patch works on almost any code. However, it produces an
> incorrect transformation on the refs.c file
> https://github.com/git/git/blob/master/refs.c
>
> Doing
>
> spatch --sp-file sp.cocci refs.c -o refs.after.c
>
> An incorrect transformation is created:
> which erroneously changes the type of the variable r.
>
> Is it a bug


You found a detail which will hopefully trigger further collateral evolution.

Another test result:

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch suggestion_for_Elia_Pinto-20221109.cocci expand_ref-test.c
…
@@ -1,6 +1,6 @@
 void my_expand_ref_variant(void)
 {
- const char **p, *r;
- for (p = ref_rev_parse_rules; *p; ++p)
+ const char **r;
+ for (const char **p = ref_rev_parse_rules; *p; ++p)
  { /* loop content */ }
 }


> or should the semantic patch be done better?

How do you think about software development possibilities with the following
script variant for the semantic patch language?


@movement@
type T;
identifier I;
statement S;
expression E1, E2, E3;
@@
(
-T I = E1;
 ... when != I
 for (
+     T
      I = E1; E2; E3
     )
 S
 ... when != I
|
-T I;
 ... when != I
 for (
+     T
      I = E1; E2; E3
     )
 S
 ... when != I
)


Regards,
Markus

  parent reply	other threads:[~2022-11-09 20:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 11:42 [cocci] Possible bug in a semantic patch Elia Pinto
2022-11-09 11:49 ` Julia Lawall
2022-11-09 20:21 ` Markus Elfring [this message]
2022-11-11 19:10   ` [cocci] Reducing the scope for variables with SmPL Markus Elfring
2022-11-12  9:42   ` [cocci] Fixing the adjustment of variable declarations Markus Elfring
2022-11-12 10:38     ` Markus Elfring
2022-11-12 11:17       ` Julia Lawall
2022-11-12 11:45         ` Markus Elfring
2022-11-13 10:30     ` Markus Elfring
2022-11-13 10:36       ` Julia Lawall
2022-11-13 12:26         ` Markus Elfring
2022-11-13 14:10           ` Julia Lawall
2022-11-13 14:23             ` Markus Elfring
2022-11-13 14:28               ` Julia Lawall
2022-11-13 14:55                 ` Markus Elfring
2022-11-13 15:19                   ` Julia Lawall
2022-11-13 15:36                     ` Markus Elfring

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=516d8b97-907f-5a7b-41af-ff162ffe7316@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=gitter.spiros@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.