linux_dsm_epyc7002/drivers/usb/atm
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
..
cxacru.c USB: atm: cxacru: convert to use dev_groups 2019-08-09 07:55:45 +02:00
Kconfig usb: remove redundant 'default n' from Kconfig-s 2019-05-21 10:06:22 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
speedtch.c usb: usbatm: Convert timers to use timer_setup() 2017-11-21 15:46:44 -08:00
ueagle-atm.c USB: atm: Replace zero-length array with flexible-array member 2020-02-12 10:59:11 -08:00
usbatm.c treewide: Use sizeof_field() macro 2019-12-09 10:36:44 -08:00
usbatm.h USB: Replace zero-length array with flexible-array member 2020-02-23 19:24:51 +01:00
xusbatm.c USB: atm: Remove redundant license text 2017-11-04 11:55:38 +01:00