Re: [iptables PATCH] libiptc: Avoid gcc-10 zero-length array warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux