mirror of
https://github.com/armbian/linux-cix.git
synced 2026-01-06 12:30:45 -08:00
treewide: uapi: Replace zero-length arrays with flexible-array members
There is a regular need in the kernel to provide a way to declare
having a dynamically sized set of trailing elements in a structure.
Kernel code should always use “flexible array members”[1] for these
cases. The older style of one-element or zero-length arrays should
no longer be used[2].
This code was transformed with the help of Coccinelle:
(linux-5.19-rc2$ spatch --jobs $(getconf _NPROCESSORS_ONLN) --sp-file script.cocci --include-headers --dir . > output.patch)
@@
identifier S, member, array;
type T1, T2;
@@
struct S {
...
T1 member;
T2 array[
- 0
];
};
-fstrict-flex-arrays=3 is coming and we need to land these changes
to prevent issues like these in the short future:
../fs/minix/dir.c:337:3: warning: 'strcpy' will always overflow; destination buffer has size 0,
but the source string has length 2 (including NUL byte) [-Wfortify-source]
strcpy(de3->name, ".");
^
Since these are all [0] to [] changes, the risk to UAPI is nearly zero. If
this breaks anything, we can use a union with a new member name.
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays
Link: https://github.com/KSPP/linux/issues/78
Build-tested-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/lkml/62b675ec.wKX6AOZ6cbE71vtF%25lkp@intel.com/
Acked-by: Dan Williams <dan.j.williams@intel.com> # For ndctl.h
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
struct bi_record {
|
||||
__be16 tag; /* tag ID */
|
||||
__be16 size; /* size of record (in bytes) */
|
||||
__be32 data[0]; /* data */
|
||||
__be32 data[]; /* data */
|
||||
};
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ struct bootversion {
|
||||
struct {
|
||||
__be32 machtype;
|
||||
__be32 version;
|
||||
} machversions[0];
|
||||
} machversions[];
|
||||
} __packed;
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
@@ -60,7 +60,7 @@ struct ucontext {
|
||||
sigset_t uc_sigmask;
|
||||
|
||||
/* Extended context structures may follow ucontext */
|
||||
unsigned long long uc_extcontext[0];
|
||||
unsigned long long uc_extcontext[];
|
||||
};
|
||||
|
||||
#endif /* __MIPS_UAPI_ASM_UCONTEXT_H */
|
||||
|
||||
@@ -30,18 +30,18 @@ struct s390_ctrset_start { /* Set CPUs to operate on */
|
||||
struct s390_ctrset_setdata { /* Counter set data */
|
||||
__u32 set; /* Counter set number */
|
||||
__u32 no_cnts; /* # of counters stored in cv[] */
|
||||
__u64 cv[0]; /* Counter values (variable length) */
|
||||
__u64 cv[]; /* Counter values (variable length) */
|
||||
};
|
||||
|
||||
struct s390_ctrset_cpudata { /* Counter set data per CPU */
|
||||
__u32 cpu_nr; /* CPU number */
|
||||
__u32 no_sets; /* # of counters sets in data[] */
|
||||
struct s390_ctrset_setdata data[0];
|
||||
struct s390_ctrset_setdata data[];
|
||||
};
|
||||
|
||||
struct s390_ctrset_read { /* Structure to get all ctr sets */
|
||||
__u64 no_cpus; /* Total # of CPUs data taken from */
|
||||
struct s390_ctrset_cpudata data[0];
|
||||
struct s390_ctrset_cpudata data[];
|
||||
};
|
||||
|
||||
#define S390_HWCTR_MAGIC 'C' /* Random magic # for ioctls */
|
||||
|
||||
@@ -52,7 +52,7 @@ struct setup_data {
|
||||
__u64 next;
|
||||
__u32 type;
|
||||
__u32 len;
|
||||
__u8 data[0];
|
||||
__u8 data[];
|
||||
};
|
||||
|
||||
/* extensible setup indirect data node */
|
||||
|
||||
@@ -198,13 +198,13 @@ struct kvm_msrs {
|
||||
__u32 nmsrs; /* number of msrs in entries */
|
||||
__u32 pad;
|
||||
|
||||
struct kvm_msr_entry entries[0];
|
||||
struct kvm_msr_entry entries[];
|
||||
};
|
||||
|
||||
/* for KVM_GET_MSR_INDEX_LIST */
|
||||
struct kvm_msr_list {
|
||||
__u32 nmsrs; /* number of msrs in entries */
|
||||
__u32 indices[0];
|
||||
__u32 indices[];
|
||||
};
|
||||
|
||||
/* Maximum size of any access bitmap in bytes */
|
||||
@@ -241,7 +241,7 @@ struct kvm_cpuid_entry {
|
||||
struct kvm_cpuid {
|
||||
__u32 nent;
|
||||
__u32 padding;
|
||||
struct kvm_cpuid_entry entries[0];
|
||||
struct kvm_cpuid_entry entries[];
|
||||
};
|
||||
|
||||
struct kvm_cpuid_entry2 {
|
||||
@@ -263,7 +263,7 @@ struct kvm_cpuid_entry2 {
|
||||
struct kvm_cpuid2 {
|
||||
__u32 nent;
|
||||
__u32 padding;
|
||||
struct kvm_cpuid_entry2 entries[0];
|
||||
struct kvm_cpuid_entry2 entries[];
|
||||
};
|
||||
|
||||
/* for KVM_GET_PIT and KVM_SET_PIT */
|
||||
@@ -389,7 +389,7 @@ struct kvm_xsave {
|
||||
* the contents of CPUID leaf 0xD on the host.
|
||||
*/
|
||||
__u32 region[1024];
|
||||
__u32 extra[0];
|
||||
__u32 extra[];
|
||||
};
|
||||
|
||||
#define KVM_MAX_XCRS 16
|
||||
@@ -516,7 +516,7 @@ struct kvm_pmu_event_filter {
|
||||
__u32 fixed_counter_bitmap;
|
||||
__u32 flags;
|
||||
__u32 pad[4];
|
||||
__u64 events[0];
|
||||
__u64 events[];
|
||||
};
|
||||
|
||||
#define KVM_PMU_EVENT_ALLOW 0
|
||||
|
||||
@@ -2123,7 +2123,7 @@ struct i915_context_engines_load_balance {
|
||||
|
||||
__u64 mbz64; /* reserved for future use; must be zero */
|
||||
|
||||
struct i915_engine_class_instance engines[0];
|
||||
struct i915_engine_class_instance engines[];
|
||||
} __attribute__((packed));
|
||||
|
||||
#define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
|
||||
@@ -2161,7 +2161,7 @@ struct i915_context_engines_bond {
|
||||
__u64 flags; /* all undefined flags must be zero */
|
||||
__u64 mbz64[4]; /* reserved for future use; must be zero */
|
||||
|
||||
struct i915_engine_class_instance engines[0];
|
||||
struct i915_engine_class_instance engines[];
|
||||
} __attribute__((packed));
|
||||
|
||||
#define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
|
||||
@@ -2288,7 +2288,7 @@ struct i915_context_engines_parallel_submit {
|
||||
* length = width (i) * num_siblings (j)
|
||||
* index = j + i * num_siblings
|
||||
*/
|
||||
struct i915_engine_class_instance engines[0];
|
||||
struct i915_engine_class_instance engines[];
|
||||
|
||||
} __packed;
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ struct blk_zone_report {
|
||||
__u64 sector;
|
||||
__u32 nr_zones;
|
||||
__u32 flags;
|
||||
struct blk_zone zones[0];
|
||||
struct blk_zone zones[];
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,7 +79,7 @@ struct bpf_insn {
|
||||
/* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
|
||||
struct bpf_lpm_trie_key {
|
||||
__u32 prefixlen; /* up to 32 for AF_INET, 128 for AF_INET6 */
|
||||
__u8 data[0]; /* Arbitrary size */
|
||||
__u8 data[]; /* Arbitrary size */
|
||||
};
|
||||
|
||||
struct bpf_cgroup_storage_key {
|
||||
|
||||
@@ -93,7 +93,7 @@ struct btrfs_qgroup_inherit {
|
||||
__u64 num_ref_copies;
|
||||
__u64 num_excl_copies;
|
||||
struct btrfs_qgroup_limit lim;
|
||||
__u64 qgroups[0];
|
||||
__u64 qgroups[];
|
||||
};
|
||||
|
||||
struct btrfs_ioctl_qgroup_limit_args {
|
||||
@@ -561,7 +561,7 @@ struct btrfs_ioctl_search_args_v2 {
|
||||
__u64 buf_size; /* in - size of buffer
|
||||
* out - on EOVERFLOW: needed size
|
||||
* to store item */
|
||||
__u64 buf[0]; /* out - found items */
|
||||
__u64 buf[]; /* out - found items */
|
||||
};
|
||||
|
||||
struct btrfs_ioctl_clone_range_args {
|
||||
@@ -632,7 +632,7 @@ struct btrfs_ioctl_same_args {
|
||||
__u16 dest_count; /* in - total elements in info array */
|
||||
__u16 reserved1;
|
||||
__u32 reserved2;
|
||||
struct btrfs_ioctl_same_extent_info info[0];
|
||||
struct btrfs_ioctl_same_extent_info info[];
|
||||
};
|
||||
|
||||
struct btrfs_ioctl_space_info {
|
||||
@@ -644,7 +644,7 @@ struct btrfs_ioctl_space_info {
|
||||
struct btrfs_ioctl_space_args {
|
||||
__u64 space_slots;
|
||||
__u64 total_spaces;
|
||||
struct btrfs_ioctl_space_info spaces[0];
|
||||
struct btrfs_ioctl_space_info spaces[];
|
||||
};
|
||||
|
||||
struct btrfs_data_container {
|
||||
@@ -652,7 +652,7 @@ struct btrfs_data_container {
|
||||
__u32 bytes_missing; /* out -- additional bytes needed for result */
|
||||
__u32 elem_cnt; /* out */
|
||||
__u32 elem_missed; /* out */
|
||||
__u64 val[0]; /* out */
|
||||
__u64 val[]; /* out */
|
||||
};
|
||||
|
||||
struct btrfs_ioctl_ino_path_args {
|
||||
|
||||
@@ -575,7 +575,7 @@ struct btrfs_inode_extref {
|
||||
__le64 parent_objectid;
|
||||
__le64 index;
|
||||
__le16 name_len;
|
||||
__u8 name[0];
|
||||
__u8 name[];
|
||||
/* name goes here */
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ struct bcm_msg_head {
|
||||
struct bcm_timeval ival1, ival2;
|
||||
canid_t can_id;
|
||||
__u32 nframes;
|
||||
struct can_frame frames[0];
|
||||
struct can_frame frames[];
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
@@ -75,7 +75,7 @@ struct cn_msg {
|
||||
|
||||
__u16 len; /* Length of the following data */
|
||||
__u16 flags;
|
||||
__u8 data[0];
|
||||
__u8 data[];
|
||||
};
|
||||
|
||||
#endif /* _UAPI__CONNECTOR_H */
|
||||
|
||||
@@ -91,7 +91,7 @@ struct cycx_firmware {
|
||||
unsigned short reserved[6];
|
||||
char descr[CFM_DESCR_LEN];
|
||||
struct cycx_fw_info info;
|
||||
unsigned char image[0];
|
||||
unsigned char image[];
|
||||
};
|
||||
|
||||
struct cycx_fw_header {
|
||||
|
||||
@@ -182,7 +182,7 @@ struct dm_target_spec {
|
||||
struct dm_target_deps {
|
||||
__u32 count; /* Array size */
|
||||
__u32 padding; /* unused */
|
||||
__u64 dev[0]; /* out */
|
||||
__u64 dev[]; /* out */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -192,7 +192,7 @@ struct dm_name_list {
|
||||
__u64 dev;
|
||||
__u32 next; /* offset to the next record from
|
||||
the _start_ of this */
|
||||
char name[0];
|
||||
char name[];
|
||||
|
||||
/*
|
||||
* The following members can be accessed by taking a pointer that
|
||||
@@ -216,7 +216,7 @@ struct dm_target_versions {
|
||||
__u32 next;
|
||||
__u32 version[3];
|
||||
|
||||
char name[0];
|
||||
char name[];
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -225,7 +225,7 @@ struct dm_target_versions {
|
||||
struct dm_target_msg {
|
||||
__u64 sector; /* Device sector */
|
||||
|
||||
char message[0];
|
||||
char message[];
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -426,7 +426,7 @@ struct dm_ulog_request {
|
||||
__u32 request_type; /* DM_ULOG_* defined above */
|
||||
__u32 data_size; /* How much data (not including this struct) */
|
||||
|
||||
char data[0];
|
||||
char data[];
|
||||
};
|
||||
|
||||
#endif /* __DM_LOG_USERSPACE_H__ */
|
||||
|
||||
@@ -257,7 +257,7 @@ struct ethtool_tunable {
|
||||
__u32 id;
|
||||
__u32 type_id;
|
||||
__u32 len;
|
||||
void *data[0];
|
||||
void *data[];
|
||||
};
|
||||
|
||||
#define DOWNSHIFT_DEV_DEFAULT_COUNT 0xff
|
||||
@@ -322,7 +322,7 @@ struct ethtool_regs {
|
||||
__u32 cmd;
|
||||
__u32 version;
|
||||
__u32 len;
|
||||
__u8 data[0];
|
||||
__u8 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -348,7 +348,7 @@ struct ethtool_eeprom {
|
||||
__u32 magic;
|
||||
__u32 offset;
|
||||
__u32 len;
|
||||
__u8 data[0];
|
||||
__u8 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -752,7 +752,7 @@ struct ethtool_gstrings {
|
||||
__u32 cmd;
|
||||
__u32 string_set;
|
||||
__u32 len;
|
||||
__u8 data[0];
|
||||
__u8 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -777,7 +777,7 @@ struct ethtool_sset_info {
|
||||
__u32 cmd;
|
||||
__u32 reserved;
|
||||
__u64 sset_mask;
|
||||
__u32 data[0];
|
||||
__u32 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -817,7 +817,7 @@ struct ethtool_test {
|
||||
__u32 flags;
|
||||
__u32 reserved;
|
||||
__u32 len;
|
||||
__u64 data[0];
|
||||
__u64 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -834,7 +834,7 @@ struct ethtool_test {
|
||||
struct ethtool_stats {
|
||||
__u32 cmd;
|
||||
__u32 n_stats;
|
||||
__u64 data[0];
|
||||
__u64 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -851,7 +851,7 @@ struct ethtool_stats {
|
||||
struct ethtool_perm_addr {
|
||||
__u32 cmd;
|
||||
__u32 size;
|
||||
__u8 data[0];
|
||||
__u8 data[];
|
||||
};
|
||||
|
||||
/* boolean flags controlling per-interface behavior characteristics.
|
||||
@@ -1160,7 +1160,7 @@ struct ethtool_rxnfc {
|
||||
struct ethtool_rxfh_indir {
|
||||
__u32 cmd;
|
||||
__u32 size;
|
||||
__u32 ring_index[0];
|
||||
__u32 ring_index[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1201,7 +1201,7 @@ struct ethtool_rxfh {
|
||||
__u8 hfunc;
|
||||
__u8 rsvd8[3];
|
||||
__u32 rsvd32;
|
||||
__u32 rss_config[0];
|
||||
__u32 rss_config[];
|
||||
};
|
||||
#define ETH_RXFH_CONTEXT_ALLOC 0xffffffff
|
||||
#define ETH_RXFH_INDIR_NO_CHANGE 0xffffffff
|
||||
@@ -1286,7 +1286,7 @@ struct ethtool_dump {
|
||||
__u32 version;
|
||||
__u32 flag;
|
||||
__u32 len;
|
||||
__u8 data[0];
|
||||
__u8 data[];
|
||||
};
|
||||
|
||||
#define ETH_FW_DUMP_DISABLE 0
|
||||
@@ -1318,7 +1318,7 @@ struct ethtool_get_features_block {
|
||||
struct ethtool_gfeatures {
|
||||
__u32 cmd;
|
||||
__u32 size;
|
||||
struct ethtool_get_features_block features[0];
|
||||
struct ethtool_get_features_block features[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1340,7 +1340,7 @@ struct ethtool_set_features_block {
|
||||
struct ethtool_sfeatures {
|
||||
__u32 cmd;
|
||||
__u32 size;
|
||||
struct ethtool_set_features_block features[0];
|
||||
struct ethtool_set_features_block features[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2087,7 +2087,7 @@ struct ethtool_link_settings {
|
||||
__u8 master_slave_state;
|
||||
__u8 reserved1[1];
|
||||
__u32 reserved[7];
|
||||
__u32 link_mode_masks[0];
|
||||
__u32 link_mode_masks[];
|
||||
/* layout of link_mode_masks fields:
|
||||
* __u32 map_supported[link_mode_masks_nwords];
|
||||
* __u32 map_advertising[link_mode_masks_nwords];
|
||||
|
||||
@@ -162,7 +162,7 @@ struct fanotify_event_info_fid {
|
||||
* Following is an opaque struct file_handle that can be passed as
|
||||
* an argument to open_by_handle_at(2).
|
||||
*/
|
||||
unsigned char handle[0];
|
||||
unsigned char handle[];
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -34,7 +34,7 @@ struct fiemap {
|
||||
__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
|
||||
__u32 fm_extent_count; /* size of fm_extents array (in) */
|
||||
__u32 fm_reserved;
|
||||
struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
|
||||
struct fiemap_extent fm_extents[]; /* array of mapped extents (out) */
|
||||
};
|
||||
|
||||
#define FIEMAP_MAX_OFFSET (~0ULL)
|
||||
|
||||
@@ -118,7 +118,7 @@ struct fw_cdev_event_response {
|
||||
__u32 type;
|
||||
__u32 rcode;
|
||||
__u32 length;
|
||||
__u32 data[0];
|
||||
__u32 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -142,7 +142,7 @@ struct fw_cdev_event_request {
|
||||
__u64 offset;
|
||||
__u32 handle;
|
||||
__u32 length;
|
||||
__u32 data[0];
|
||||
__u32 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -205,7 +205,7 @@ struct fw_cdev_event_request2 {
|
||||
__u32 generation;
|
||||
__u32 handle;
|
||||
__u32 length;
|
||||
__u32 data[0];
|
||||
__u32 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -265,7 +265,7 @@ struct fw_cdev_event_iso_interrupt {
|
||||
__u32 type;
|
||||
__u32 cycle;
|
||||
__u32 header_length;
|
||||
__u32 header[0];
|
||||
__u32 header[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -355,7 +355,7 @@ struct fw_cdev_event_phy_packet {
|
||||
__u32 type;
|
||||
__u32 rcode;
|
||||
__u32 length;
|
||||
__u32 data[0];
|
||||
__u32 data[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -803,7 +803,7 @@ struct fw_cdev_set_iso_channels {
|
||||
*/
|
||||
struct fw_cdev_iso_packet {
|
||||
__u32 control;
|
||||
__u32 header[0];
|
||||
__u32 header[];
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,7 +90,7 @@ struct file_dedupe_range {
|
||||
__u16 dest_count; /* in - total elements in info array */
|
||||
__u16 reserved1; /* must be zero */
|
||||
__u32 reserved2; /* must be zero */
|
||||
struct file_dedupe_range_info info[0];
|
||||
struct file_dedupe_range_info info[];
|
||||
};
|
||||
|
||||
/* And dynamically-tunable limits and defaults: */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user