linux/arch/mips/kernel
Gustavo A. R. Silva c4ad6ea957 MIPS: Replace zero-length array with flexible-array
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 conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 7649773293 ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2020-05-08 12:01:02 +02:00
..
syscalls asm-generic: fix unistd_32.h generation format 2020-04-07 10:43:42 -07:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
8250-platform.c
asm-offsets.c MIPS: Remove struct task_struct fpu state when CONFIG_MIPS_FP_SUPPORT=n 2018-11-09 10:23:19 -08:00
binfmt_elfn32.c y2038: elfcore: Use __kernel_old_timeval for process times 2019-11-15 14:38:29 +01:00
binfmt_elfo32.c y2038: elfcore: Use __kernel_old_timeval for process times 2019-11-15 14:38:29 +01:00
bmips_5xxx_init.S MIPS: BCM5xxx: Remove dead init_fpu code 2018-11-08 11:20:57 -08:00
bmips_vec.S MIPS: BMIPS: Add Whirlwind (BMIPS5200) initialization code 2016-05-09 12:00:01 +02:00
branch.c MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
cacheinfo.c mips: cacheinfo: report shared CPU map 2019-11-26 10:33:08 -08:00
cevt-bcm1480.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cevt-ds1287.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cevt-gt641xx.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cevt-r4k.c MIPS: pass non-NULL dev_id on shared request_irq() 2020-03-16 16:04:49 +01:00
cevt-sb1250.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cevt-txx9.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
cmpxchg.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cps-vec-ns16550.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cps-vec.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cpu-probe.c MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
crash.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
crash_dump.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
csrc-bcm1480.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
csrc-ioasic.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
csrc-r4k.c mips: vdso: Use generic VDSO clock mode storage 2020-02-17 20:12:16 +01:00
csrc-sb1250.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
early_printk.c mips: unify prom_putchar() declarations 2018-07-17 09:40:17 -07:00
early_printk_8250.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 1 2019-05-21 11:28:39 +02:00
elf.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
entry.S sched/rt, MIPS: Use CONFIG_PREEMPTION 2019-12-08 14:37:34 +01:00
ftrace.c MIPS: ftrace: Reword prepare_ftrace_return() comment block 2019-06-11 15:46:21 -07:00
genex.S MIPS: asm: Rename some macros to avoid build errors 2020-05-07 13:20:05 +02:00
gpio_txx9.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
head.S MIPS: Clear XContext at boot time 2020-04-24 18:37:23 +02:00
i8253.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
idle.c MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
irq-gt641xx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 1 2019-05-21 11:28:39 +02:00
irq-msc01.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq-rm7000.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq.c MIPS: irq: Allocate accurate order pages for irq stack 2019-02-19 12:45:01 -08:00
irq_txx9.c
jump_label.c MIPS: jump_label: Use compact branches for >= r6 2019-04-09 16:21:30 -07:00
kgdb.c MIPS: KGDB: fix kgdb support for SMP platforms. 2019-03-28 11:35:58 -07:00
kprobes.c mm, kprobes: generalize and rename notify_page_fault() as kprobe_page_fault() 2019-07-16 19:23:22 -07:00
linux32.c MIPS: Delete unused code in linux32.c 2018-08-01 13:20:27 -07:00
machine_kexec.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 230 2019-06-19 17:09:06 +02:00
Makefile MIPS: r4k-bugs64: Limit R4k bug checks to affected systems 2019-10-07 09:38:53 -07:00
mcount.S mips: ftrace: fix static function graph tracing 2018-06-19 15:00:12 -07:00
mips-cm.c mips: cm: Add L2 ECC/parity errors reporting 2020-05-07 13:11:38 +02:00
mips-cpc.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
mips-mt-fpaff.c sched/core: Provide a pointer to the valid CPU mask 2019-06-03 11:49:37 +02:00
mips-mt.c MIPS: MT: Remove norps command line parameter 2018-11-26 22:49:14 -08:00
mips-r2-to-r6-emul.c MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
mips_machine.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
module.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
octeon_switch.S Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables 2018-06-14 12:21:18 +09:00
perf_event.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
perf_event_mipsxx.c MIPS: perf: Remove unnecessary "fallthrough" pseudo keywords 2020-05-02 13:21:09 +02:00
pm-cps.c MIPS: barrier: Add __SYNC() infrastructure 2019-10-07 09:42:17 -07:00
pm.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
probes-common.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
proc.c MIPS: Treat Loongson Extensions as ASEs 2019-08-26 11:42:40 +01:00
process.c MIPS: Exclude more dsemul code when CONFIG_MIPS_FP_SUPPORT=n 2020-03-25 16:07:14 +01:00
prom.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
ptrace.c audit/stable-5.2 PR 20190507 2019-05-07 19:06:04 -07:00
ptrace32.c MIPS: ptrace: Remove FP support when CONFIG_MIPS_FP_SUPPORT=n 2018-11-09 10:23:17 -08:00
r4k-bugs64.c MIPS: r4k-bugs64: Drop CONFIG_CPU_MIPSR6 checks 2019-10-07 09:38:54 -07:00
r4k_fpu.S MIPS: Simplify FP context initialization 2018-11-09 10:23:13 -08:00
r4k_switch.S Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables 2018-06-14 12:21:18 +09:00
r2300_fpu.S MIPS: Simplify FP context initialization 2018-11-09 10:23:13 -08:00
r2300_switch.S Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables 2018-06-14 12:21:18 +09:00
relocate.c MIPS: Remove no-op/identity casts 2018-08-31 11:49:20 -07:00
relocate_kernel.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 230 2019-06-19 17:09:06 +02:00
reset.c MIPS: Hang more efficiently on halt/powerdown/restart 2018-03-09 11:22:43 +00:00
rtlx-cmp.c
rtlx-mt.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
rtlx.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
scall32-o32.S mips: remove nargs from __SYSCALL 2019-07-30 10:50:30 -07:00
scall64-n32.S mips: remove nargs from __SYSCALL 2019-07-30 10:50:30 -07:00
scall64-n64.S mips: remove nargs from __SYSCALL 2019-07-30 10:50:30 -07:00
scall64-o32.S MIPS: asm: Rename some macros to avoid build errors 2020-05-07 13:20:05 +02:00
segment.c mips: kernel: no need to check return value of debugfs_create functions 2019-01-22 11:17:20 -08:00
setup.c MIPS: Make sparse_init() using top-down allocation 2020-04-21 16:07:27 +02:00
signal-common.h
signal.c MIPS: Replace zero-length array with flexible-array 2020-05-08 12:01:02 +02:00
signal32.c Remove 'type' argument from access_ok() function 2019-01-03 18:57:57 -08:00
signal_n32.c Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2019-07-08 21:48:15 -07:00
signal_o32.c signal: Remove task parameter from force_sig 2019-05-27 09:36:28 -05:00
smp-bmips.c MIPS: Drop pmon.h 2019-11-11 10:44:52 -08:00
smp-cmp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 182 2019-05-30 11:29:20 -07:00
smp-cps.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
smp-mt.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 182 2019-05-30 11:29:20 -07:00
smp-up.c MIPS: SMP: Allow boot_secondary SMP op to return errors 2017-08-30 00:57:27 +02:00
smp.c MIPS updates for v5.7: 2020-03-31 08:51:45 -07:00
spinlock_test.c mips: kernel: no need to check return value of debugfs_create functions 2019-01-22 11:17:20 -08:00
spram.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
stacktrace.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
sync-r4k.c MIPS: sync-r4k: do slave counter synchronization with disabled HW interrupts 2020-01-22 10:16:18 -08:00
syscall.c MIPS: syscall: Emit Loongson3 sync workarounds within asm 2019-10-07 09:43:05 -07:00
sysrq.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
time.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
topology.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
traps.c MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
unaligned.c MIPS: Move unaligned load/store helpers to inst.h 2020-04-24 18:18:06 +02:00
uprobes.c MIPS: uprobes: remove set but not used variable 'epc' 2019-05-29 13:20:30 -07:00
vdso.c MIPS: Exclude more dsemul code when CONFIG_MIPS_FP_SUPPORT=n 2020-03-25 16:07:14 +01:00
vmlinux.lds.S MIPS: Truncate link address into 32bit for 32bit kernel 2020-05-07 10:31:01 +02:00
vpe-cmp.c
vpe-mt.c
vpe.c MIPS: VPE: Fix a double free and a memory leak in 'release_vpe()' 2020-02-15 12:44:03 -08:00
watch.c MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00