Skip to contentSkip to conversation

x86/mtrr: Remove redundant code

PATCH In review Jiapeng Chong 2 participants 2 messages Oct 18, 2023 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mtrr: Remove redundant code

arch/x86/kernel/cpu/mtrr/cleanup.c:943:4: warning: Value stored to 'highest_pfn' is never read.

---
 arch/x86/kernel/cpu/mtrr/cleanup.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/kernel/cpu/mtrr/cleanup.c +0 -2
index 18cf79d6e2c5..c4ec295cebbc 100644
@@ -939,8 +939,6 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
 	if (mtrr_tom2) {
 		range[nr_range].start = (1ULL<<(32 - PAGE_SHIFT));
 		range[nr_range].end = mtrr_tom2 >> PAGE_SHIFT;
-		if (highest_pfn < range[nr_range].end)
-			highest_pfn = range[nr_range].end;
 		nr_range++;
 	}
 	nr_range = x86_get_mtrr_mem_range(range, nr_range, 0, 0);
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw
Quoted 14 lines · Jiapeng Chong

arch/x86/kernel/cpu/mtrr/cleanup.c:943:4: warning: Value stored to 'highest_pfn' is never read.

---
 arch/x86/kernel/cpu/mtrr/cleanup.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/kernel/cpu/mtrr/cleanup.c +0 -0
index 18cf79d6e2c5..c4ec295cebbc 100644

arch/x86/kernel/cpu/mtrr/cleanup.c int __init mtrr_trim_uncached_memory(unsigned long end_pfn) · line 944

Quoted 8 lines
arch/x86/kernel/cpu/mtrr/cleanup.c +0 -2
@@ -939,8 +939,6 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
 	if (mtrr_tom2) {
 		range[nr_range].start = (1ULL<<(32 - PAGE_SHIFT));
 		range[nr_range].end = mtrr_tom2 >> PAGE_SHIFT;
-		if (highest_pfn < range[nr_range].end)
-			highest_pfn = range[nr_range].end;
 		nr_range++;
 	}
 	nr_range = x86_get_mtrr_mem_range(range, nr_range, 0, 0);

Please explain in the changelog how that redundant code got there and why there's no underlying bug to be concerned about.

[ I just did that myself and could share the results - but this kind of
analysis has to be done when submitting "cleanup" patches changing such type of code ... or at least it has to be flagged, not just mindlessly removing code ... ]

Thanks,

Ingo