linux/include/xen/interface
Gustavo A. R. Silva e8dc73c9f9 xen: 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/20200226212612.GA4663@embeddedor
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
2020-03-05 09:41:58 -06:00
..
hvm xen/pvh: Add memory map pointer to hvm_start_info struct 2018-12-13 13:41:49 -05:00
io xen: Replace zero-length array with flexible-array member 2020-03-05 09:41:58 -06:00
callback.h ia64/xen: Remove Xen support for ia64 2013-12-10 16:11:07 -08:00
elfnote.h xen/pvh: Import PVH-related Xen public interfaces 2017-02-07 08:07:01 -05:00
event_channel.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
features.h xen/pvh: Indicate XENFEAT_linux_rsdp_unrestricted to Xen 2018-04-10 09:22:22 -04:00
grant_table.h scripts/spelling.txt: add "an union" pattern and fix typo instances 2017-02-27 18:43:46 -08:00
memory.h x86/xen: Move pv specific parts of arch/x86/xen/mmu.c to mmu_pv.c 2018-09-03 16:50:33 +02:00
nmi.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
physdev.h xen: add support for MSI message groups 2014-03-18 14:40:09 +00:00
platform.h xen: introduce XENPF_settime64 2015-12-21 14:40:57 +00:00
sched.h xen: Sync xen header 2016-09-05 13:52:37 +02:00
vcpu.h x86/xen/time: setup vcpu 0 time info page 2017-11-08 16:33:14 -05:00
version.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xen-mca.h xen/mcelog: add PPIN to record when available 2019-11-14 10:01:57 +01:00
xen.h xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE 2018-05-14 15:25:37 +02:00
xenpmu.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00