From: lars@metafoo.de (Lars-Peter Clausen)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Simple replacement of an expression of given type?
Date: Sat, 21 Jun 2014 08:27:11 +0200 [thread overview]
Message-ID: <53A525BF.5060205@metafoo.de> (raw)
In-Reply-To: <87y4wrtam6.fsf@rustcorp.com.au>
On 06/21/2014 01:38 AM, Rusty Russell wrote:
> Hi!
>
> In my current project, I moved a field from a structure
> (struct block) into another network-endian structure. I used the
> following patch.cocci to do the fixups:
>
> @ rule1 @
> struct block *b;
> @@
>
> - b->blocknum
> + le32_to_cpu(b->hdr->depth)
>
> It got 99%, but it missed the two cases where b was actually in another
> structure, ie. "te->block->blocknum".
>
> I *think* this is because I want to substitute any expression of type
> struct block *, rather than only identifiers?
>
> But I couldn't understand the documentation enough to do this :(
This should work. But by default coccinelle does not parse global headers,
so if the struct for te is defined in a global header it won't know that
te->block is of type 'struct block *'. If that is the case try to run it
with --all-includes
- Lars
next prev parent reply other threads:[~2014-06-21 6:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 23:38 [Cocci] Simple replacement of an expression of given type? Rusty Russell
2014-06-21 6:27 ` Lars-Peter Clausen [this message]
2014-06-21 6:28 ` Julia Lawall
2014-06-21 7:06 ` Rusty Russell
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=53A525BF.5060205@metafoo.de \
--to=lars@metafoo.de \
--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