linux/net/batman-adv
Gustavo A. R. Silva 5f27eb055d batman-adv: Replace zero-length array with flexible-array member
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 7649773293 ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Sven Eckelman <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
2020-02-17 22:43:42 +01:00
..
bat_algo.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bat_algo.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bat_iv_ogm.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bat_iv_ogm.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bat_v_elp.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bat_v_elp.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bat_v_ogm.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bat_v_ogm.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bat_v.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bat_v.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bitarray.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bitarray.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bridge_loop_avoidance.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
bridge_loop_avoidance.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
debugfs.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
debugfs.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
distributed-arp-table.c batman-adv: Replace zero-length array with flexible-array member 2020-02-17 22:43:42 +01:00
distributed-arp-table.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
fragmentation.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
fragmentation.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
gateway_client.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
gateway_client.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
gateway_common.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
gateway_common.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
hard-interface.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
hard-interface.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
hash.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
hash.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
icmp_socket.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
icmp_socket.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
Kconfig batman-adv: Disable CONFIG_BATMAN_ADV_SYSFS by default 2020-01-01 00:57:07 +01:00
log.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
log.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
main.c This feature/cleanup patchset includes the following patches: 2020-01-15 23:04:04 +01:00
main.h batman-adv: Start new development cycle 2020-02-16 16:00:02 +01:00
Makefile batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
multicast.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
multicast.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
netlink.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
netlink.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
network-coding.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
network-coding.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
originator.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
originator.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
routing.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
routing.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
send.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
send.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
soft-interface.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
soft-interface.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
sysfs.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
sysfs.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
tp_meter.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
tp_meter.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
trace.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
trace.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
translation-table.c batman-adv: Avoid RCU list-traversal in spinlock 2020-02-17 16:07:50 +01:00
translation-table.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
tvlv.c batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
tvlv.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00
types.h batman-adv: Update copyright years for 2020 2020-01-01 00:00:33 +01:00