All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] Returning statically allocated nested structs
@ 2024-03-28  8:41 Peter Senna Tschudin
  2024-03-28  9:07 ` Julia Lawall
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Senna Tschudin @ 2024-03-28  8:41 UTC (permalink / raw)
  To: cocci

Dear list,

I am trying to come up with a semantic patch to detect uses of nested
structs, more specifically:
 - the nested struct is statically allocated
 - the statically allocated nested struct is returned by a function.

Here is an example:

struct inner {

    /* some inner struct stuff*/

} inner;

struct outer  {

    /* some outer struct stuff*/

    struct inner i; // The kind of nesting I care about
    struct inner is[SOME_MAGIC_NUMBER]; // The kind of nesting I care about too

    struct inner *ip; // Nah, this is boring. I don't care about boring
} outer;

void sillyfu() {
    struct outer ou = { }; // initialization does not matter.
    struct outer *oup = NULL; // Nah, this is boring. I don't care about boring

    /* some serious silly stuff */

    return ou;
}

I remember that there are some details for detecting structs
effectively, and as I am investigating a code base with over 1.2M
lines of code, I would like to ask for pointers of where to start.

Thank you!

Peter

-- 
                         Peter

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

end of thread, other threads:[~2024-03-28 14:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28  8:41 [cocci] Returning statically allocated nested structs Peter Senna Tschudin
2024-03-28  9:07 ` Julia Lawall
2024-03-28 10:00   ` Peter Senna Tschudin
2024-03-28 10:10     ` Julia Lawall
2024-03-28 13:03       ` Peter Senna Tschudin
2024-03-28 14:49         ` Julia Lawall
2024-03-28 14:57           ` Peter Senna Tschudin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.