From: Jan Engelhardt <jengelh@inai.de>
To: Phil Sutter <phil@nwl.cc>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Subject: Re: [iptables PATCH] libiptc: Avoid gcc-10 zero-length array warning
Date: Thu, 8 Oct 2020 18:46:40 +0200 (CEST) [thread overview]
Message-ID: <9437p77p-4rp3-q1rn-745q-9267q7osor7s@vanv.qr> (raw)
In-Reply-To: <20201008160714.GB13016@orbyte.nwl.cc>
On Thursday 2020-10-08 18:07, Phil Sutter wrote:
>> iptables does not rely or even do such embedding nonsense. When we
>> have a flexible array member T x[0] or T x[] somewhere, we really do
>> mean that Ts follow, not some Us like in the RDMA case.
>
>In fact, struct ipt_replace has a zero-length array as last field of
>type struct ipt_entry which in turn has a zero-length array as last
>field. :)
In the RDMA thread, I was informed that the trailing members' only
purpose is to serve as something of a shorthand:
Shortcut:
struct ipt_entry *e = replace->elements;
The long way:
struct ipt_entry *e = (void *)((char *)replace + sizeof(*replace));
But such gritty detail is often stowed away in some nice accessor
functions or macros. That's what's currently missing in spots
apprently.
struct ipt_entry *next = get_next_blah(replace);
Then the get_next can do that arithmetic, we won't need
ipt_replace::elements, and could do away with the flexible array
member altogether, especially when it's not used with equal-sized
elements, and ipt_entry is of variadic size.
next prev parent reply other threads:[~2020-10-08 16:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 13:01 [iptables PATCH] libiptc: Avoid gcc-10 zero-length array warning Phil Sutter
2020-10-08 14:33 ` Jan Engelhardt
2020-10-08 14:58 ` Phil Sutter
2020-10-08 15:31 ` Jan Engelhardt
2020-10-08 16:07 ` Phil Sutter
2020-10-08 16:46 ` Jan Engelhardt [this message]
2020-10-09 15:16 ` Phil Sutter
2020-10-09 16:43 ` Jan Engelhardt
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=9437p77p-4rp3-q1rn-745q-9267q7osor7s@vanv.qr \
--to=jengelh@inai.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
/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 NNTP newsgroup(s).