Skip to contentSkip to conversation

x86/mtrr: fix compiling warning

PATCH In review Yinghai Lu 2 participants 2 messages Sep 19, 2008 x86

lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 1/1 x86/mtrr: fix compiling warning

arch/x86/kernel/cpu/mtrr/main.c +2 -3
index 58ac5d3..90f0531 100644
@@ -1218,11 +1218,10 @@ static int __init mtrr_cleanup(unsigned address_bits)
 
 	memset(range, 0, sizeof(range));
 	extra_remove_size = 0;
-	if (mtrr_tom2) {
-		extra_remove_base = 1 << (32 - PAGE_SHIFT);
+	extra_remove_base = 1 << (32 - PAGE_SHIFT);
+	if (mtrr_tom2)
 		extra_remove_size =
 			(mtrr_tom2 >> PAGE_SHIFT) - extra_remove_base;
-	}
 	nr_range = x86_get_mtrr_mem_range(range, 0, extra_remove_base,
 					  extra_remove_size);
 	range_sums = sum_ranges(range, nr_range);
#1 lore raw
Quoted 1 line · Yinghai Lu

thx - applied the earlier version below already.

Ingo

------------>

Quoted 1 line

From 279b0bbba2bb647348ad90e183b3960aa99eccfd Mon Sep 17 00:00:00 2001

From: Yinghai Lu <[email protected]>
Date: Thu, 18 Sep 2008 23:55:27 -0700
Subject: [PATCH] x86: fix arch/x86/kernel/cpu/mtrr/main.c warning

fix this warning reported by Andrew Morton:

Quoted 2 lines

arch/x86/kernel/cpu/mtrr/main.c: In function 'mtrr_bp_init':
arch/x86/kernel/cpu/mtrr/main.c:1170: warning: 'extra_remove_base' may be used uninitialized in this function

the warning is bogus but the logic that prevents uninitialized use is a bit convoluted so simplify it all.

---
 arch/x86/kernel/cpu/mtrr/main.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/mtrr/main.c +2 -3
index b117d7f..8a7c792 100644
@@ -1218,11 +1218,10 @@ static int __init mtrr_cleanup(unsigned address_bits)
 
 	memset(range, 0, sizeof(range));
 	extra_remove_size = 0;
-	if (mtrr_tom2) {
-		extra_remove_base = 1 << (32 - PAGE_SHIFT);
+	extra_remove_base = 1 << (32 - PAGE_SHIFT);
+	if (mtrr_tom2)
 		extra_remove_size =
 			(mtrr_tom2 >> PAGE_SHIFT) - extra_remove_base;
-	}
 	nr_range = x86_get_mtrr_mem_range(range, 0, extra_remove_base,
 					  extra_remove_size);
 	range_sums = sum_ranges(range, nr_range);