All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] Spatch corrupting struct variable
@ 2023-12-21  8:44 Ilpo Järvinen
  2023-12-21  9:01 ` Julia Lawall
  2023-12-21 11:16 ` [cocci] Transforming data structure accesses with SmPL Markus Elfring
  0 siblings, 2 replies; 6+ messages in thread
From: Ilpo Järvinen @ 2023-12-21  8:44 UTC (permalink / raw)
  To: cocci

Hi all,

I'm at total loss what coccinelle/spatch is trying to do here:

@@
struct resource *res;
expression size;
@@
- res->end = res->start + size - 1;
+ resource_set_size(res, size);

Spatching against Linux kernel tree results in this corruption:

HANDLING: drivers/bus/fsl-mc/fsl-mc-bus.c
diff = 
diff -u -p a/fsl-mc-bus.c b/fsl-mc-bus.c
--- a/fsl-mc-bus.c
+++ b/fsl-mc-bus.c
@@ -736,7 +736,7 @@ static int fsl_mc_device_get_mmio_region
                        goto error_cleanup_regions;
                }
 
-               regions[i].end = regions[i].start + region_desc.size - 1;
+               resource_set_size(regions, region_desc.size);
                regions[i].name = "fsl-mc object MMIO region";
                regions[i].flags = region_desc.flags & IORESOURCE_BITS;
                regions[i].flags |= IORESOURCE_MEM;

??? How did that [i] vanish from regions? Why spatch thought . and -> are 
equal?

$ spatch --version
spatch version 1.1.0 compiled with OCaml version 4.11.1
Flags passed to the configure script: --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --enable-ocaml --enable-python --enable-opt
OCaml scripting support: yes
Python scripting support: yes
Syntax of regular expressions: PCRE


--
 i.


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

end of thread, other threads:[~2023-12-21 12:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-21  8:44 [cocci] Spatch corrupting struct variable Ilpo Järvinen
2023-12-21  9:01 ` Julia Lawall
2023-12-21  9:44   ` Ilpo Järvinen
2023-12-21 11:16 ` [cocci] Transforming data structure accesses with SmPL Markus Elfring
     [not found]   ` <80d307c-e3f7-8f84-78d4-b19113f441f7@linux.intel.com>
2023-12-21 12:52     ` Markus Elfring
2023-12-21 12:57       ` Julia Lawall

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.