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 <tglx@linutronix.de>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Addresses-Coverity-ID: 1464429
Link: http://lkml.kernel.org/r/20180213192208.GA26414@embeddedor.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Gustavo A. R. Silva 2018-02-13 13:22:08 -06:00 коммит произвёл Ingo Molnar
Родитель 9de29eac8d
Коммит 24dbc6000f
4 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -109,7 +109,7 @@ struct cpuinfo_x86 {
char x86_vendor_id[16]; char x86_vendor_id[16];
char x86_model_id[64]; char x86_model_id[64];
/* in KB - valid for CPUS which support this call: */ /* in KB - valid for CPUS which support this call: */
int x86_cache_size; unsigned int x86_cache_size;
int x86_cache_alignment; /* In bytes */ int x86_cache_alignment; /* In bytes */
/* Cache QoS architectural values: */ /* Cache QoS architectural values: */
int x86_cache_max_rmid; /* max index */ int x86_cache_max_rmid; /* max index */

Просмотреть файл

@ -1184,7 +1184,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
int i; int i;
c->loops_per_jiffy = loops_per_jiffy; c->loops_per_jiffy = loops_per_jiffy;
c->x86_cache_size = -1; c->x86_cache_size = 0;
c->x86_vendor = X86_VENDOR_UNKNOWN; c->x86_vendor = X86_VENDOR_UNKNOWN;
c->x86_model = c->x86_stepping = 0; /* So far unknown... */ c->x86_model = c->x86_stepping = 0; /* So far unknown... */
c->x86_vendor_id[0] = '\0'; /* Unset */ c->x86_vendor_id[0] = '\0'; /* Unset */

Просмотреть файл

@ -982,7 +982,7 @@ static struct microcode_ops microcode_intel_ops = {
static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c) static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c)
{ {
u64 llc_size = c->x86_cache_size * 1024; u64 llc_size = c->x86_cache_size * 1024ULL;
do_div(llc_size, c->x86_max_cores); do_div(llc_size, c->x86_max_cores);

Просмотреть файл

@ -91,8 +91,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
} }
/* Cache size */ /* Cache size */
if (c->x86_cache_size >= 0) if (c->x86_cache_size)
seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); seq_printf(m, "cache size\t: %u KB\n", c->x86_cache_size);
show_cpuinfo_core(m, c, cpu); show_cpuinfo_core(m, c, cpu);
show_cpuinfo_misc(m, c); show_cpuinfo_misc(m, c);