From: "Keller, Jacob E" <jacob.e.keller@intel.com>
To: "linux-sparse@vger.kernel.org" <linux-sparse@vger.kernel.org>
Subject: array of flexible structures oddity
Date: Fri, 7 Jan 2022 01:02:11 +0000 [thread overview]
Message-ID: <64238376-3882-2449-7758-e948cb4a6e1c@intel.com> (raw)
Hi,
I'm working on some code and noticed that sparse v0.6.4 now complains
about a seemingly innocuous use of "tty_port" from the Linux kernel:
struct my_struct {
struct tty_port[5];
}
This occurs because the tty_port structure contains a tty_bufhead which
itself contains a "sentinel" member which is an intentionally zero-sized
flexible member.
In this case, the member is known to be zero sized and data is not
directly accessed.
This results in the array of tty_port being considered "flexible" and
thus we report this warning.
This seems like a wrong approach, or at least we ought to have a method
of marking such intentional uses.
There's no other warning, (i.e. we don't get a warning about embedding a
flexible structure into another structure despite this likely being a
bug in normal flows).
For now I can work around it by disabling the warning... but I think the
behavior here ought to be improved.
I think the following behavior is what i would consider ideal:
a) count the structure as flexible only if the last member is flexible
b) produce a warning on embedding a flexible structure or element
anywhere that is not the last position, unless
c) some attribute or other marker which lets us indicate that its known
behavior and is safely handled.
Thanks,
Jake
reply other threads:[~2022-01-07 1:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=64238376-3882-2449-7758-e948cb4a6e1c@intel.com \
--to=jacob.e.keller@intel.com \
--cc=linux-sparse@vger.kernel.org \
/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).