aboutsummaryrefslogtreecommitdiff
path: root/rust/qemu-api
diff options
context:
space:
mode:
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>2025-01-21 15:48:43 -0300
committerAlistair Francis <alistair.francis@wdc.com>2025-03-04 15:42:53 +1000
commitbf031e257dea3d4d41f96d9eef77f447f56860e4 (patch)
tree4b6fbb69ae5a9888ff8638ef4189c22c0dc226d4 /rust/qemu-api
parent661c2e1ab29cd9c4d268ae3f44712e8d421c0e56 (diff)
downloadqemu-bf031e257dea3d4d41f96d9eef77f447f56860e4.zip
qemu-bf031e257dea3d4d41f96d9eef77f447f56860e4.tar.gz
qemu-bf031e257dea3d4d41f96d9eef77f447f56860e4.tar.bz2
target/riscv/csr.c: fix deadcode in rmw_xireg()
Coverity found a DEADCODE issue in rmw_xireg() claiming that we can't reach 'RISCV_EXCP_VIRT_INSTRUCTION_FAULT' at the 'done' label: done: if (ret) { return (env->virt_enabled && virt) ? RISCV_EXCP_VIRT_INSTRUCTION_FAULT : RISCV_EXCP_ILLEGAL_INST; } return RISCV_EXCP_NONE; This happens because the 'virt' flag, which is only used by 'done', is set to 'false' and it will always remain 'false' in any condition where we'll jump to 'done': switch (csrno) { (...) case CSR_VSIREG: isel = env->vsiselect; virt = true; break; default: goto done; }; 'virt = true' will never reach 'done' because we have a if/else-if/else block right before the label that will always return: if (xiselect_aia_range(isel)) { return ... } else if (...) { return ... } else { return RISCV_EXCP_ILLEGAL_INST; } All this means that we can preserve the current logic by reducing the 'done' label to: done: if (ret) { return RISCV_EXCP_ILLEGAL_INST; } return RISCV_EXCP_NONE; The flag 'virt' is now unused. Remove it. Fix the 'goto done' identation while we're at it. Resolves: Coverity CID 1590359 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-2-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'rust/qemu-api')
0 files changed, 0 insertions, 0 deletions