mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
1ee44529cc
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
|
||
---|---|---|
.. | ||
bestcomm | ||
dw | ||
dw-axi-dmac | ||
dw-edma | ||
fsl-dpaa2-qdma | ||
hsu | ||
idxd | ||
ioat | ||
ipu | ||
mediatek | ||
ppc4xx | ||
qcom | ||
sf-pdma | ||
sh | ||
ti | ||
xilinx | ||
acpi-dma.c | ||
altera-msgdma.c | ||
amba-pl08x.c | ||
at_hdmac.c | ||
at_hdmac_regs.h | ||
at_xdmac.c | ||
bcm-sba-raid.c | ||
bcm2835-dma.c | ||
coh901318.c | ||
coh901318.h | ||
coh901318_lli.c | ||
dma-axi-dmac.c | ||
dma-jz4780.c | ||
dmaengine.c | ||
dmaengine.h | ||
dmatest.c | ||
ep93xx_dma.c | ||
fsl-edma-common.c | ||
fsl-edma-common.h | ||
fsl-edma.c | ||
fsl-qdma.c | ||
fsl_raid.c | ||
fsl_raid.h | ||
fsldma.c | ||
fsldma.h | ||
hisi_dma.c | ||
idma64.c | ||
idma64.h | ||
img-mdc-dma.c | ||
imx-dma.c | ||
imx-sdma.c | ||
iop-adma.c | ||
iop-adma.h | ||
k3dma.c | ||
Kconfig | ||
lpc18xx-dmamux.c | ||
Makefile | ||
mcf-edma.c | ||
mic_x100_dma.c | ||
mic_x100_dma.h | ||
milbeaut-hdmac.c | ||
milbeaut-xdmac.c | ||
mmp_pdma.c | ||
mmp_tdma.c | ||
moxart-dma.c | ||
mpc512x_dma.c | ||
mv_xor.c | ||
mv_xor.h | ||
mv_xor_v2.c | ||
mxs-dma.c | ||
nbpfaxi.c | ||
of-dma.c | ||
owl-dma.c | ||
pch_dma.c | ||
pl330.c | ||
plx_dma.c | ||
pxa_dma.c | ||
s3c24xx-dma.c | ||
sa11x0-dma.c | ||
sirf-dma.c | ||
sprd-dma.c | ||
st_fdma.c | ||
st_fdma.h | ||
ste_dma40.c | ||
ste_dma40_ll.c | ||
ste_dma40_ll.h | ||
stm32-dma.c | ||
stm32-dmamux.c | ||
stm32-mdma.c | ||
sun4i-dma.c | ||
sun6i-dma.c | ||
tegra20-apb-dma.c | ||
tegra210-adma.c | ||
timb_dma.c | ||
TODO | ||
txx9dmac.c | ||
txx9dmac.h | ||
uniphier-mdmac.c | ||
virt-dma.c | ||
virt-dma.h | ||
xgene-dma.c | ||
zx_dma.c |