cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [cocci] Possible bug in a semantic patch
@ 2022-11-09 11:42 Elia Pinto
  2022-11-09 11:49 ` Julia Lawall
  2022-11-09 20:21 ` [cocci] Fixing the adjustment of variable declarations Markus Elfring
  0 siblings, 2 replies; 17+ messages in thread
From: Elia Pinto @ 2022-11-09 11:42 UTC (permalink / raw)
  To: cocci, cocci

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-11-13 15:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

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 NNTP newsgroup(s).