2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-30 16:13:54 +08:00
linux-next/drivers/auxdisplay
Gustavo A. R. Silva 2f920c0f0e auxdisplay: charlcd: 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: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
2020-03-06 22:18:07 +01:00
..
arm-charlcd.c auxdisplay: simplify getting .drvdata 2018-08-01 18:58:09 +02:00
cfag12864b.c treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00
cfag12864bfb.c auxdisplay: constify fb ops 2019-12-11 12:31:39 +02:00
charlcd.c auxdisplay: charlcd: replace zero-length array with flexible-array member 2020-03-06 22:18:07 +01:00
charlcd.h auxdisplay: charlcd: add include guard to charlcd.h 2019-08-08 19:59:50 +02:00
hd44780.c auxdisplay: charlcd: move charlcd.h to drivers/auxdisplay 2019-08-08 19:59:17 +02:00
ht16k33.c auxdisplay: constify fb ops 2019-12-11 12:31:39 +02:00
img-ascii-lcd.c auxdisplay: img-ascii-lcd: convert to devm_platform_ioremap_resource 2020-03-06 22:07:10 +01:00
Kconfig auxdisplay: Fix Kconfig indentation 2020-03-06 22:01:54 +01:00
ks0108.c auxdisplay: Replace licenses with SPDX identifiers 2018-04-12 19:02:45 +02:00
Makefile auxdisplay: deconfuse configuration 2019-03-17 08:48:33 +01:00
panel.c auxdisplay: charlcd: move charlcd.h to drivers/auxdisplay 2019-08-08 19:59:17 +02:00