qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] target/ppc: fix unreachable code in do_ldst_quad()


From: Richard Henderson
Subject: Re: [PATCH] target/ppc: fix unreachable code in do_ldst_quad()
Date: Sun, 24 Jul 2022 15:10:37 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 7/20/22 19:27, Daniel Henrique Barboza wrote:
Coverity reports that commit fc34e81acd51 ("target/ppc: add macros to
check privilege level") turned the following code unreachable:

if (!prefixed && !(ctx->insns_flags2 & PPC2_LSQ_ISA207)) {
     /* lq and stq were privileged prior to V. 2.07 */
     REQUIRE_SV(ctx);

     CID 1490757:  Control flow issues  (UNREACHABLE)
     This code cannot be reached: "if (ctx->le_mode) {
     if (ctx->le_mode) {
         gen_align_no_le(ctx);
         return true;
     }
}

This happens because the macro REQUIRE_SV(), in CONFIG_USER_MODE, will
always result in a 'return true' statement.

I think adding ifdefs isn't fantastic. This isn't actually fix a bug, so we *could* just mark this as ignore in Coverity.

If you wanted to clean this up, remove the implicit control flow from REQUIRE_* and turn the macros into pure predicates, so that you get

    if (REQUIRE_SV(ctx)) {
        return true;
    }
    if (ctx->le_mode) {
        ...
    }


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]