Skip to contentSkip to conversation

x86/cacheinfo: fix a -Wtype-limits warning

PATCH Superseded Qian Cai 2 participants 2 messages Jun 19, 2019 x86

lore
Share & tools
lore

Qian Cai

author
#0 lore raw

PATCH v2 1/1 x86/cacheinfo: fix a -Wtype-limits warning

cpuinfo_x86.x86_model is an unsigned type, so compares it against zero will generate a compilation warning,

arch/x86/kernel/cpu/cacheinfo.c: In function 'cacheinfo_amd_init_llc_id':
arch/x86/kernel/cpu/cacheinfo.c:662:19: warning: comparison is always true due to limited range of data type [-Wtype-limits]

"c->x86 == 0x17" is true if and only if c->x86_model was explicitly set by cpu_detect(), so just remove the unnecessary checking.

Fixes 68091ee7ac3c ("x86/CPU/AMD: Calculate last level cache ID from number of sharing threads")

---

v2: Update the commit message per Sean.

 arch/x86/kernel/cpu/cacheinfo.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/cacheinfo.c +1 -2
index 395d46f78582..c7503be92f35 100644
@@ -658,8 +658,7 @@ void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, int cpu, u8 node_id)
 	if (c->x86 < 0x17) {
 		/* LLC is at the node level. */
 		per_cpu(cpu_llc_id, cpu) = node_id;
-	} else if (c->x86 == 0x17 &&
-		   c->x86_model >= 0 && c->x86_model <= 0x1F) {
+	} else if (c->x86 == 0x17 && c->x86_model <= 0x1F) {
 		/*
 		 * LLC is at the core complex level.
 		 * Core complex ID is ApicId[3] for these processors.
Signature · 1 line
1.8.3.1
#1 lore raw

[tip:x86/cpu] x86/cacheinfo: Fix a -Wtype-limits warning

x86/cacheinfo: Fix a -Wtype-limits warning
Commit-ID:  1b7aebf0487613033aff26420e32fa2076d52846
Gitweb:     https://git.kernel.org/tip/1b7aebf0487613033aff26420e32fa2076d52846
Author:     Qian Cai <[email protected]>
AuthorDate: Wed, 19 Jun 2019 10:32:53 -0400
Committer:  Borislav Petkov <[email protected]>
CommitDate: Wed, 19 Jun 2019 19:21:32 +0200

x86/cacheinfo: Fix a -Wtype-limits warning

cpuinfo_x86.x86_model is an unsigned type, so comparing against zero will generate a compilation warning:

arch/x86/kernel/cpu/cacheinfo.c: In function 'cacheinfo_amd_init_llc_id':
arch/x86/kernel/cpu/cacheinfo.c:662:19: warning: comparison is always true \
due to limited range of data type [-Wtype-limits]

Remove the unnecessary lower bound check.

[ bp: Massage. ]

Fixes 68091ee7ac3c ("x86/CPU/AMD: Calculate last level cache ID from number of sharing threads")
Cc "Gustavo A. R. Silva" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Pu Wen <[email protected]>
Cc Suravee Suthikulpanit <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
---
 arch/x86/kernel/cpu/cacheinfo.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/cacheinfo.c +1 -2
index 395d46f78582..c7503be92f35 100644
@@ -658,8 +658,7 @@ void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, int cpu, u8 node_id)
 	if (c->x86 < 0x17) {
 		/* LLC is at the node level. */
 		per_cpu(cpu_llc_id, cpu) = node_id;
-	} else if (c->x86 == 0x17 &&
-		   c->x86_model >= 0 && c->x86_model <= 0x1F) {
+	} else if (c->x86 == 0x17 && c->x86_model <= 0x1F) {
 		/*
 		 * LLC is at the core complex level.
 		 * Core complex ID is ApicId[3] for these processors.