Coccinelle Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: rusty@rustcorp.com.au (Rusty Russell)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Simple replacement of an expression of given type?
Date: Sat, 21 Jun 2014 16:36:29 +0930	[thread overview]
Message-ID: <87fviyu4ga.fsf@rustcorp.com.au> (raw)
In-Reply-To: <alpine.DEB.2.02.1406210822590.2074@localhost6.localdomain6>

Julia Lawall <julia.lawall@lip6.fr> writes:
> On Sat, 21 Jun 2014, 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 :(
>
> You are already working on expressions.  The problem is that sometimes 
> Coccinelle doesn't know what is the type of te->block.  To give it the 
> most possible amount of informations, you can give the options
>
> --recursive-includes --relax-include-path

Ah, thanks for the explanation, and indeed, that worked perfectly.

And thanks Julia and Lars for your quick responses!

Cheers,
Rusty.

      reply	other threads:[~2014-06-21  7:06 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
2014-06-21  6:28 ` Julia Lawall
2014-06-21  7:06   ` Rusty Russell [this message]

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=87fviyu4ga.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --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