mirror of https://github.com/xzeldon/htop.git
Update CPU freq display to use NAN on error
This commit is contained in:
parent
ebcf924643
commit
3c65d78d77
|
@ -42,7 +42,7 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, int size) {
|
||||||
if (this->pl->settings->showCPUFrequency) {
|
if (this->pl->settings->showCPUFrequency) {
|
||||||
double cpuFrequency = this->values[CPU_METER_FREQUENCY];
|
double cpuFrequency = this->values[CPU_METER_FREQUENCY];
|
||||||
char cpuFrequencyBuffer[16];
|
char cpuFrequencyBuffer[16];
|
||||||
if (cpuFrequency < 0) {
|
if (isnan(cpuFrequency)) {
|
||||||
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A");
|
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A");
|
||||||
} else {
|
} else {
|
||||||
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.0fMHz", cpuFrequency);
|
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.0fMHz", cpuFrequency);
|
||||||
|
|
|
@ -19,6 +19,7 @@ in the source distribution for its full text.
|
||||||
#include "zfs/ZfsCompressedArcMeter.h"
|
#include "zfs/ZfsCompressedArcMeter.h"
|
||||||
#include "DarwinProcessList.h"
|
#include "DarwinProcessList.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,7 +211,7 @@ double Platform_setCPUValues(Meter* mtr, int cpu) {
|
||||||
/* Convert to percent and return */
|
/* Convert to percent and return */
|
||||||
total = mtr->values[CPU_METER_NICE] + mtr->values[CPU_METER_NORMAL] + mtr->values[CPU_METER_KERNEL];
|
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);
|
return CLAMP(total, 0.0, 100.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
|
||||||
percent = CLAMP(percent, 0.0, 100.0);
|
percent = CLAMP(percent, 0.0, 100.0);
|
||||||
if (isnan(percent)) percent = 0.0;
|
if (isnan(percent)) percent = 0.0;
|
||||||
|
|
||||||
v[CPU_METER_FREQUENCY] = -1;
|
v[CPU_METER_FREQUENCY] = NAN;
|
||||||
|
|
||||||
return percent;
|
return percent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
|
||||||
percent = CLAMP(percent, 0.0, 100.0);
|
percent = CLAMP(percent, 0.0, 100.0);
|
||||||
if (isnan(percent)) percent = 0.0;
|
if (isnan(percent)) percent = 0.0;
|
||||||
|
|
||||||
v[CPU_METER_FREQUENCY] = -1;
|
v[CPU_METER_FREQUENCY] = NAN;
|
||||||
|
|
||||||
return percent;
|
return percent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1153,7 +1153,7 @@ static inline double LinuxProcessList_scanCPUFrequency(LinuxProcessList* this) {
|
||||||
|
|
||||||
for (int i = 0; i <= cpus; i++) {
|
for (int i = 0; i <= cpus; i++) {
|
||||||
CPUData* cpuData = &(this->cpus[i]);
|
CPUData* cpuData = &(this->cpus[i]);
|
||||||
cpuData->frequency = -1;
|
cpuData->frequency = NAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numCPUsWithFrequency = 0;
|
int numCPUsWithFrequency = 0;
|
||||||
|
|
|
@ -162,7 +162,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
|
||||||
v[CPU_METER_STEAL] = 0.0;
|
v[CPU_METER_STEAL] = 0.0;
|
||||||
v[CPU_METER_GUEST] = 0.0;
|
v[CPU_METER_GUEST] = 0.0;
|
||||||
v[CPU_METER_IOWAIT] = 0.0;
|
v[CPU_METER_IOWAIT] = 0.0;
|
||||||
v[CPU_METER_FREQUENCY] = -1;
|
v[CPU_METER_FREQUENCY] = NAN;
|
||||||
Meter_setItems(this, 8);
|
Meter_setItems(this, 8);
|
||||||
totalPercent = v[0]+v[1]+v[2]+v[3];
|
totalPercent = v[0]+v[1]+v[2]+v[3];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -186,7 +186,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
|
||||||
percent = CLAMP(percent, 0.0, 100.0);
|
percent = CLAMP(percent, 0.0, 100.0);
|
||||||
if (isnan(percent)) percent = 0.0;
|
if (isnan(percent)) percent = 0.0;
|
||||||
|
|
||||||
v[CPU_METER_FREQUENCY] = -1;
|
v[CPU_METER_FREQUENCY] = NAN;
|
||||||
|
|
||||||
return percent;
|
return percent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "CPUMeter.h"
|
#include "CPUMeter.h"
|
||||||
#include "MemoryMeter.h"
|
#include "MemoryMeter.h"
|
||||||
|
@ -105,7 +107,7 @@ double Platform_setCPUValues(Meter* this, int cpu) {
|
||||||
(void) cpu;
|
(void) cpu;
|
||||||
|
|
||||||
double* v = this->values;
|
double* v = this->values;
|
||||||
v[CPU_METER_FREQUENCY] = -1;
|
v[CPU_METER_FREQUENCY] = NAN;
|
||||||
|
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue