Skip to content

Commit 24dbc60

Browse files
GustavoARSilvaIngo Molnar
authored andcommitted
x86/cpu: Change type of x86_cache_size variable to unsigned int
Currently, x86_cache_size is of type int, which makes no sense as we will never have a valid cache size equal or less than 0. So instead of initializing this variable to -1, it can perfectly be initialized to 0 and use it as an unsigned variable instead. Suggested-by: Thomas Gleixner <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Addresses-Coverity-ID: 1464429 Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 9de29ea commit 24dbc60

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

arch/x86/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct cpuinfo_x86 {
109109
char x86_vendor_id[16];
110110
char x86_model_id[64];
111111
/* in KB - valid for CPUS which support this call: */
112-
int x86_cache_size;
112+
unsigned int x86_cache_size;
113113
int x86_cache_alignment; /* In bytes */
114114
/* Cache QoS architectural values: */
115115
int x86_cache_max_rmid; /* max index */

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
11841184
int i;
11851185

11861186
c->loops_per_jiffy = loops_per_jiffy;
1187-
c->x86_cache_size = -1;
1187+
c->x86_cache_size = 0;
11881188
c->x86_vendor = X86_VENDOR_UNKNOWN;
11891189
c->x86_model = c->x86_stepping = 0; /* So far unknown... */
11901190
c->x86_vendor_id[0] = '\0'; /* Unset */

arch/x86/kernel/cpu/microcode/intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ static struct microcode_ops microcode_intel_ops = {
982982

983983
static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c)
984984
{
985-
u64 llc_size = c->x86_cache_size * 1024;
985+
u64 llc_size = c->x86_cache_size * 1024ULL;
986986

987987
do_div(llc_size, c->x86_max_cores);
988988

arch/x86/kernel/cpu/proc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
9191
}
9292

9393
/* Cache size */
94-
if (c->x86_cache_size >= 0)
95-
seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
94+
if (c->x86_cache_size)
95+
seq_printf(m, "cache size\t: %u KB\n", c->x86_cache_size);
9696

9797
show_cpuinfo_core(m, c, cpu);
9898
show_cpuinfo_misc(m, c);

0 commit comments

Comments
 (0)