linux-stable/drivers/misc/mei
Gustavo A. R. Silva f490e8aea3 misc: 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: Dimitri Sivanich <sivanich@hpe.com>
Link: https://lore.kernel.org/r/20200226222240.GA14474@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-18 12:24:19 +01:00
..
hdcp mei: hdcp: bind only with i915 on the same PCH 2020-01-10 13:20:49 +01:00
bus-fixup.c mei: bus: replace zero-length array with flexible-array member 2020-02-11 14:03:19 -08:00
bus.c mei: bus: use simple sprintf for sysfs 2020-01-10 13:20:49 +01:00
client.c mei: limit number of bytes in mei header. 2020-02-11 14:03:19 -08:00
client.h mei: bus: add more client attributes to sysfs 2019-11-16 12:58:54 +01:00
debugfs.c Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
dma-ring.c mei: adjust the copyright notice in the files. 2019-03-28 02:07:54 +09:00
hbm.c mei: adjust the copyright notice in the files. 2019-03-28 02:07:54 +09:00
hbm.h mei: adjust the copyright notice in the files. 2019-03-28 02:07:54 +09:00
hw-me-regs.h mei: me: add jasper point DID 2020-01-24 09:33:58 +01:00
hw-me.c mei: add trc detection register to sysfs 2019-11-07 09:37:27 +01:00
hw-me.h mei: add trc detection register to sysfs 2019-11-07 09:37:27 +01:00
hw-txe-regs.h mei: adjust the copyright notice in the files. 2019-03-28 02:07:54 +09:00
hw-txe.c mei: abstract fw status register read. 2019-11-07 09:35:49 +01:00
hw-txe.h mei: adjust the copyright notice in the files. 2019-03-28 02:07:54 +09:00
hw.h misc: Replace zero-length array with flexible-array member 2020-03-18 12:24:19 +01:00
init.c mei: abstract fw status register read. 2019-11-07 09:35:49 +01:00
interrupt.c mei: adjust the copyright notice in the files. 2019-03-28 02:07:54 +09:00
Kconfig mei: hdcp: use own Kconfig file 2019-04-25 19:33:34 +02:00
main.c compat_ioctl: remove most of fs/compat_ioctl.c 2019-12-01 13:46:15 -08:00
Makefile mei: adjust the copyright notice in the files. 2019-03-28 02:07:54 +09:00
mei-trace.c mei: adjust the copyright notice in the files. 2019-03-28 02:07:54 +09:00
mei-trace.h mei: adjust the copyright notice in the files. 2019-03-28 02:07:54 +09:00
mei_dev.h misc: Replace zero-length array with flexible-array member 2020-03-18 12:24:19 +01:00
pci-me.c mei: remove unused includes from pci-{me,txe}.c 2020-02-23 21:51:19 +01:00
pci-txe.c mei: remove unused includes from pci-{me,txe}.c 2020-02-23 21:51:19 +01:00