linux/drivers/dma/ti
Gustavo A. R. Silva 5ca3364a83 dmaengine: ti: omap-dma: 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>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20200213003925.GA6906@embeddedor.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2020-02-13 20:16:00 +05:30
..
cppi41.c dmaengine: cppi41: Fix cppi41_dma_prep_slave_sg() when idle 2019-10-23 21:15:21 +05:30
dma-crossbar.c dmaengine: ti: dma-crossbar: Fix a memory leak bug 2019-08-20 17:16:15 +05:30
edma.c dmaengine: ti: edma: Fix error return code in edma_probe() 2019-12-18 11:39:34 +05:30
k3-psil-am654.c dmaengine: ti: k3-psil: make symbols static 2020-01-21 13:10:24 +05:30
k3-psil-j721e.c dmaengine: ti: k3-psil: make symbols static 2020-01-21 13:10:24 +05:30
k3-psil-priv.h dmaengine: ti: k3-psil: make symbols static 2020-01-21 13:10:24 +05:30
k3-psil.c dmaengine: ti: k3-psil: make symbols static 2020-01-21 13:10:24 +05:30
k3-udma-glue.c dmaengine: ti: k3-udma: Add glue layer for non DMAengine users 2020-01-21 11:06:12 +05:30
k3-udma-private.c dmaengine: ti: k3-udma: Add glue layer for non DMAengine users 2020-01-21 11:06:12 +05:30
k3-udma.c dmaengine: ti: k3-udma: fix spelling mistake "limted" -> "limited" 2020-01-23 17:03:29 +05:30
k3-udma.h dmaengine: ti: k3-udma: Add glue layer for non DMAengine users 2020-01-21 11:06:12 +05:30
Kconfig dmaengine: ti: k3-udma: Add glue layer for non DMAengine users 2020-01-21 11:06:12 +05:30
Makefile dmaengine: ti: k3-udma: Add glue layer for non DMAengine users 2020-01-21 11:06:12 +05:30
omap-dma.c dmaengine: ti: omap-dma: Replace zero-length array with flexible-array member 2020-02-13 20:16:00 +05:30