Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Elia Pinto <gitter.spiros@gmail.com>
To: cocci@inria.fr, cocci@systeme.lip6.fr
Subject: [cocci] Possible bug in a semantic patch
Date: Wed, 9 Nov 2022 12:42:18 +0100	[thread overview]
Message-ID: <CA+EOSBm7wxOoXmhbAP7YhTDXJxNQJJ6QRU8Rb47QV_XmvyyaGg@mail.gmail.com> (raw)

Greetings to all

I am trying to apply this semantic patch

****sp.cocci file ***********************************

/ * SPDX-License-Identifier: LGPL-2.1-or-later * /

@@

type T;

identifier I;

statement S;

expression E1, E2, E3;

@@



- T I;

  ... when != I

- for (I = E1; E2; E3)

+ for (T I = E1; E2; E3)

    S

  ... when != I



****************************************

to this repository

https://github.com/git/git.git

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:

diff -Nu refs.c refs.after.c

.....

@@ -733.12 +730.12 @@

 int expand_ref (struct repository * repo, const char * str, int len,

               struct object_id * oid, char ** ref)

 {

- const char ** p, * r;

+ const char ** r;       ç========================= NOTE



......

which erroneously changes the type of the variable r.

Is it a bug or should the semantic patch be done better?

Thanks in advance



Elia

             reply	other threads:[~2022-11-09 11:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 11:42 Elia Pinto [this message]
2022-11-09 11:49 ` [cocci] Possible bug in a semantic patch Julia Lawall
2022-11-09 20:21 ` [cocci] Fixing the adjustment of variable declarations Markus Elfring
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=CA+EOSBm7wxOoXmhbAP7YhTDXJxNQJJ6QRU8Rb47QV_XmvyyaGg@mail.gmail.com \
    --to=gitter.spiros@gmail.com \
    --cc=cocci@inria.fr \
    --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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).