diff --git a/src/cpuid.c b/src/cpuid.c index 3898d91..52ab0fd 100644 --- a/src/cpuid.c +++ b/src/cpuid.c @@ -517,6 +517,10 @@ struct cache* get_cache_info(struct cpuInfo* cpu) { printBug("Invalid L3 size: %dMB", cach->L3/(1048576)); return NULL; } + if(cach->L2 == UNKNOWN) { + printBug("Could not find L2 cache"); + return NULL; + } return cach; } @@ -887,20 +891,16 @@ char* get_str_l1d(struct cache* cach, struct topology* topo) { } char* get_str_l2(struct cache* cach, struct topology* topo) { - if(cach->L2 == UNKNOWN) { - char* string = malloc(sizeof(char) * 5); - snprintf(string, 5, STRING_NONE); - return string; - } - return get_str_cache(cach->L2, topo, false); + assert(cach->L2 != UNKNOWN); + if(cach->L3 == UNKNOWN) + return get_str_cache(cach->L2, topo, true); + else + return get_str_cache(cach->L2, topo, false); } char* get_str_l3(struct cache* cach, struct topology* topo) { - if(cach->L3 == UNKNOWN) { - char* string = malloc(sizeof(char) * 5); - snprintf(string, 5, STRING_NONE); - return string; - } + if(cach->L3 == UNKNOWN) + return NULL; return get_str_cache(cach->L3, topo, true); } diff --git a/src/main.c b/src/main.c index 0e9b3f3..0c6380a 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ #include "cpuid.h" #include "global.h" -static const char* VERSION = "0.54"; +static const char* VERSION = "0.55"; void print_help(char *argv[]) { printf("Usage: %s [--version] [--help] [--levels] [--style fancy|retro] [--color 'R,G,B:R,G,B:R,G,B:R,G,B']\n\ diff --git a/src/printer.c b/src/printer.c index 9041a26..f8601a8 100644 --- a/src/printer.c +++ b/src/printer.c @@ -14,8 +14,8 @@ #define COL_INTEL_FANCY_4 "\x1b[37;1m" #define COL_INTEL_RETRO_1 "\x1b[36;1m" #define COL_INTEL_RETRO_2 "\x1b[37;1m" -#define COL_AMD_FANCY_1 "\x1b[37;1m" -#define COL_AMD_FANCY_2 "\x1b[31;1m" +#define COL_AMD_FANCY_1 "\x1b[47;1m" +#define COL_AMD_FANCY_2 "\x1b[41;1m" #define COL_AMD_FANCY_3 "\x1b[37;1m" #define COL_AMD_FANCY_4 "\x1b[31;1m" #define COL_AMD_RETRO_1 "\x1b[37;1m" @@ -332,8 +332,7 @@ bool print_cpufetch(struct cpuInfo* cpu, struct cache* cach, struct frequency* f setAttribute(art,ATTRIBUTE_SHA,sha); setAttribute(art,ATTRIBUTE_L1i,l1i); setAttribute(art,ATTRIBUTE_L1d,l1d); - setAttribute(art,ATTRIBUTE_L2,l2); - setAttribute(art,ATTRIBUTE_L3,l3); + setAttribute(art,ATTRIBUTE_L2,l2); setAttribute(art,ATTRIBUTE_PEAK,pp); uint32_t socket_num = get_nsockets(topo); @@ -341,7 +340,9 @@ bool print_cpufetch(struct cpuInfo* cpu, struct cache* cach, struct frequency* f setAttribute(art, ATTRIBUTE_SOCKETS, sockets); setAttribute(art, ATTRIBUTE_NCORES_DUAL, n_cores_dual); } - + if(l3 != NULL) { + setAttribute(art,ATTRIBUTE_L3,l3); + } if(art->n_attributes_set > NUMBER_OF_LINES) { printBug("The number of attributes set is bigger than the max that can be displayed"); return false;