560b8e1d70
KVM_RISCV_GET_CSR() and KVM_RISCV_SET_CSR() use an 'int ret' variable
that is used to do an early 'return' if ret > 0. Both are being called
in functions that are also declaring a 'ret' integer, initialized with
'0', and this integer is used as return of the function.
The result is that the compiler is less than pleased and is pointing
shadowing errors:
../target/riscv/kvm/kvm-cpu.c: In function 'kvm_riscv_get_regs_csr':
../target/riscv/kvm/kvm-cpu.c:90:13: error: declaration of 'ret' shadows a previous local [-Werror=shadow=compatible-local]
90 | int ret = kvm_get_one_reg(cs, RISCV_CSR_REG(env, csr), ®); \
| ^~~
../target/riscv/kvm/kvm-cpu.c:539:5: note: in expansion of macro 'KVM_RISCV_GET_CSR'
539 | KVM_RISCV_GET_CSR(cs, env, sstatus, env->mstatus);
| ^~~~~~~~~~~~~~~~~
../target/riscv/kvm/kvm-cpu.c:536:9: note: shadowed declaration is here
536 | int ret = 0;
| ^~~
../target/riscv/kvm/kvm-cpu.c: In function 'kvm_riscv_put_regs_csr':
../target/riscv/kvm/kvm-cpu.c:98:13: error: declaration of 'ret' shadows a previous local [-Werror=shadow=compatible-local]
98 | int ret = kvm_set_one_reg(cs, RISCV_CSR_REG(env, csr), ®); \
| ^~~
../target/riscv/kvm/kvm-cpu.c:556:5: note: in expansion of macro 'KVM_RISCV_SET_CSR'
556 | KVM_RISCV_SET_CSR(cs, env, sstatus, env->mstatus);
| ^~~~~~~~~~~~~~~~~
../target/riscv/kvm/kvm-cpu.c:553:9: note: shadowed declaration is here
553 | int ret = 0;
| ^~~
The macros are doing early returns for non-zero returns and the local
'ret' variable for both functions is used just to do 'return 0', so
remove them from kvm_riscv_get_regs_csr() and kvm_riscv_put_regs_csr()
and do a straight 'return 0' in the end.
For good measure let's also rename the 'ret' variables in
KVM_RISCV_GET_CSR() and KVM_RISCV_SET_CSR() to '_ret' to make them more
resilient to these kind of errors.
Fixes:
|
||
---|---|---|
.. | ||
insn_trans | ||
kvm | ||
tcg | ||
arch_dump.c | ||
bitmanip_helper.c | ||
common-semi-target.h | ||
cpu_bits.h | ||
cpu_cfg.h | ||
cpu_helper.c | ||
cpu_user.h | ||
cpu_vendorid.h | ||
cpu-param.h | ||
cpu-qom.h | ||
cpu.c | ||
cpu.h | ||
crypto_helper.c | ||
csr.c | ||
debug.c | ||
debug.h | ||
fpu_helper.c | ||
gdbstub.c | ||
helper.h | ||
insn16.decode | ||
insn32.decode | ||
instmap.h | ||
internals.h | ||
Kconfig | ||
m128_helper.c | ||
machine.c | ||
meson.build | ||
monitor.c | ||
op_helper.c | ||
pmp.c | ||
pmp.h | ||
pmu.c | ||
pmu.h | ||
riscv-qmp-cmds.c | ||
sbi_ecall_interface.h | ||
time_helper.c | ||
time_helper.h | ||
trace-events | ||
trace.h | ||
translate.c | ||
vcrypto_helper.c | ||
vector_helper.c | ||
vector_internals.c | ||
vector_internals.h | ||
xthead.decode | ||
XVentanaCondOps.decode | ||
zce_helper.c |