Coverity 1390849, Logically dead code
In the latest Coverity scan, it reports
405 if (csrno >= CSR_MHPMCOUNTER3 && csrno <= CSR_MHPMCOUNTER31) {
406 return 0;
407 }
408#if defined(TARGET_RISCV32)
409 if (csrno >= CSR_MHPMCOUNTER3 && csrno <= CSR_MHPMCOUNTER31) {
CID 1390849 (#1 of 1): Logically dead code (DEADCODE)dead_error_line: Execution cannot reach this statement: return 0U;.
410 return 0;
411 }
412#endif
I believe the condition at op_helper.c:409 should be testing CSR_MHPMCOUNTER3H and CSR_MHPMCOUNTER31H. Must run now, otherwise I'd also send the trivial patch.
r~
Quoted 16 lines · Richard Henderson
In the latest Coverity scan, it reports
405 if (csrno >=
CSR_MHPMCOUNTER3&& csrno <=CSR_MHPMCOUNTER31) {
406 return 0;
407 }
408#ifdefined(TARGET_RISCV32)
409 if (csrno >=CSR_MHPMCOUNTER3&& csrno <=CSR_MHPMCOUNTER31) {CID 1390849 (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: return 0U;.410 return 0;
411 }
412#endif
Quoted 4 lines
I believe the condition at op_helper.c:409 should be testing
CSR_MHPMCOUNTER3H
andCSR_MHPMCOUNTER31H. Must run now, otherwise I'd also send the trivial patch.
Thanks! Yes indeed they should be the H versions.
I will send the trivial patch...
Quoted 10 lines · Michael Clark
Quoted 6 lines · Richard Henderson
In the latest Coverity scan, it reports
I believe the condition at op_helper.c:409 should be testing
CSR_MHPMCOUNTER3H
andCSR_MHPMCOUNTER31H. Must run now, otherwise I'd also send the trivial patch.
Quoted 3 lines
Thanks! Yes indeed they should be the H versions.
I will send the trivial patch...
You might like to sign up to our Coverity Scan project if you aren't already:
https://scan.coverity.com/projects/qemu?tab=overview
It reports a couple of other riscv coverity nits (minor memory leaks).
thanks
-- PMM