aboutsummaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>2025-01-21 15:48:44 -0300
committerAlistair Francis <alistair.francis@wdc.com>2025-03-04 15:42:53 +1000
commite07a89143bb2735858a1eefeb9bcd9eb637e8e8f (patch)
treebd868b183e8287e39d89495bfe9e2176d746ba46 /rust
parentbf031e257dea3d4d41f96d9eef77f447f56860e4 (diff)
downloadqemu-e07a89143bb2735858a1eefeb9bcd9eb637e8e8f.zip
qemu-e07a89143bb2735858a1eefeb9bcd9eb637e8e8f.tar.gz
qemu-e07a89143bb2735858a1eefeb9bcd9eb637e8e8f.tar.bz2
target/riscv/csr.c: fix 'ret' deadcode in rmw_xireg()
Coverity found a second DEADCODE issue in rmw_xireg() claiming that we can't reach 'RISCV_EXCP_NONE' at the 'done' label: > 2706 done: > 2707 if (ret) { > 2708 return (env->virt_enabled && virt) ? > 2709 RISCV_EXCP_VIRT_INSTRUCTION_FAULT : RISCV_EXCP_ILLEGAL_INST; > 2710 } >>>> CID 1590356: Control flow issues (DEADCODE) >>>> Execution cannot reach this statement: "return RISCV_EXCP_NONE;". > 2711 return RISCV_EXCP_NONE; Our label is now reduced after fixing another deadcode in the previous patch but the problem reported here still remains: done: if (ret) { return RISCV_EXCP_ILLEGAL_INST; } return RISCV_EXCP_NONE; This happens because 'ret' changes only once at the start of the function: ret = smstateen_acc_ok(env, 0, SMSTATEEN0_SVSLCT); if (ret != RISCV_EXCP_NONE) { return ret; } So it's a guarantee that ret will be RISCV_EXCP_NONE (-1) if we ever reach the label, i.e. "if (ret)" will always be true, and the label can be even further reduced to: done: return RISCV_EXCP_ILLEGAL_INST; To make a better use of the label, remove the 'else' from the xiselect_aia_range() chain and let it fall-through to the 'done' label since they are now both returning RISCV_EXCP_ILLEGAL_INST. Resolves: Coverity CID 1590356 Fixes: dc0280723d ("target/riscv: Decouple AIA processing from xiselect and xireg") Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20250121184847.2109128-3-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'rust')
0 files changed, 0 insertions, 0 deletions