linux-stable/drivers/media
Gustavo A. R. Silva 142d06489f media: s5k5baf: Replace zero-length array with flexible-array
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]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

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 <gustavoars@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-25 15:44:00 +02:00
..
cec media: cec: silence shift wrapping warning in __cec_s_log_addrs() 2020-05-05 17:27:03 +02:00
common media: dvb-usb: auto-select CYPRESS_FIRMWARE 2020-04-14 10:29:04 +02:00
dvb-core media: dvbdev: Fix tuner->demod media controller link 2020-05-25 09:09:05 +02:00
dvb-frontends media: dvb-frontends: remove redundant initialization of variable status 2020-05-12 17:33:31 +02:00
firewire media: Kconfig: mode firewire comment to firewire/Kconfig 2020-04-14 10:29:04 +02:00
i2c media: s5k5baf: Replace zero-length array with flexible-array 2020-05-25 15:44:00 +02:00
mc media: entity: Pass entity to get_fwnode_pad operation 2020-05-18 11:12:05 +02:00
mmc media: Kconfig: move comment to siano include 2020-04-14 10:29:04 +02:00
pci media: mantis_dvb: remove redundant initialization to variable result 2020-05-12 17:32:51 +02:00
platform media: video-mux: Create media links in bound notifier 2020-05-18 14:20:56 +02:00
radio media: radio: don't use a menu just for wl128x driver 2020-04-16 10:34:57 +02:00
rc media: gpio-ir-tx: allow transmission without carrier 2020-05-12 17:30:40 +02:00
spi media: i2c/Kconfig: use sub-menus for I2C support 2020-04-16 10:34:40 +02:00
test-drivers media: vimc: Make use of V4L2_CAP_IO_MC 2020-05-06 12:10:12 +02:00
tuners media: si2157: ensure wait_status is initialized 2020-04-29 11:59:57 +02:00
usb media: dvb-usb: Add Cinergy S2 PCIe Dual Port support 2020-05-25 09:09:39 +02:00
v4l2-core media: v4l2-ctrls: Add helper to register properties 2020-05-18 15:36:20 +02:00
Kconfig media: media/test_drivers: rename to test-drivers 2020-04-16 10:38:31 +02:00
Makefile media: media/test_drivers: rename to test-drivers 2020-04-16 10:38:31 +02:00