linux-sg2042/drivers/usb
Gustavo A. R. Silva 6bc3f3979e USB: 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>
Link: https://lore.kernel.org/r/20200220132017.GA29262@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-23 19:24:51 +01:00
..
atm USB: Replace zero-length array with flexible-array member 2020-02-23 19:24:51 +01:00
c67x00 USB: add SPDX identifiers to all remaining Makefiles 2017-11-07 15:53:48 +01:00
cdns3 usb: cdns3: remove redundant assignment to pointer trb 2020-02-10 11:15:27 -08:00
chipidea usb: chipidea: add inline for ci_hdrc_host_driver_init if host is not defined 2020-01-22 07:54:27 +01:00
class compat_ioctl: remove most of fs/compat_ioctl.c 2019-12-01 13:46:15 -08:00
common usb: common: usb-conn-gpio: Don't log an error on probe deferral 2019-12-10 11:41:20 +01:00
core usb: core: Use ACPI_SUCCESS() at appropriate places 2020-02-19 11:08:52 +01:00
dwc2 USB: Replace zero-length array with flexible-array member 2020-02-23 19:24:51 +01:00
dwc3 usb: dwc3: qcom: Replace <linux/clk-provider.h> by <linux/of_clk.h> 2020-02-12 10:47:58 -08:00
early remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
gadget usb: gadget: renesas_usb3: remove useless cast for driver.name 2020-02-19 11:10:26 +01:00
host USB: Replace zero-length array with flexible-array member 2020-02-23 19:24:51 +01:00
image Merge 5.4-rc3 into usb-next 2019-10-14 07:09:59 +02:00
isp1760 remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
misc USB: apple-mfi-fastcharge: fix endianess issue in probe 2020-02-13 05:07:10 -08:00
mon usb: mon: Fix a deadlock in usbmon between mmap and read 2019-12-10 11:41:20 +01:00
mtu3 Merge 5.4-rc6 into usb-next 2019-11-04 06:41:09 +01:00
musb usb: musb: core: remove useless cast for driver.name 2020-02-19 11:10:27 +01:00
phy usb: phy: show USB charger type for user 2020-01-24 09:41:27 +01:00
renesas_usbhs phy: for 5.6 2020-01-17 07:52:26 +01:00
roles usb: use kobj_to_dev() API 2020-02-14 08:38:15 -08:00
serial USB: Replace zero-length array with flexible-array member 2020-02-23 19:24:51 +01:00
storage usb-storage: Use const to reduce object data size 2020-02-19 11:08:52 +01:00
typec usb: ucsi: ccg: disable runtime pm during fw flashing 2020-02-17 16:50:18 +01:00
usbip usbip: Fix error path of vhci_recv_ret_submit() 2019-12-17 16:36:33 +01:00
Kconfig usb: common: create Kconfig file 2019-09-03 19:00:39 +02:00
Makefile USB: Changes for v5.4 merge window 2019-09-02 19:20:57 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00