linux/drivers/of
Gustavo A. R. Silva f43775625e of: of_private.h: 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>
Signed-off-by: Rob Herring <robh@kernel.org>
2020-03-31 09:03:34 -06:00
..
unittest-data of: unittest: add overlay gpio test to catch gpio hog problem 2020-02-26 10:42:04 -06:00
address.c of/address: Support multiple 'dma-ranges' entries 2020-02-14 15:27:08 -06:00
base.c ARM: SoC-related driver updates 2020-02-08 14:04:19 -08:00
device.c treewide: remove redundant IS_ERR() before error code check 2020-02-04 03:05:27 +00:00
dynamic.c of: Rework and simplify phandle cache to use a fixed size 2019-12-24 14:17:52 -07:00
fdt_address.c of: Use SPDX license tag for DT files 2018-01-08 08:22:45 -06:00
fdt.c Devicetree updates for v5.5: 2019-12-02 11:41:35 -08:00
irq.c of: irq: fix a trivial typo in a doc comment 2019-08-14 20:12:16 -06:00
Kconfig of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc 2020-01-28 08:26:20 -06:00
kobj.c of: overlay: add missing of_node_get() in __of_attach_node_sysfs 2018-11-08 22:10:53 -08:00
Makefile PCI: Move OF-related PCI functions into PCI core 2018-01-17 17:36:39 -06:00
of_mdio.c net: mii_timestamper: fix static allocation by PHY driver 2020-01-31 07:46:11 -08:00
of_net.c net: of_get_phy_mode: Change API to solve int/unit warnings 2019-11-04 11:21:25 -08:00
of_numa.c of, numa: Validate some distance map rules 2018-11-08 12:44:34 -06:00
of_private.h of: of_private.h: Replace zero-length array with flexible-array member 2020-03-31 09:03:34 -06:00
of_reserved_mem.c of: of_reserved_mem: Increase limit on number of reserved regions 2020-02-25 15:08:28 -06:00
overlay.c of: overlay: Remove blank line between assignment and check 2020-01-08 10:49:23 -06:00
pdt.c of: Remove struct device_node.type pointer 2019-01-10 16:24:44 -06:00
platform.c of/platform: Unconditionally pause/resume sync state during kernel init 2019-12-12 18:39:52 -06:00
property.c of: property: Add device link support for power-domains and hwlocks 2020-02-26 09:50:54 -06:00
resolver.c of: overlay: log the error cause on resolver failure 2020-03-02 11:32:44 -06:00
unittest.c of: unittest: make gpio overlay test dependent on CONFIG_OF_GPIO 2020-03-02 11:32:30 -06:00