treewide: Replace zero-length arrays with flexible-array members
authorGustavo A. R. Silva <gustavoars@kernel.org>
Tue, 15 Feb 2022 01:11:44 +0000 (19:11 -0600)
committerGustavo A. R. Silva <gustavoars@kernel.org>
Thu, 17 Feb 2022 13:00:39 +0000 (07:00 -0600)
commit5224f79096170bf7b92cc8fe42a12f44b91e5f62
tree4a1aa6767d05015793171bb77b07b042a830fc4c
parent26291c54e111ff6ba87a164d85d4a4e134b7315c
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>
66 files changed:
arch/alpha/include/asm/hwrpb.h
arch/ia64/include/asm/sal.h
arch/s390/include/asm/ccwgroup.h
arch/s390/include/asm/chsc.h
arch/s390/include/asm/eadm.h
arch/s390/include/asm/fcx.h
arch/s390/include/asm/idals.h
arch/s390/include/asm/sclp.h
arch/s390/include/asm/sysinfo.h
arch/sh/include/asm/thread_info.h
arch/sparc/include/asm/vio.h
arch/um/include/shared/net_kern.h
arch/x86/include/asm/microcode_amd.h
arch/x86/include/asm/microcode_intel.h
arch/x86/include/asm/pci.h
arch/x86/include/asm/pci_x86.h
arch/xtensa/include/asm/bootparam.h
drivers/crypto/caam/pdb.h
drivers/gpu/drm/i915/gt/uc/intel_guc_ads.c
drivers/gpu/drm/nouveau/include/nvfw/hs.h
drivers/hwtracing/coresight/coresight-config.h
drivers/misc/bcm-vk/bcm_vk.h
drivers/misc/habanalabs/include/common/cpucp_if.h
drivers/misc/habanalabs/include/gaudi/gaudi_packets.h
drivers/misc/habanalabs/include/goya/goya_packets.h
drivers/net/ethernet/freescale/enetc/enetc_hw.h
drivers/net/ethernet/i825xx/sun3_82586.h
drivers/net/ethernet/marvell/octeontx2/af/npc.h
drivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h
drivers/net/ethernet/ti/davinci_mdio.c
drivers/scsi/dpt/dpti_i2o.h
drivers/scsi/elx/libefc_sli/sli4.h
drivers/scsi/mpi3mr/mpi3mr.h
drivers/scsi/qla2xxx/qla_bsg.h
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_edif_bsg.h
drivers/scsi/qla2xxx/qla_fw.h
drivers/scsi/qla4xxx/ql4_fw.h
drivers/staging/r8188eu/include/rtw_cmd.h
drivers/staging/rtl8712/rtl871x_cmd.h
drivers/staging/rtl8723bs/include/ieee80211.h
drivers/staging/rtl8723bs/include/rtw_cmd.h
drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h
drivers/visorbus/vbuschannel.h
fs/cifs/ntlmssp.h
fs/ext4/fast_commit.h
fs/ksmbd/ksmbd_netlink.h
fs/ksmbd/ntlmssp.h
fs/ksmbd/smb2pdu.h
fs/ksmbd/transport_rdma.c
fs/ksmbd/xattr.h
fs/xfs/scrub/attr.h
include/asm-generic/tlb.h
include/linux/greybus/greybus_manifest.h
include/linux/greybus/hd.h
include/linux/greybus/module.h
include/linux/i3c/ccc.h
include/linux/platform_data/brcmfmac.h
include/linux/platform_data/cros_ec_commands.h
include/net/bluetooth/mgmt.h
include/net/ioam6.h
include/sound/sof/channel_map.h
scripts/dtc/libfdt/fdt.h
sound/soc/intel/atom/sst-mfld-dsp.h
sound/soc/intel/skylake/skl-topology.h
tools/lib/perf/include/perf/event.h