From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: cocci@inria.fr
Subject: Re: [cocci] Spatch corrupting struct variable
Date: Thu, 21 Dec 2023 11:44:31 +0200 (EET) [thread overview]
Message-ID: <7dde285a-3255-b58b-43ca-8a185e42fc10@linux.intel.com> (raw)
In-Reply-To: <155979e7-bf8-a7da-4762-749cb9eba1d@inria.fr>
[-- Attachment #1: Type: text/plain, Size: 1452 bytes --]
On Thu, 21 Dec 2023, Julia Lawall wrote:
> On Thu, 21 Dec 2023, Ilpo Järvinen wrote:
>
> > 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?
>
> There is an isomorphism that does that. Maybe it should be removed...
>
> In any case, you can put @disable ptr_to_array@ in place of the initial @@
> in your rule. Or if your rule has a name, put the disable ptr_to_array
> after the name.
Thanks for the quick reply. Adding disable ptr_to_array indeed helped. :-)
--
i.
next prev parent reply other threads:[~2023-12-21 9:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=7dde285a-3255-b58b-43ca-8a185e42fc10@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=cocci@inria.fr \
--cc=julia.lawall@inria.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 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.