mirror of
https://github.com/armbian/linux-cix.git
synced 2026-01-06 12:30:45 -08:00
treewide: 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:
(next-20220214$ 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
];
};
UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.
[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
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
This commit is contained in:
@@ -152,7 +152,7 @@ struct memdesc_struct {
|
||||
unsigned long chksum;
|
||||
unsigned long optional_pa;
|
||||
unsigned long numclusters;
|
||||
struct memclust_struct cluster[0];
|
||||
struct memclust_struct cluster[];
|
||||
};
|
||||
|
||||
struct dsr_struct {
|
||||
|
||||
@@ -420,7 +420,7 @@ typedef struct sal_log_processor_info {
|
||||
* The rest of this structure consists of variable-length arrays, which can't be
|
||||
* expressed in C.
|
||||
*/
|
||||
sal_log_mod_error_info_t info[0];
|
||||
sal_log_mod_error_info_t info[];
|
||||
/*
|
||||
* This is what the rest looked like if C supported variable-length arrays:
|
||||
*
|
||||
|
||||
@@ -25,7 +25,7 @@ struct ccwgroup_device {
|
||||
unsigned int count;
|
||||
struct device dev;
|
||||
struct work_struct ungroup_work;
|
||||
struct ccw_device *cdev[0];
|
||||
struct ccw_device *cdev[];
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,7 +63,7 @@ struct chsc_pnso_area {
|
||||
struct chsc_header response;
|
||||
u32:32;
|
||||
struct chsc_pnso_naihdr naihdr;
|
||||
struct chsc_pnso_naid_l2 entries[0];
|
||||
struct chsc_pnso_naid_l2 entries[];
|
||||
} __packed __aligned(PAGE_SIZE);
|
||||
|
||||
#endif /* _ASM_S390_CHSC_H */
|
||||
|
||||
@@ -78,7 +78,7 @@ struct aob {
|
||||
|
||||
struct aob_rq_header {
|
||||
struct scm_device *scmdev;
|
||||
char data[0];
|
||||
char data[];
|
||||
};
|
||||
|
||||
struct scm_device {
|
||||
|
||||
@@ -214,7 +214,7 @@ struct dcw_intrg_data {
|
||||
u32 :32;
|
||||
u64 time;
|
||||
u64 prog_id;
|
||||
u8 prog_data[0];
|
||||
u8 prog_data[];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define DCW_FLAGS_CC (1 << (7 - 1))
|
||||
@@ -241,7 +241,7 @@ struct dcw {
|
||||
u32 :8;
|
||||
u32 cd_count:8;
|
||||
u32 count;
|
||||
u8 cd[0];
|
||||
u8 cd[];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define TCCB_FORMAT_DEFAULT 0x7f
|
||||
|
||||
@@ -108,7 +108,7 @@ clear_normalized_cda(struct ccw1 * ccw)
|
||||
struct idal_buffer {
|
||||
size_t size;
|
||||
size_t page_order;
|
||||
void *data[0];
|
||||
void *data[];
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -112,7 +112,7 @@ struct zpci_report_error_header {
|
||||
* (OpenCrypto Successful Diagnostics Execution)
|
||||
*/
|
||||
u16 length; /* Length of Subsequent Data (up to 4K – SCLP header */
|
||||
u8 data[0]; /* Subsequent Data passed verbatim to SCLP ET 24 */
|
||||
u8 data[]; /* Subsequent Data passed verbatim to SCLP ET 24 */
|
||||
} __packed;
|
||||
|
||||
extern char *sclp_early_sccb;
|
||||
|
||||
@@ -67,12 +67,12 @@ struct sysinfo_1_2_2 {
|
||||
unsigned short cpus_configured;
|
||||
unsigned short cpus_standby;
|
||||
unsigned short cpus_reserved;
|
||||
unsigned short adjustment[0];
|
||||
unsigned short adjustment[];
|
||||
};
|
||||
|
||||
struct sysinfo_1_2_2_extension {
|
||||
unsigned int alt_capability;
|
||||
unsigned short alt_adjustment[0];
|
||||
unsigned short alt_adjustment[];
|
||||
};
|
||||
|
||||
struct sysinfo_2_2_1 {
|
||||
@@ -181,7 +181,7 @@ struct sysinfo_15_1_x {
|
||||
unsigned char reserved1;
|
||||
unsigned char mnest;
|
||||
unsigned char reserved2[4];
|
||||
union topology_entry tle[0];
|
||||
union topology_entry tle[];
|
||||
};
|
||||
|
||||
int stsi(void *sysinfo, int fc, int sel1, int sel2);
|
||||
|
||||
@@ -33,7 +33,7 @@ struct thread_info {
|
||||
mm_segment_t addr_limit; /* thread address space */
|
||||
unsigned long previous_sp; /* sp of previous stack in case
|
||||
of nested IRQ stacks */
|
||||
__u8 supervisor_stack[0];
|
||||
__u8 supervisor_stack[];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -70,7 +70,7 @@ struct vio_dring_register {
|
||||
#define VIO_RX_DRING_DATA 0x0004
|
||||
u16 resv;
|
||||
u32 num_cookies;
|
||||
struct ldc_trans_cookie cookies[0];
|
||||
struct ldc_trans_cookie cookies[];
|
||||
};
|
||||
|
||||
struct vio_dring_unregister {
|
||||
@@ -161,7 +161,7 @@ struct vio_disk_desc {
|
||||
u64 size;
|
||||
u32 ncookies;
|
||||
u32 resv2;
|
||||
struct ldc_trans_cookie cookies[0];
|
||||
struct ldc_trans_cookie cookies[];
|
||||
};
|
||||
|
||||
#define VIO_DISK_VNAME_LEN 8
|
||||
@@ -200,13 +200,13 @@ struct vio_disk_devid {
|
||||
u16 resv;
|
||||
u16 type;
|
||||
u32 len;
|
||||
char id[0];
|
||||
char id[];
|
||||
};
|
||||
|
||||
struct vio_disk_efi {
|
||||
u64 lba;
|
||||
u64 len;
|
||||
char data[0];
|
||||
char data[];
|
||||
};
|
||||
|
||||
/* VIO net specific structures and defines */
|
||||
@@ -246,7 +246,7 @@ struct vio_net_desc {
|
||||
struct vio_dring_hdr hdr;
|
||||
u32 size;
|
||||
u32 ncookies;
|
||||
struct ldc_trans_cookie cookies[0];
|
||||
struct ldc_trans_cookie cookies[];
|
||||
};
|
||||
|
||||
struct vio_net_dext {
|
||||
|
||||
@@ -39,7 +39,7 @@ struct uml_net_private {
|
||||
|
||||
void (*add_address)(unsigned char *, unsigned char *, void *);
|
||||
void (*delete_address)(unsigned char *, unsigned char *, void *);
|
||||
char user[0];
|
||||
char user[];
|
||||
};
|
||||
|
||||
struct net_kern_info {
|
||||
|
||||
@@ -38,7 +38,7 @@ struct microcode_header_amd {
|
||||
|
||||
struct microcode_amd {
|
||||
struct microcode_header_amd hdr;
|
||||
unsigned int mpb[0];
|
||||
unsigned int mpb[];
|
||||
};
|
||||
|
||||
#define PATCH_MAX_SIZE (3 * PAGE_SIZE)
|
||||
|
||||
@@ -19,7 +19,7 @@ struct microcode_header_intel {
|
||||
|
||||
struct microcode_intel {
|
||||
struct microcode_header_intel hdr;
|
||||
unsigned int bits[0];
|
||||
unsigned int bits[];
|
||||
};
|
||||
|
||||
/* microcode format is extended from prescott processors */
|
||||
@@ -33,7 +33,7 @@ struct extended_sigtable {
|
||||
unsigned int count;
|
||||
unsigned int cksum;
|
||||
unsigned int reserved[3];
|
||||
struct extended_signature sigs[0];
|
||||
struct extended_signature sigs[];
|
||||
};
|
||||
|
||||
#define DEFAULT_UCODE_DATASIZE (2000)
|
||||
|
||||
@@ -135,7 +135,7 @@ struct pci_setup_rom {
|
||||
unsigned long bus;
|
||||
unsigned long device;
|
||||
unsigned long function;
|
||||
uint8_t romdata[0];
|
||||
uint8_t romdata[];
|
||||
};
|
||||
|
||||
#endif /* _ASM_X86_PCI_H */
|
||||
|
||||
@@ -87,7 +87,7 @@ struct irq_routing_table {
|
||||
u32 miniport_data; /* Crap */
|
||||
u8 rfu[11];
|
||||
u8 checksum; /* Modulo 256 checksum must give 0 */
|
||||
struct irq_info slots[0];
|
||||
struct irq_info slots[];
|
||||
} __attribute__((packed));
|
||||
|
||||
extern unsigned int pcibios_irq_mask;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
typedef struct bp_tag {
|
||||
unsigned short id; /* tag id */
|
||||
unsigned short size; /* size of this record excluding the structure*/
|
||||
unsigned long data[0]; /* data */
|
||||
unsigned long data[]; /* data */
|
||||
} bp_tag_t;
|
||||
|
||||
struct bp_meminfo {
|
||||
|
||||
@@ -144,7 +144,7 @@ struct ipsec_encap_pdb {
|
||||
};
|
||||
u32 spi;
|
||||
u32 ip_hdr_len;
|
||||
u32 ip_hdr[0];
|
||||
u32 ip_hdr[];
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ struct __guc_ads_blob {
|
||||
struct guc_gt_system_info system_info;
|
||||
struct guc_engine_usage engine_usage;
|
||||
/* From here on, location is dynamic! Refer to above diagram. */
|
||||
struct guc_mmio_reg regset[0];
|
||||
struct guc_mmio_reg regset[];
|
||||
} __packed;
|
||||
|
||||
static u32 guc_ads_regset_size(struct intel_guc *guc)
|
||||
|
||||
@@ -23,7 +23,7 @@ struct nvfw_hs_load_header {
|
||||
u32 data_dma_base;
|
||||
u32 data_size;
|
||||
u32 num_apps;
|
||||
u32 apps[0];
|
||||
u32 apps[];
|
||||
};
|
||||
|
||||
const struct nvfw_hs_load_header *
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user