]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/i386: Avoid unreachable variable declaration in mmu_translate()
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 6 Apr 2023 15:59:46 +0000 (16:59 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Sun, 10 Nov 2024 08:10:00 +0000 (11:10 +0300)
commit6d36cf89d36f22c7da2c33ff52008932a62b4a34
treed8eadc38909ed4e10cd13f15dcf675d05e87a39d
parent16ac2273d170d13346c99db531ce1cb389f50d5a
target/i386: Avoid unreachable variable declaration in mmu_translate()

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)
target/i386/tcg/sysemu/excp_helper.c