Backports Archive mirror
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: cocci@systeme.lip6.fr
Cc: backports@vger.kernel.org
Subject: Re: Finding and replacing a struct inside another struct
Date: Wed, 22 Aug 2018 12:38:30 +0300	[thread overview]
Message-ID: <74f2d0049e235c1bd02f94a83cdaf00eaf401174.camel@coelho.fi> (raw)
In-Reply-To: <ea981773c0caca06958f6dc5f5238954b520056b.camel@coelho.fi>

On Wed, 2018-08-22 at 12:30 +0300, Luca Coelho wrote:
> Hi,
> 
> I need some help again. :)
> 
> I have a struct (cfg80211_crypto_settings) that contains a new
> element
> that I want to substitute for a function call
> (cfg_control_port_over_nl80211).  But this struct appears inside
> another struct.
> 
> So I tried this:
> 
> First I try to find a struct that contains the struct I want (with
> the
> @parent_child@ rule):
> 
> @parent_child@
> identifier child;
> identifier parent_type;
> @@
> struct parent_type
> {
> ...
> struct cfg80211_crypto_settings child;
> ...
> }
> 
> And then I try to match usage of the parent struct that I found:
> 
> @@
> identifier parent_child.child;
> identifier parent_child.parent_type;
> identifier p;
> @@
> struct parent_type *p;
> <...
> -p.child.control_over_nl80211
> +cfg_control_port_over_nl80211(&p.child)
> ...>

Ah, I think I found the problem... I was using p.child, but I was
defining p as a pointer!

I guess I should have this instead:

@@
identifier parent_child.child;
identifier parent_child.parent_type;
ide
ntifier p;
@@
struct parent_type *p;
<...
-p->child.control_over_nl80211
+cf
g_control_port_over_nl80211(&p->child)
...>

--
Luca.

--
To unsubscribe from this list: send the line "unsubscribe backports" in

  reply	other threads:[~2018-08-22 13:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-22  9:30 Finding and replacing a struct inside another struct Luca Coelho
2018-08-22  9:38 ` Luca Coelho [this message]
2018-08-22 10:20   ` Luca Coelho
2018-08-22 10:54     ` [Cocci] " Julia Lawall
2018-08-22 10:52 ` 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=74f2d0049e235c1bd02f94a83cdaf00eaf401174.camel@coelho.fi \
    --to=luca@coelho.fi \
    --cc=backports@vger.kernel.org \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).