alistair23-linux/include/xen/interface/io
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
..
9pfs.h xen: introduce the header file for the Xen 9pfs transport protocol 2017-05-02 11:11:08 +02:00
blkif.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
console.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
displif.h xen: Sync up with the canonical protocol definitions in Xen 2018-06-12 15:10:26 -07:00
fbif.h xen pvfb: Dynamic mode support (screen resizing) 2008-05-27 10:11:36 +02:00
kbdif.h Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2018-08-18 16:48:07 -07:00
netif.h xen-netback: re-import canonical netif header 2016-03-13 22:08:01 -04:00
pciif.h xen-pcifront: Xen PCI frontend driver. 2010-10-18 10:49:37 -04:00
protocols.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pvcalls.h xen: introduce the pvcalls interface header 2017-08-31 09:45:55 -04:00
ring.h xen/interface: re-define FRONT/BACK_RING_ATTACH() 2019-12-20 13:44:42 +01:00
sndif.h xen: Sync up with the canonical protocol definitions in Xen 2018-06-12 15:10:26 -07:00
tpmif.h xen: Replace zero-length array with flexible-array member 2020-03-05 09:41:58 -06:00
vscsiif.h xen: Add Xen pvSCSI protocol description 2014-09-23 13:36:19 +00:00
xenbus.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xs_wire.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00