cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Replacing a struct member with a function call
@ 2021-03-14  0:55 Thomas Adam
  2021-03-14  6:10 ` Wolfram Sang
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Adam @ 2021-03-14  0:55 UTC (permalink / raw)
  To: Coccinelle

Hello all,

I'm wanting to replace a struct member with a function call across the
code base I'm working on.

For example, I currently have the following struct definition (simplified):

struct monitor {
    struct {
        int width;
        int height
    } virtual;
};

Across my code base, I typically have the following:

struct monitor *m;
int f = m->virtual.width;

I have a need to remove `m->virtual.width` with a function call, hence
the example above after the modified code would look something like:

struct monitor *m;
int f = get_monitor_width();

I've tried the following smPL code without any success.  Could someone
point me in the right direction?  TIA!

@@
type M;
@@
- m->virtual.width;
+ get_monitor_width();

-- Thomas
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-18 18:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-14  0:55 [Cocci] Replacing a struct member with a function call Thomas Adam
2021-03-14  6:10 ` Wolfram Sang
2021-03-14  9:16   ` Julia Lawall
2021-03-15  0:43     ` Thomas Adam
2021-03-15  6:38       ` Julia Lawall
2021-03-16  2:48       ` Mansour Moufid
2021-03-16  7:20         ` Julia Lawall
2021-03-18 18:19           ` Thomas Adam

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 NNTP newsgroup(s).