https://github.com/torvalds/linux
Revision e76018cb604ace486de9cf85898c14bb2b47faff authored by Gustavo A. R. Silva on 23 March 2020, 21:48:10 UTC, committed by Gustavo A. R. Silva on 18 April 2020, 20:44:54 UTC
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 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
1 parent 5a58ec8
Tip revision: e76018cb604ace486de9cf85898c14bb2b47faff authored by Gustavo A. R. Silva on 23 March 2020, 21:48:10 UTC
can: dev: peak_canfd.h: Replace zero-length array with flexible-array member
can: dev: peak_canfd.h: Replace zero-length array with flexible-array member
Tip revision: e76018c
File | Mode | Size |
---|---|---|
Makefile | -rw-r--r-- | 1.3 KB |
bpf_sk_storage.c | -rw-r--r-- | 30.4 KB |
datagram.c | -rw-r--r-- | 19.8 KB |
datagram.h | -rw-r--r-- | 322 bytes |
dev.c | -rw-r--r-- | 262.1 KB |
dev_addr_lists.c | -rw-r--r-- | 23.8 KB |
dev_ioctl.c | -rw-r--r-- | 11.8 KB |
devlink.c | -rw-r--r-- | 235.5 KB |
drop_monitor.c | -rw-r--r-- | 39.4 KB |
dst.c | -rw-r--r-- | 7.9 KB |
dst_cache.c | -rw-r--r-- | 3.5 KB |
failover.c | -rw-r--r-- | 7.4 KB |
fib_notifier.c | -rw-r--r-- | 4.8 KB |
fib_rules.c | -rw-r--r-- | 29.4 KB |
filter.c | -rw-r--r-- | 239.2 KB |
flow_dissector.c | -rw-r--r-- | 48.6 KB |
flow_offload.c | -rw-r--r-- | 14.0 KB |
gen_estimator.c | -rw-r--r-- | 6.9 KB |
gen_stats.c | -rw-r--r-- | 11.5 KB |
gro_cells.c | -rw-r--r-- | 2.2 KB |
hwbm.c | -rw-r--r-- | 1.9 KB |
link_watch.c | -rw-r--r-- | 5.6 KB |
lwt_bpf.c | -rw-r--r-- | 14.8 KB |
lwtunnel.c | -rw-r--r-- | 8.8 KB |
neighbour.c | -rw-r--r-- | 91.3 KB |
net-procfs.c | -rw-r--r-- | 8.4 KB |
net-sysfs.c | -rw-r--r-- | 44.4 KB |
net-sysfs.h | -rw-r--r-- | 510 bytes |
net-traces.c | -rw-r--r-- | 1.7 KB |
net_namespace.c | -rw-r--r-- | 32.3 KB |
netclassid_cgroup.c | -rw-r--r-- | 3.4 KB |
netevent.c | -rw-r--r-- | 1.8 KB |
netpoll.c | -rw-r--r-- | 18.8 KB |
netprio_cgroup.c | -rw-r--r-- | 6.6 KB |
page_pool.c | -rw-r--r-- | 14.3 KB |
pktgen.c | -rw-r--r-- | 95.4 KB |
ptp_classifier.c | -rw-r--r-- | 6.8 KB |
request_sock.c | -rw-r--r-- | 5.0 KB |
rtnetlink.c | -rw-r--r-- | 134.0 KB |
scm.c | -rw-r--r-- | 8.5 KB |
secure_seq.c | -rw-r--r-- | 5.0 KB |
skbuff.c | -rw-r--r-- | 154.0 KB |
skmsg.c | -rw-r--r-- | 19.2 KB |
sock.c | -rw-r--r-- | 87.2 KB |
sock_diag.c | -rw-r--r-- | 7.8 KB |
sock_map.c | -rw-r--r-- | 28.7 KB |
sock_reuseport.c | -rw-r--r-- | 9.1 KB |
stream.c | -rw-r--r-- | 5.4 KB |
sysctl_net_core.c | -rw-r--r-- | 14.8 KB |
timestamping.c | -rw-r--r-- | 1.5 KB |
tso.c | -rw-r--r-- | 2.3 KB |
utils.c | -rw-r--r-- | 11.6 KB |
xdp.c | -rw-r--r-- | 11.7 KB |
Computing file changes ...