6bc3f3979e
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
|
||
---|---|---|
.. | ||
audio-v2.h | ||
audio-v3.h | ||
audio.h | ||
c67x00.h | ||
ccid.h | ||
cdc_ncm.h | ||
cdc-wdm.h | ||
cdc.h | ||
ch9.h | ||
chipidea.h | ||
composite.h | ||
ehci_def.h | ||
ehci_pdriver.h | ||
ehci-dbgp.h | ||
ezusb.h | ||
functionfs.h | ||
g_hid.h | ||
gadget_configfs.h | ||
gadget.h | ||
hcd.h | ||
input.h | ||
iowarrior.h | ||
irda.h | ||
isp116x.h | ||
isp1301.h | ||
isp1362.h | ||
isp1760.h | ||
m66592.h | ||
musb-ux500.h | ||
musb.h | ||
net2280.h | ||
of.h | ||
ohci_pdriver.h | ||
otg-fsm.h | ||
otg.h | ||
pd_ado.h | ||
pd_bdo.h | ||
pd_ext_sdb.h | ||
pd_vdo.h | ||
pd.h | ||
phy_companion.h | ||
phy.h | ||
quirks.h | ||
r8a66597.h | ||
renesas_usbhs.h | ||
rndis_host.h | ||
role.h | ||
serial.h | ||
sl811.h | ||
storage.h | ||
tcpm.h | ||
tegra_usb_phy.h | ||
typec_altmode.h | ||
typec_dp.h | ||
typec_mux.h | ||
typec.h | ||
uas.h | ||
ulpi.h | ||
usb338x.h | ||
usb_phy_generic.h | ||
usbnet.h | ||
xhci-dbgp.h |