[PATCH] [POWERPC] fix warning in hash_native_64.c

Stephen Rothwell sfr at canb.auug.org.au
Thu May 10 02:18:35 EST 2007


arch/powerpc/mm/hash_native_64.c: In function 'native_hpte_clear':
arch/powerpc/mm/hash_native_64.c:353: warning: 'avpn' may be used uninitialized in this function

The change is really to BUG_ON the invers of the if condition and
outdent all the following code.  The comment above this imples that
changing this so it does the BUG_ON() is a reasonable fix.

David Gibson suggested using BUG_ON here.

Signed-off-by: Stephen Rothwell <sfr at canb.auug.org.au>
---
 arch/powerpc/mm/hash_native_64.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

-- 
Cheers,
Stephen Rothwell                    sfr at canb.auug.org.au

diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index 7b7fe2d..531a5ab 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -16,6 +16,7 @@
 #include <linux/bitops.h>
 #include <linux/threads.h>
 #include <linux/smp.h>
+#include <linux/bug.h>
 
 #include <asm/abs_addr.h>
 #include <asm/machdep.h>
@@ -389,18 +390,19 @@ static void hpte_decode(hpte_t *hpte, unsigned long slot,
 		avpnm_bits = __ilog2_u64(mmu_psize_defs[size].avpnm) + 1;
 	else
 		avpnm_bits = 0;
-	if (shift - avpnm_bits <= 23) {
-		avpn = HPTE_V_AVPN_VAL(hpte_v) << 23;
 
-		if (shift < 23) {
-			unsigned long vpi, pteg;
+	BUG_ON(!(shift - avpnm_bits <= 23));
 
-			pteg = slot / HPTES_PER_GROUP;
-			if (hpte_v & HPTE_V_SECONDARY)
-				pteg = ~pteg;
-			vpi = ((avpn >> 28) ^ pteg) & htab_hash_mask;
-			avpn |= (vpi << mmu_psize_defs[size].shift);
-		}
+	avpn = HPTE_V_AVPN_VAL(hpte_v) << 23;
+
+	if (shift < 23) {
+		unsigned long vpi, pteg;
+
+		pteg = slot / HPTES_PER_GROUP;
+		if (hpte_v & HPTE_V_SECONDARY)
+			pteg = ~pteg;
+		vpi = ((avpn >> 28) ^ pteg) & htab_hash_mask;
+		avpn |= (vpi << mmu_psize_defs[size].shift);
 	}
 
 	*va = avpn;
-- 
1.5.1.3




More information about the Linuxppc-dev mailing list