summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-09-07 12:24:32 +0200
committercgzones <cgzones@googlemail.com>2020-09-24 18:06:36 +0200
commit3c65d78d77e43de12284417012fad2d8c195770e (patch)
tree77854c971c13784e9e734aecc1aaf5213fc8f98c
parentebcf92464353d44c1d01b5afd286314415a66c96 (diff)
Update CPU freq display to use NAN on error
-rw-r--r--CPUMeter.c2
-rw-r--r--darwin/Platform.c3
-rw-r--r--dragonflybsd/Platform.c2
-rw-r--r--freebsd/Platform.c2
-rw-r--r--linux/LinuxProcessList.c2
-rw-r--r--openbsd/Platform.c2
-rw-r--r--solaris/Platform.c2
-rw-r--r--unsupported/Platform.c4
8 files changed, 11 insertions, 8 deletions
diff --git a/CPUMeter.c b/CPUMeter.c
index 62c9971b..badca940 100644
--- a/CPUMeter.c
+++ b/CPUMeter.c
@@ -42,7 +42,7 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, int size) {
if (this->pl->settings->showCPUFrequency) {
double cpuFrequency = this->values[CPU_METER_FREQUENCY];
char cpuFrequencyBuffer[16];
- if (cpuFrequency < 0) {
+ if (isnan(cpuFrequency)) {
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A");
} else {
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.0fMHz", cpuFrequency);
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 1186fe04..129b1cb9 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -19,6 +19,7 @@ in the source distribution for its full text.
#include "zfs/ZfsCompressedArcMeter.h"
#include "DarwinProcessList.h"
+#include <math.h>
#include <stdlib.h>
@@ -210,7 +211,7 @@ double Platform_setCPUValues(Meter* mtr, int cpu) {
/* Convert to percent and return */
total = mtr->values[CPU_METER_NICE] + mtr->values[CPU_METER_NORMAL] + mtr->values[CPU_METER_KERNEL];
- mtr->values[CPU_METER_FREQUENCY] = -1;
+ mtr->values[CPU_METER_FREQUENCY] = NAN;
return CLAMP(total, 0.0, 100.0);
}
diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c
index 3b8e1a0d..e4e78e38 100644
--- a/dragonflybsd/Platform.c
+++ b/dragonflybsd/Platform.c
@@ -168,7 +168,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
percent = CLAMP(percent, 0.0, 100.0);
if (isnan(percent)) percent = 0.0;
- v[CPU_METER_FREQUENCY] = -1;
+ v[CPU_METER_FREQUENCY] = NAN;
return percent;
}
diff --git a/freebsd/Platform.c b/freebsd/Platform.c
index df664ae5..3fc5de31 100644
--- a/freebsd/Platform.c
+++ b/freebsd/Platform.c
@@ -171,7 +171,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
percent = CLAMP(percent, 0.0, 100.0);
if (isnan(percent)) percent = 0.0;
- v[CPU_METER_FREQUENCY] = -1;
+ v[CPU_METER_FREQUENCY] = NAN;
return percent;
}
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 18dda3ed..9f754f19 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -1153,7 +1153,7 @@ static inline double LinuxProcessList_scanCPUFrequency(LinuxProcessList* this) {
for (int i = 0; i <= cpus; i++) {
CPUData* cpuData = &(this->cpus[i]);
- cpuData->frequency = -1;
+ cpuData->frequency = NAN;
}
int numCPUsWithFrequency = 0;
diff --git a/openbsd/Platform.c b/openbsd/Platform.c
index cb162078..bd5ef7ef 100644
--- a/openbsd/Platform.c
+++ b/openbsd/Platform.c
@@ -162,7 +162,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
v[CPU_METER_STEAL] = 0.0;
v[CPU_METER_GUEST] = 0.0;
v[CPU_METER_IOWAIT] = 0.0;
- v[CPU_METER_FREQUENCY] = -1;
+ v[CPU_METER_FREQUENCY] = NAN;
Meter_setItems(this, 8);
totalPercent = v[0]+v[1]+v[2]+v[3];
} else {
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 436c9ce9..d3ad1f93 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -186,7 +186,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
percent = CLAMP(percent, 0.0, 100.0);
if (isnan(percent)) percent = 0.0;
- v[CPU_METER_FREQUENCY] = -1;
+ v[CPU_METER_FREQUENCY] = NAN;
return percent;
}
diff --git a/unsupported/Platform.c b/unsupported/Platform.c
index 420dfb78..20df3376 100644
--- a/unsupported/Platform.c
+++ b/unsupported/Platform.c
@@ -6,6 +6,8 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
+#include <math.h>
+
#include "Platform.h"
#include "CPUMeter.h"
#include "MemoryMeter.h"
@@ -105,7 +107,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
(void) cpu;
double* v = this->values;
- v[CPU_METER_FREQUENCY] = -1;
+ v[CPU_METER_FREQUENCY] = NAN;
return 0.0;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy