From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Max Filippov" <jcmvbkbc@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH] target/xtensa/mmu: Avoid maybe-uninitialized error in get_phys_page()
Date: Thu, 31 Aug 2023 15:17:35 +0200 [thread overview]
Message-ID: <20230831131735.69288-1-philmd@linaro.org> (raw)
Fix when using GCC v11.4 (Ubuntu 11.4.0-1ubuntu1~22.04) with CFLAGS=-Og:
target/xtensa/mmu_helper.c: In function ‘helper_pptlb’:
target/xtensa/mmu_helper.c:986:35: error: ‘bg_segment’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
986 | return env->config->mpu_bg[bg_segment].attr | segment;
| ^
target/xtensa/mmu_helper.c: In function ‘xtensa_get_physical_addr’:
target/xtensa/mmu_helper.c:1011:35: error: ‘segment’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
1011 | attr = env->config->mpu_bg[segment].attr;
| ^
target/xtensa/mmu_helper.c:996:14: note: ‘segment’ was declared here
996 | unsigned segment;
| ^~~~~~~
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/xtensa/mmu_helper.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
index fa66e8e867..93e3866217 100644
--- a/target/xtensa/mmu_helper.c
+++ b/target/xtensa/mmu_helper.c
@@ -980,9 +980,10 @@ uint32_t HELPER(pptlb)(CPUXtensaState *env, uint32_t v)
} else if (nhits == 1 && (env->sregs[MPUENB] & (1u << segment))) {
return env->mpu_fg[segment].attr | segment | XTENSA_MPU_PROBE_V;
} else {
- xtensa_mpu_lookup(env->config->mpu_bg,
- env->config->n_mpu_bg_segments,
- v, &bg_segment);
+ nhits = xtensa_mpu_lookup(env->config->mpu_bg,
+ env->config->n_mpu_bg_segments,
+ v, &bg_segment);
+ assert(nhits > 0);
return env->config->mpu_bg[bg_segment].attr | segment;
}
}
@@ -1005,9 +1006,10 @@ static int get_physical_addr_mpu(CPUXtensaState *env,
} else if (nhits == 1 && (env->sregs[MPUENB] & (1u << segment))) {
attr = env->mpu_fg[segment].attr;
} else {
- xtensa_mpu_lookup(env->config->mpu_bg,
- env->config->n_mpu_bg_segments,
- vaddr, &segment);
+ nhits = xtensa_mpu_lookup(env->config->mpu_bg,
+ env->config->n_mpu_bg_segments,
+ vaddr, &segment);
+ assert(nhits > 0);
attr = env->config->mpu_bg[segment].attr;
}
--
2.41.0
reply other threads:[~2023-08-31 13:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230831131735.69288-1-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=jcmvbkbc@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).