diff mbox series

[4/5] target/riscv/csr.c: fix deadcode in aia_smode32()

Message ID 20250121184847.2109128-5-dbarboza@ventanamicro.com (mailing list archive)
State New, archived
Headers show
Series target/riscv: Coverity fixes | expand

Commit Message

Daniel Henrique Barboza Jan. 21, 2025, 6:48 p.m. UTC
Coverity reported a DEADCODE ticket in this function, as follows:

 >>>>      CID 1590358:  Control flow issues  (DEADCODE)
 >>>>      Execution cannot reach this statement: "return ret;".
 > 380             return ret;
 > 381         }

The cause is that the 'if (ret != RISCV_EXCP_NONE)' conditional is
duplicated:

    ret = smstateen_acc_ok(env, 0, SMSTATEEN0_AIA);
    if (ret != RISCV_EXCP_NONE) {
        return ret;
    }

    if (ret != RISCV_EXCP_NONE) {
        return ret;
    }

Remove the duplication to fix the deadcode.

Resolves: Coverity CID 1590358
Fixes: dbcb6e1ccf ("target/riscv: Enable S*stateen bits for AIA")
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
 target/riscv/csr.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Alistair Francis Jan. 29, 2025, 12:58 a.m. UTC | #1
On Wed, Jan 22, 2025 at 4:53 AM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
> Coverity reported a DEADCODE ticket in this function, as follows:
>
>  >>>>      CID 1590358:  Control flow issues  (DEADCODE)
>  >>>>      Execution cannot reach this statement: "return ret;".
>  > 380             return ret;
>  > 381         }
>
> The cause is that the 'if (ret != RISCV_EXCP_NONE)' conditional is
> duplicated:
>
>     ret = smstateen_acc_ok(env, 0, SMSTATEEN0_AIA);
>     if (ret != RISCV_EXCP_NONE) {
>         return ret;
>     }
>
>     if (ret != RISCV_EXCP_NONE) {
>         return ret;
>     }
>
> Remove the duplication to fix the deadcode.
>
> Resolves: Coverity CID 1590358
> Fixes: dbcb6e1ccf ("target/riscv: Enable S*stateen bits for AIA")
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/riscv/csr.c | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index 75f21ccabb..dc0a88a0f0 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -376,10 +376,6 @@ static RISCVException aia_smode32(CPURISCVState *env, int csrno)
>          return ret;
>      }
>
> -    if (ret != RISCV_EXCP_NONE) {
> -        return ret;
> -    }
> -
>      return smode32(env, csrno);
>  }
>
> --
> 2.47.1
>
>
diff mbox series

Patch

diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index 75f21ccabb..dc0a88a0f0 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -376,10 +376,6 @@  static RISCVException aia_smode32(CPURISCVState *env, int csrno)
         return ret;
     }
 
-    if (ret != RISCV_EXCP_NONE) {
-        return ret;
-    }
-
     return smode32(env, csrno);
 }