From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] remove typedefs from struct
Date: Sat, 14 Feb 2015 19:56:28 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.10.1502141955040.6185@hadrien> (raw)
In-Reply-To: <2bb2afa2a75f464b900af8506ddc84dd@BN1BFFO11FD029.protection.gbl>
On Sat, 14 Feb 2015, S?ren Brinkmann wrote:
> Hi,
>
> I'm just getting my feet wet with coccinelle, so I'm probably missing
> something really obvious in my problem.
>
> I have a codebase that uses plenty of
> typedef struct foo {
> ...
> } bar;
>
> I want to remove all these typedefs and simply use struct foo instead. I
> came up with this patch:
>
> /// Convert typdefed structs to structs
>
> @ rule1 @
> identifier i;
> type t;
> @@
> -typedef struct i {
> +struct i {
> ...
> - }t;
> + };
>
> @@
> identifier rule1.i;
> type rule1.t;
> @@
> -t
> +struct i
> // end of patch
>
> This seems to work for most occurrences, but there are a couple of
> variables defined like this:
>
> static const t *const baz[MAX] = {
> ...
> };
>
> And also function declarations like:
> u32 fn(const t* const baz);
>
> In such cases, t isn't replaces as I would expect, but those lines
> aren't changed at all.
>
> Other variables and non-const function parameters seem to be replaced as
> expected.
> Does anybody have an idea what I'm missing?
In principle, it should be OK. Could you send a concrete example of C
conde on which it does not work? It is possible that there is some
problem in parsing baz, and it is just skipping over it. For this, you
can run spatch --parse-c on your file. If there is a BAD or bad in front
of the code that you expect to have changed, then there may be a problem.
julia
next prev parent reply other threads:[~2015-02-14 18:56 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-14 18:29 [Cocci] remove typedefs from struct Sören Brinkmann
2015-02-14 18:56 ` Julia Lawall [this message]
2015-02-15 1:22 ` Sören Brinkmann
2015-02-15 5:54 ` Julia Lawall
2015-02-15 9:38 ` Julia Lawall
2015-02-15 21:05 ` Sören Brinkmann
2015-02-15 21:16 ` Julia Lawall
2015-02-15 21:31 ` Sören Brinkmann
2015-02-15 21:41 ` Julia Lawall
2015-02-15 21:53 ` Sören Brinkmann
2015-02-15 21:56 ` Julia Lawall
2015-02-16 9:00 ` Sören Brinkmann
2015-02-16 9:10 ` Julia Lawall
2015-02-16 15:59 ` Sören Brinkmann
2015-02-17 6:56 ` Julia Lawall
2015-02-17 19:42 ` Sören Brinkmann
2015-02-17 20:31 ` Julia Lawall
2015-02-18 0:50 ` Sören Brinkmann
2015-02-18 21:44 ` Julia Lawall
2015-02-19 9:08 ` [Cocci] Finding several type qualifiers with SmPL? SF Markus Elfring
2015-02-19 16:47 ` Sören Brinkmann
2015-02-19 16:54 ` Julia Lawall
2015-02-19 18:55 ` SF Markus Elfring
2015-02-19 18:30 ` SF Markus Elfring
2015-02-15 17:13 ` [Cocci] remove typedefs from struct SF Markus Elfring
2015-02-15 17:32 ` Julia Lawall
2015-02-15 20:15 ` Sören Brinkmann
2015-02-16 4:31 ` Sören Brinkmann
2015-02-16 6:19 ` Julia Lawall
2015-02-16 7:51 ` Sören Brinkmann
2015-02-16 8:10 ` 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=alpine.DEB.2.10.1502141955040.6185@hadrien \
--to=julia.lawall@lip6.fr \
--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