[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.15 16/33] target/i386: Avoid unreachable variable declaratio
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.15 16/33] target/i386: Avoid unreachable variable declaration in mmu_translate() |
Date: |
Sat, 9 Nov 2024 09:38:42 +0300 |
From: Peter Maydell <peter.maydell@linaro.org>
Coverity complains (CID 1507880) that the declaration "int error_code;"
in mmu_translate() is unreachable code. Since this is only a declaration,
this isn't actually a bug, but:
* it's a bear-trap for future changes, because if it was changed to
include an initialization 'int error_code = foo;' then the
initialization wouldn't actually happen (being dead code)
* it's against our coding style, which wants declarations to be
at the start of blocks
* it means that anybody reading the code has to go and look up
exactly what the C rules are for skipping over variable declarations
using a goto
Move the declaration to the top of the function.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20230406155946.3362077-1-peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 987b63f24afe027a09b1c549c05a032a477f7e96)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: cherry-pick this for stable-7.2 so that the next patch applies cleanly)
diff --git a/target/i386/tcg/sysemu/excp_helper.c
b/target/i386/tcg/sysemu/excp_helper.c
index 5f13252d68..eb78fcba11 100644
--- a/target/i386/tcg/sysemu/excp_helper.c
+++ b/target/i386/tcg/sysemu/excp_helper.c
@@ -146,6 +146,7 @@ static bool mmu_translate(CPUX86State *env, const
TranslateParams *in,
hwaddr pte_addr, paddr;
uint32_t pkr;
int page_size;
+ int error_code;
restart_all:
rsvd_mask = ~MAKE_64BIT_MASK(0, env_archcpu(env)->phys_bits);
@@ -464,7 +465,6 @@ do_check_protect_pse36:
out->page_size = page_size;
return true;
- int error_code;
do_fault_rsvd:
error_code = PG_ERROR_RSVD_MASK;
goto do_fault_cont;
--
2.39.5
- [Stable-7.2.15 05/33] tracetool: avoid invalid escape in Python string, (continued)
- [Stable-7.2.15 05/33] tracetool: avoid invalid escape in Python string, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 07/33] linux-user: Fix parse_elf_properties GNU0_MAGIC check, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 08/33] scsi: fetch unit attention when creating the request, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 04/33] fuzz: disable leak-detection for oss-fuzz builds, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 06/33] linux-user/flatload: Take mmap_lock in load_flt_binary(), Michael Tokarev, 2024/11/09
- [Stable-7.2.15 10/33] hw/audio/hda: free timer on exit, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 09/33] hw/intc/arm_gicv3_cpuif: Add cast to match the documentation, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 11/33] KVM: Dynamic sized kvm memslots array, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 14/33] raw-format: Fix error message for invalid offset/size, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 13/33] tests: Wait for migration completion on destination QEMU to avoid failures, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 16/33] target/i386: Avoid unreachable variable declaration in mmu_translate(),
Michael Tokarev <=
- [Stable-7.2.15 12/33] accel/kvm: check for KVM_CAP_READONLY_MEM on VM, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 15/33] tcg: Reset data_gen_ptr correctly, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 17/33] target/i386: Walk NPT in guest real mode, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 20/33] Fix calculation of minimum in colo_compare_tcp, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 18/33] linux-user/ppc: Fix sigmask endianness issue in sigreturn, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 19/33] gitlab: make check-[dco|patch] a little more verbose, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 21/33] net/tap-win32: Fix gcc 14 format truncation errors, Michael Tokarev, 2024/11/09
- [Stable-7.2.15 22/33] target/arm: Don't assert in regime_is_user() for E10 mmuidx values, Michael Tokarev, 2024/11/09