The Linux kernel fails to build now, and there is no CONFIG_ to turn off this "feature":
net/ipv4/netfilter/ip_tables.c:72:9: error: fields must have a constant size: 'variable length array in structure' extension
will never be supported
return xt_alloc_initial_table(ipt, IPT);
^
In file included from net/ipv4/netfilter/ip_tables.c:31:
net/ipv4/netfilter/../../netfilter/xt_repldata.h:14:26: note: instantiated from:
struct type##_standard entries[nhooks]; \
Here is the header:
/*
Today's hack: quantum tunneling in structs
'entries' and 'term' are never anywhere referenced by word in code. In fact,
they serve as the hanging-off data accessed through repl.data[].
*/
I don't think this is much different from VLAs, but instead of the array size depending on function parameter, it depends on a local variable.
It also isn't much different from variable-sized structs, it could convert the last 2 fields into [0xi8], and calculate the sizeof() at runtime.
Here is a workaround for the C code, clang could do this automatically:
diff --git a/net/netfilter/xt_repldata.h b/net/netfilter/xt_repldata.h
index 6efe4e5..e61924d 100644
--- a/net/netfilter/xt_repldata.h
+++ b/net/netfilter/xt_repldata.h
@@ -11,13 +11,16 @@
unsigned int bytes = 0, hooknum = 0, i = 0; \
struct { \
struct type##_replace repl; \
Extended Description
The Linux kernel fails to build now, and there is no CONFIG_ to turn off this "feature": net/ipv4/netfilter/ip_tables.c:72:9: error: fields must have a constant size: 'variable length array in structure' extension
will never be supported
return xt_alloc_initial_table(ipt, IPT);
^
In file included from net/ipv4/netfilter/ip_tables.c:31:
net/ipv4/netfilter/../../netfilter/xt_repldata.h:14:26: note: instantiated from:
struct type##_standard entries[nhooks]; \
Here is the header: /*
define xt_alloc_initial_table(type, typ2) ({ \
I don't think this is much different from VLAs, but instead of the array size depending on function parameter, it depends on a local variable. It also isn't much different from variable-sized structs, it could convert the last 2 fields into [0xi8], and calculate the sizeof() at runtime.
Here is a workaround for the C code, clang could do this automatically: diff --git a/net/netfilter/xt_repldata.h b/net/netfilter/xt_repldata.h index 6efe4e5..e61924d 100644 --- a/net/netfilter/xt_repldata.h +++ b/net/netfilter/xt_repldata.h @@ -11,13 +11,16 @@ unsigned int bytes = 0, hooknum = 0, i = 0; \ struct { \ struct type##_replace repl; \