From a03f296390ca345cc270ed5f5afd66c84b7ede56 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Sat, 7 Aug 2021 08:57:41 +0200 Subject: [PATCH] [v0.98] Fix bug in get_str_peak_performance and always show unknown pp when freq is also unknown --- src/common/cpu.c | 1 + src/x86/cpuid.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/cpu.c b/src/common/cpu.c index b5c1d7e..4ddc768 100644 --- a/src/common/cpu.c +++ b/src/common/cpu.c @@ -157,6 +157,7 @@ char* get_str_peak_performance(int64_t flops) { if(flops == -1) { str = emalloc(sizeof(char) * (strlen(STRING_UNKNOWN) + 1)); strncpy(str, STRING_UNKNOWN, strlen(STRING_UNKNOWN) + 1); + return str; } // 7 for digits (e.g, XXXX.XX), 7 for XFLOP/s diff --git a/src/x86/cpuid.c b/src/x86/cpuid.c index 4483ed0..37236ee 100644 --- a/src/x86/cpuid.c +++ b/src/x86/cpuid.c @@ -684,15 +684,17 @@ struct frequency* get_frequency_info(struct cpuInfo* cpu) { } if(freq->max == 0) { printWarn("Read max CPU frequency from CPUID and got 0 MHz"); - #ifdef __linux__ - printWarn("Using udev to detect frequency"); + #ifdef __linux__ + printWarn("Using udev to detect frequency"); freq->max = get_max_freq_from_file(0, cpu->hv->present); if(freq->max == 0) { printWarn("Read max CPU frequency from udev and got 0 MHz"); freq->max = UNKNOWN_FREQ; } - #endif + #else + freq->max = UNKNOWN_FREQ; + #endif } }