History

Merge tag 'flexible-array-member-5.7-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux

Pull flexible-array member conversion from Gustavo Silva: "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] sizeof(flexible-array-member) triggers a warning because flexible array members have incomplete type[1]. There are some instances of code in which the sizeof operator is being incorrectly/erroneously applied to zero-length arrays and the result is zero. Such instances may be hiding some bugs. So, this work (flexible-array member convertions) will also help to get completely rid of those sorts of issues. Notice that all of these patches have been baking in linux-next for quite a while now and, 238 more of these patches have already been merged into 5.7-rc1. There are a couple hundred more of these issues waiting to be addressed in the whole codebase" [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") * tag 'flexible-array-member-5.7-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux: (28 commits) xattr.h: Replace zero-length array with flexible-array member uapi: linux: fiemap.h: Replace zero-length array with flexible-array member uapi: linux: dlm_device.h: Replace zero-length array with flexible-array member tpm_eventlog.h: Replace zero-length array with flexible-array member ti_wilink_st.h: Replace zero-length array with flexible-array member swap.h: Replace zero-length array with flexible-array member skbuff.h: Replace zero-length array with flexible-array member sched: topology.h: Replace zero-length array with flexible-array member rslib.h: Replace zero-length array with flexible-array member rio.h: Replace zero-length array with flexible-array member posix_acl.h: Replace zero-length array with flexible-array member platform_data: wilco-ec.h: Replace zero-length array with flexible-array member memcontrol.h: Replace zero-length array with flexible-array member list_lru.h: Replace zero-length array with flexible-array member lib: cpu_rmap: Replace zero-length array with flexible-array member irq.h: Replace zero-length array with flexible-array member ihex.h: Replace zero-length array with flexible-array member igmp.h: Replace zero-length array with flexible-array member genalloc.h: Replace zero-length array with flexible-array member ethtool.h: Replace zero-length array with flexible-array member ...

Linus Torvalds committed 6 years ago

Commit 13402832 parents 50cc09c 439515828 files · +39 −39Browse files

Showing the changes to include/uapi/linux (2 of 28 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/dlm_device.h +2 −2
  2. include/uapi/linux/fiemap.h +1 −1
include/uapi/linux/dlm_device.h+2−2
@@ -45,13 +45,13 @@ struct dlm_lock_params { · 44 unmodified lines
45 void __user *bastaddr;45 void __user *bastaddr;
46 struct dlm_lksb __user *lksb;46 struct dlm_lksb __user *lksb;
47 char lvb[DLM_USER_LVB_LEN];47 char lvb[DLM_USER_LVB_LEN];
48 char name[0];48 char name[];
49};49};
50 50
51struct dlm_lspace_params {51struct dlm_lspace_params {
52 __u32 flags;52 __u32 flags;
53 __u32 minor;53 __u32 minor;
54 char name[0];54 char name[];
55};55};
56 56
57struct dlm_purge_params {57struct dlm_purge_params {
include/uapi/linux/fiemap.h+1−1
@@ -34,7 +34,7 @@ struct fiemap { · 33 unmodified lines
34 __u32 fm_mapped_extents;/* number of extents that were mapped (out) */34 __u32 fm_mapped_extents;/* number of extents that were mapped (out) */
35 __u32 fm_extent_count; /* size of fm_extents array (in) */35 __u32 fm_extent_count; /* size of fm_extents array (in) */
36 __u32 fm_reserved;36 __u32 fm_reserved;
37 struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */37 struct fiemap_extent fm_extents[]; /* array of mapped extents (out) */
38};38};
39 39
40#define FIEMAP_MAX_OFFSET (~0ULL)40#define FIEMAP_MAX_OFFSET (~0ULL)