[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH] target/ppc/mmu: Silent maybe-uninitialized error in ppc_hash
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH] target/ppc/mmu: Silent maybe-uninitialized error in ppc_hash64_xlate() |
Date: |
Fri, 23 Feb 2024 09:32:45 +0100 |
Initialize apshift to avoid a maybe-uninitialized error:
C compiler for the host machine: cc -m64 -mbig-endian (gcc 13.2.0 "cc (Debian
13.2.0-10) 13.2.0")
C linker for the host machine: cc -m64 -mbig-endian ld.bfd 2.41.90.20240115
Host machine cpu family: ppc64
Host machine cpu: ppc64
...
target/ppc/mmu-hash64.c: In function 'ppc_hash64_xlate':
target/ppc/mmu-hash64.c:1154:15: error: 'apshift' may be used uninitialized
[-Werror=maybe-uninitialized]
1154 | *raddrp = deposit64(pte.pte1 & HPTE64_R_RPN, 0, apshift, eaddr);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target/ppc/mmu-hash64.c:947:14: note: 'apshift' was declared here
947 | unsigned apshift;
| ^~~~~~~
The call chain is:
ppc_hash64_xlate -> ppc_hash64_htab_lookup -> ppc_hash64_pteg_search
ppc_hash64_pteg_search() either sets *pshift or returns -1,
ppc_hash64_htab_lookup() returns if ppc_hash64_pteg_search()
returned -1:
1068: ptex = ppc_hash64_htab_lookup(cpu, slb, eaddr, &pte, &apshift);
1069: if (ptex == -1) {
1070: if (!guest_visible) {
1071: return false;
1072: }
...
1087: return false;
So IIUC this "uninitialized use" can not happens.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
I had this in an old branch (2 months old) I just rebased,
and don't get why nobody else got this error yet.
---
target/ppc/mmu-hash64.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c
index d645c0bb94..cd1e0c13c8 100644
--- a/target/ppc/mmu-hash64.c
+++ b/target/ppc/mmu-hash64.c
@@ -944,7 +944,7 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr,
MMUAccessType access_type,
CPUPPCState *env = &cpu->env;
ppc_slb_t vrma_slbe;
ppc_slb_t *slb;
- unsigned apshift;
+ unsigned apshift = 0;
hwaddr ptex;
ppc_hash_pte64_t pte;
int exec_prot, pp_prot, amr_prot, prot;
--
2.41.0
- [RFC PATCH] target/ppc/mmu: Silent maybe-uninitialized error in ppc_hash64_xlate(),
Philippe Mathieu-Daudé <=