]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libiptc: Avoid gcc-10 zero-length array warning
authorPhil Sutter <phil@nwl.cc>
Thu, 8 Oct 2020 12:51:52 +0000 (14:51 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 12 Oct 2020 11:27:23 +0000 (13:27 +0200)
Gcc-10 doesn't like the use of zero-length arrays as last struct member
to denote variable sized objects. The suggested alternative, namely to
use a flexible array member as defined by C99, is problematic as that
doesn't allow for said struct to be embedded into others. With the
relevant structs being part of kernel UAPI, this can't be precluded
though.

The call to memcpy() which triggers the warning copies data from one
struct xt_counters to another. Since this struct is flat and merely
contains two u64 fields, One can use direct assignment instead which
avoids the warning.

Signed-off-by: Phil Sutter <phil@nwl.cc>
libiptc/libiptc.c

index 58882015252132dd692b22b8859d421938efe3df..ceeb017b39400ac13ff4d9f8cb8522db331966d6 100644 (file)
@@ -1169,7 +1169,7 @@ static int iptcc_compile_chain(struct xtc_handle *h, STRUCT_REPLACE *repl, struc
        else
                foot->target.verdict = RETURN;
        /* set policy-counters */
-       memcpy(&foot->e.counters, &c->counters, sizeof(STRUCT_COUNTERS));
+       foot->e.counters = c->counters;
 
        return 0;
 }