From: Palani kodeswaran <palani.k@gmail.com>
To: cocci@inria.fr
Subject: [cocci] Replacing struct field references with field references from a different struct
Date: Mon, 8 Aug 2022 16:06:28 +0530 [thread overview]
Message-ID: <CAASoEDTjytDuj6quFJpmhcppBZxEUXpTOSk5eZDhS8gUm6hAzA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 920 bytes --]
Hello,
I am trying to replace field references inside a struct of given type with
references from a different struct (that is passed as an input parameter
for a function). I have the following coccinelle rule that is not working
@vlan@
identifier p,c,fn;
type t;
struct vlan_hdr *v;
@@
t fn(struct xdp_md *ctx){
...
- v->h_vlan_encapsulated_proto
+ ctx->vlan_proto
}
However, I have a similar rule that works for another struct type. I am
not sure what I am missing in the above rule compared to the one below. The
only difference I can see in the source code is that the above rule needs
to transform a piece of code inside an if block. I believe the three
ellipsis (...) would handle that anyways?
@rule3@
identifier p,c,fn;
type t;
struct ethhdr *e;
@@
t fn(struct xdp_md *ctx){
...
- e->h_proto
+ ctx->protocol
...
}
Appreciate your help.
Regards,
Palani.
[-- Attachment #2: Type: text/html, Size: 1360 bytes --]
next reply other threads:[~2022-08-08 10:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-08 10:36 Palani kodeswaran [this message]
2022-08-08 11:56 ` [cocci] Replacing struct field references with field references from a different struct 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=CAASoEDTjytDuj6quFJpmhcppBZxEUXpTOSk5eZDhS8gUm6hAzA@mail.gmail.com \
--to=palani.k@gmail.com \
--cc=cocci@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 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).