From a67a605fb50af3539c5762dd994b0c7d733c4b5b Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Thu, 8 Apr 2021 10:12:01 +0200 Subject: [PATCH] [v0.96] Print "Unknown" string when manufacturing process is unkown --- src/x86/uarch.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/x86/uarch.c b/src/x86/uarch.c index 77eb08c..0f0f3c2 100644 --- a/src/x86/uarch.c +++ b/src/x86/uarch.c @@ -38,6 +38,8 @@ typedef uint32_t MICROARCH; +#define STRING_UNKNOWN "Unknown" + // Data not available #define NA -1 @@ -398,14 +400,19 @@ char* get_str_uarch(struct cpuInfo* cpu) { } char* get_str_process(struct cpuInfo* cpu) { - char* str = malloc(sizeof(char) * (4+2+1)); - uint32_t process = cpu->arch->process; - - if(process > 100) + char* str = malloc(sizeof(char) * (strlen(STRING_UNKNOWN)+1)); + int32_t process = cpu->arch->process; + + if(process == UNK) { + snprintf(str, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN); + } + else if(process > 100) { sprintf(str, "%.2fum", (double)process/100); - else + } + else { sprintf(str, "%dnm", process); - + } + return str; }