Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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
...

+39 -39
+1 -1
include/linux/bio.h
··· 319 319 struct work_struct bip_work; /* I/O completion */ 320 320 321 321 struct bio_vec *bip_vec; 322 - struct bio_vec bip_inline_vecs[0];/* embedded bvec array */ 322 + struct bio_vec bip_inline_vecs[];/* embedded bvec array */ 323 323 }; 324 324 325 325 #if defined(CONFIG_BLK_DEV_INTEGRITY)
+1 -1
include/linux/blk-mq.h
··· 173 173 * blocking (BLK_MQ_F_BLOCKING). Must be the last member - see also 174 174 * blk_mq_hw_ctx_size(). 175 175 */ 176 - struct srcu_struct srcu[0]; 176 + struct srcu_struct srcu[]; 177 177 }; 178 178 179 179 /**
+1 -1
include/linux/blk_types.h
··· 198 198 * double allocations for a small number of bio_vecs. This member 199 199 * MUST obviously be kept at the very end of the bio. 200 200 */ 201 - struct bio_vec bi_inline_vecs[0]; 201 + struct bio_vec bi_inline_vecs[]; 202 202 }; 203 203 204 204 #define BIO_RESET_BYTES offsetof(struct bio, bi_max_vecs)
+2 -2
include/linux/can/dev/peak_canfd.h
··· 189 189 u8 client; 190 190 __le16 flags; 191 191 __le32 can_id; 192 - u8 d[0]; 192 + u8 d[]; 193 193 }; 194 194 195 195 /* uCAN error types */ ··· 266 266 u8 client; 267 267 __le16 flags; 268 268 __le32 can_id; 269 - u8 d[0]; 269 + u8 d[]; 270 270 }; 271 271 272 272 /* build the cmd opcode_channel field with respect to the correct endianness */
+1 -1
include/linux/cpu_rmap.h
··· 28 28 struct { 29 29 u16 index; 30 30 u16 dist; 31 - } near[0]; 31 + } near[]; 32 32 }; 33 33 #define CPU_RMAP_DIST_INF 0xffff 34 34
+2 -2
include/linux/digsig.h
··· 29 29 uint32_t timestamp; /* key made, always 0 for now */ 30 30 uint8_t algo; 31 31 uint8_t nmpi; 32 - char mpi[0]; 32 + char mpi[]; 33 33 } __packed; 34 34 35 35 struct signature_hdr { ··· 39 39 uint8_t hash; 40 40 uint8_t keyid[8]; 41 41 uint8_t nmpi; 42 - char mpi[0]; 42 + char mpi[]; 43 43 } __packed; 44 44 45 45 #if defined(CONFIG_SIGNATURE) || defined(CONFIG_SIGNATURE_MODULE)
+1 -1
include/linux/dirent.h
··· 7 7 s64 d_off; 8 8 unsigned short d_reclen; 9 9 unsigned char d_type; 10 - char d_name[0]; 10 + char d_name[]; 11 11 }; 12 12 13 13 #endif
+1 -1
include/linux/enclosure.h
··· 101 101 struct device edev; 102 102 struct enclosure_component_callbacks *cb; 103 103 int components; 104 - struct enclosure_component component[0]; 104 + struct enclosure_component component[]; 105 105 }; 106 106 107 107 static inline struct enclosure_device *
+1 -1
include/linux/energy_model.h
··· 36 36 struct em_perf_domain { 37 37 struct em_cap_state *table; 38 38 int nr_cap_states; 39 - unsigned long cpus[0]; 39 + unsigned long cpus[]; 40 40 }; 41 41 42 42 #ifdef CONFIG_ENERGY_MODEL
+2 -2
include/linux/ethtool.h
··· 35 35 compat_u64 data; 36 36 struct compat_ethtool_rx_flow_spec fs; 37 37 u32 rule_cnt; 38 - u32 rule_locs[0]; 38 + u32 rule_locs[]; 39 39 }; 40 40 41 41 #endif /* CONFIG_COMPAT */ ··· 462 462 463 463 struct ethtool_rx_flow_rule { 464 464 struct flow_rule *rule; 465 - unsigned long priv[0]; 465 + unsigned long priv[]; 466 466 }; 467 467 468 468 struct ethtool_rx_flow_spec_input {
+1 -1
include/linux/genalloc.h
··· 76 76 void *owner; /* private data to retrieve at alloc time */ 77 77 unsigned long start_addr; /* start address of memory chunk */ 78 78 unsigned long end_addr; /* end address of memory chunk (inclusive) */ 79 - unsigned long bits[0]; /* bitmap for allocating memory chunk */ 79 + unsigned long bits[]; /* bitmap for allocating memory chunk */ 80 80 }; 81 81 82 82 /*
+1 -1
include/linux/igmp.h
··· 38 38 unsigned int sl_max; 39 39 unsigned int sl_count; 40 40 struct rcu_head rcu; 41 - __be32 sl_addr[0]; 41 + __be32 sl_addr[]; 42 42 }; 43 43 44 44 #define IP_SFLSIZE(count) (sizeof(struct ip_sf_socklist) + \
+1 -1
include/linux/ihex.h
··· 18 18 struct ihex_binrec { 19 19 __be32 addr; 20 20 __be16 len; 21 - uint8_t data[0]; 21 + uint8_t data[]; 22 22 } __attribute__((packed)); 23 23 24 24 static inline uint16_t ihex_binrec_size(const struct ihex_binrec *p)
+2 -2
include/linux/irq.h
··· 1043 1043 unsigned long unused; 1044 1044 struct irq_domain *domain; 1045 1045 struct list_head list; 1046 - struct irq_chip_type chip_types[0]; 1046 + struct irq_chip_type chip_types[]; 1047 1047 }; 1048 1048 1049 1049 /** ··· 1079 1079 unsigned int irq_flags_to_clear; 1080 1080 unsigned int irq_flags_to_set; 1081 1081 enum irq_gc_flags gc_flags; 1082 - struct irq_chip_generic *gc[0]; 1082 + struct irq_chip_generic *gc[]; 1083 1083 }; 1084 1084 1085 1085 /* Generic chip callback functions */
+1 -1
include/linux/list_lru.h
··· 34 34 struct list_lru_memcg { 35 35 struct rcu_head rcu; 36 36 /* array of per cgroup lists, indexed by memcg_cache_id */ 37 - struct list_lru_one *lru[0]; 37 + struct list_lru_one *lru[]; 38 38 }; 39 39 40 40 struct list_lru_node {
+2 -2
include/linux/memcontrol.h
··· 106 106 */ 107 107 struct memcg_shrinker_map { 108 108 struct rcu_head rcu; 109 - unsigned long map[0]; 109 + unsigned long map[]; 110 110 }; 111 111 112 112 /* ··· 148 148 /* Size of entries[] */ 149 149 unsigned int size; 150 150 /* Array of thresholds */ 151 - struct mem_cgroup_threshold entries[0]; 151 + struct mem_cgroup_threshold entries[]; 152 152 }; 153 153 154 154 struct mem_cgroup_thresholds {
+1 -1
include/linux/platform_data/wilco-ec.h
··· 83 83 u16 result; 84 84 u16 data_size; 85 85 u8 reserved[2]; 86 - u8 data[0]; 86 + u8 data[]; 87 87 } __packed; 88 88 89 89 /**
+1 -1
include/linux/posix_acl.h
··· 28 28 refcount_t a_refcount; 29 29 struct rcu_head a_rcu; 30 30 unsigned int a_count; 31 - struct posix_acl_entry a_entries[0]; 31 + struct posix_acl_entry a_entries[]; 32 32 }; 33 33 34 34 #define FOREACH_ACL_ENTRY(pa, acl, pe) \
+2 -2
include/linux/rio.h
··· 100 100 u32 port_ok; 101 101 struct rio_switch_ops *ops; 102 102 spinlock_t lock; 103 - struct rio_dev *nextdev[0]; 103 + struct rio_dev *nextdev[]; 104 104 }; 105 105 106 106 /** ··· 201 201 u8 hopcount; 202 202 struct rio_dev *prev; 203 203 atomic_t state; 204 - struct rio_switch rswitch[0]; /* RIO switch info */ 204 + struct rio_switch rswitch[]; /* RIO switch info */ 205 205 }; 206 206 207 207 #define rio_dev_g(n) list_entry(n, struct rio_dev, global_list)
+1 -1
include/linux/rslib.h
··· 54 54 */ 55 55 struct rs_control { 56 56 struct rs_codec *codec; 57 - uint16_t buffers[0]; 57 + uint16_t buffers[]; 58 58 }; 59 59 60 60 /* General purpose RS codec, 8-bit data width, symbol width 1-15 bit */
+1 -1
include/linux/sched/topology.h
··· 142 142 * by attaching extra space to the end of the structure, 143 143 * depending on how many CPUs the kernel has booted up with) 144 144 */ 145 - unsigned long span[0]; 145 + unsigned long span[]; 146 146 }; 147 147 148 148 static inline struct cpumask *sched_domain_span(struct sched_domain *sd)
+1 -1
include/linux/skbuff.h
··· 4162 4162 refcount_t refcnt; 4163 4163 u8 offset[SKB_EXT_NUM]; /* in chunks of 8 bytes */ 4164 4164 u8 chunks; /* same */ 4165 - char data[0] __aligned(8); 4165 + char data[] __aligned(8); 4166 4166 }; 4167 4167 4168 4168 struct skb_ext *__skb_ext_alloc(void);
+1 -1
include/linux/swap.h
··· 275 275 */ 276 276 struct work_struct discard_work; /* discard worker */ 277 277 struct swap_cluster_list discard_clusters; /* discard clusters list */ 278 - struct plist_node avail_lists[0]; /* 278 + struct plist_node avail_lists[]; /* 279 279 * entries in swap_avail_heads, one 280 280 * entry per node. 281 281 * Must be last as the number of the
+3 -3
include/linux/tpm_eventlog.h
··· 28 28 u32 event_type; 29 29 u8 pcr_value[20]; /* SHA1 */ 30 30 u32 event_size; 31 - u8 event_data[0]; 31 + u8 event_data[]; 32 32 }; 33 33 34 34 enum tcpa_event_types { ··· 55 55 struct tcpa_pc_event { 56 56 u32 event_id; 57 57 u32 event_size; 58 - u8 event_data[0]; 58 + u8 event_data[]; 59 59 }; 60 60 61 61 enum tcpa_pc_event_ids { ··· 102 102 103 103 struct tcg_event_field { 104 104 u32 event_size; 105 - u8 event[0]; 105 + u8 event[]; 106 106 } __packed; 107 107 108 108 struct tcg_pcr_event2_head {
+1 -1
include/linux/xattr.h
··· 73 73 struct list_head list; 74 74 char *name; 75 75 size_t size; 76 - char value[0]; 76 + char value[]; 77 77 }; 78 78 79 79 /*
+2 -2
include/uapi/linux/dlm_device.h
··· 45 45 void __user *bastaddr; 46 46 struct dlm_lksb __user *lksb; 47 47 char lvb[DLM_USER_LVB_LEN]; 48 - char name[0]; 48 + char name[]; 49 49 }; 50 50 51 51 struct dlm_lspace_params { 52 52 __u32 flags; 53 53 __u32 minor; 54 - char name[0]; 54 + char name[]; 55 55 }; 56 56 57 57 struct dlm_purge_params {
+1 -1
include/uapi/linux/fiemap.h
··· 34 34 __u32 fm_mapped_extents;/* number of extents that were mapped (out) */ 35 35 __u32 fm_extent_count; /* size of fm_extents array (in) */ 36 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 40 #define FIEMAP_MAX_OFFSET (~0ULL)