From: Peter Senna Tschudin <peter.senna@gmail.com>
To: cocci@inria.fr
Subject: [cocci] Returning statically allocated nested structs
Date: Thu, 28 Mar 2024 09:41:18 +0100 [thread overview]
Message-ID: <CA+MoWDqtRxQQ08k53_bP6L96FReUx8AxV2BU7dHWC-hfEr_kow@mail.gmail.com> (raw)
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
next reply other threads:[~2024-03-28 8:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 8:41 Peter Senna Tschudin [this message]
2024-03-28 9:07 ` [cocci] Returning statically allocated nested structs 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
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=CA+MoWDqtRxQQ08k53_bP6L96FReUx8AxV2BU7dHWC-hfEr_kow@mail.gmail.com \
--to=peter.senna@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).