OpenCloudOS-Kernel/drivers/mtd/maps
Gustavo A. R. Silva f1ffdbfad0 mtd: maps: sa1100-flash: 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: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200319224200.GA25162@embeddedor.com
2020-03-24 23:02:30 +01:00
..
Kconfig mtd: physmap_of: add a hook for Intel IXP4xx flash probing 2019-10-29 14:24:53 +01:00
Makefile mtd: physmap_of: add a hook for Intel IXP4xx flash probing 2019-10-29 14:24:53 +01:00
amd76xrom.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
cfi_flagadm.c mtd: constify mtd_partition 2017-11-06 23:26:01 +01:00
ck804xrom.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
dc21285.c mtd: dc21285: use raw spinlock functions for nw_gpio_lock 2015-05-28 12:01:29 -07:00
esb2rom.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
ichxrom.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
impa7.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
intel_vr_nor.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
ixp4xx.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
l440gx.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
lantiq-flash.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
map_funcs.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
netsc520.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
nettel.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
pci.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
pcmciamtd.c mtd: maps: pcmciamtd: fix possible sleep-in-atomic-context bugs in pcmciamtd_set_vpp() 2020-01-27 16:55:02 +01:00
physmap-core.c mtd: maps: physmap: Add minimal Runtime PM support 2020-01-27 16:55:31 +01:00
physmap-gemini.c mtd: physmap_of_gemini: remove extranous __xipram annotation 2019-05-06 21:46:44 +02:00
physmap-gemini.h mtd: maps: Rename physmap_of_{versatile, gemini} into physmap-{versatile, gemini} 2018-11-05 22:24:29 +01:00
physmap-ixp4xx.c mtd: physmap_of: add a hook for Intel IXP4xx flash probing 2019-10-29 14:24:53 +01:00
physmap-ixp4xx.h mtd: physmap_of: add a hook for Intel IXP4xx flash probing 2019-10-29 14:24:53 +01:00
physmap-versatile.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
physmap-versatile.h mtd: maps: Rename physmap_of_{versatile, gemini} into physmap-{versatile, gemini} 2018-11-05 22:24:29 +01:00
pismo.c mtd: pismo: Simplify getting the adapter of a client 2019-09-15 23:50:39 +02:00
plat-ram.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
pmcmsp-flash.c mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy 2017-02-08 13:15:49 -08:00
pxa2xx-flash.c mtd: pxa2xx: Use ioremap_cache insted of ioremap_cached 2019-09-15 23:50:22 +02:00
rbtx4939-flash.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
sa1100-flash.c mtd: maps: sa1100-flash: Replace zero-length array with flexible-array member 2020-03-24 23:02:30 +01:00
sbc_gxx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
sc520cdp.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
scb2_flash.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
scx200_docflash.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
solutionengine.c mtd/maps: fix solutionengine.c printk format warnings 2018-07-24 22:43:10 +02:00
sun_uflash.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
ts5500_flash.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
tsunami_flash.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
uclinux.c mtd: maps: Make uclinux_ram_map static 2019-05-06 21:47:01 +02:00
vmu-flash.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 467 2019-06-19 17:09:10 +02:00