linux/fs/ext2
Gustavo A. R. Silva c2d0699c62 ext2: xattr.h: 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")

Link: https://lore.kernel.org/r/20200309180441.GA2992@embeddedor
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2020-03-16 15:56:50 +01:00
..
acl.c ext2: cache NULL when both default_acl and acl are NULL 2018-09-03 11:05:03 +02:00
acl.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
balloc.c ext2: fix improper function comment 2019-11-07 12:35:27 +01:00
dir.c ext2: use common file type conversion 2019-01-21 17:48:17 +01:00
ext2.h ext2: introduce new helper ext2_group_last_block_no() 2019-11-06 16:25:12 +01:00
file.c ext2: support statx syscall 2019-02-18 15:14:43 +01:00
ialloc.c ext2: add missing brelse() in ext2_new_inode() 2019-05-30 13:35:32 +02:00
inode.c dax: Pass dax_dev instead of bdev to dax_writeback_mapping_range() 2020-01-03 11:13:12 -08:00
ioctl.c ext2: return error when fail to allocating memory in ioctl 2019-10-24 09:24:40 +02:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +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
namei.c ext2: support statx syscall 2019-02-18 15:14:43 +01:00
super.c ext2: Adjust indentation in ext2_fill_super 2020-01-06 10:09:35 +01:00
symlink.c ext2: support statx syscall 2019-02-18 15:14:43 +01:00
xattr.c ext2: Silence lockdep warning about reclaim under xattr_sem 2020-02-26 13:14:27 +01:00
xattr.h ext2: xattr.h: Replace zero-length array with flexible-array member 2020-03-16 15:56:50 +01:00
xattr_security.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xattr_trusted.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xattr_user.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00