From bea9b4798717b6f4e31085506dfc179eeb8dc17c Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:00:26 +0200 Subject: Imported Upstream version 0.8.3 --- CPUMeter.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'CPUMeter.c') diff --git a/CPUMeter.c b/CPUMeter.c index bc6af15..7325bff 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -43,6 +43,10 @@ static void CPUMeter_init(Meter* this) { static void CPUMeter_setValues(Meter* this, char* buffer, int size) { ProcessList* pl = this->pl; int processor = this->param; + if (processor > this->pl->processorCount) { + snprintf(buffer, size, "absent"); + return; + } double total = (double) pl->totalPeriod[processor]; double cpu; this->values[0] = pl->nicePeriod[processor] / total * 100.0; @@ -67,6 +71,10 @@ static void CPUMeter_display(Object* cast, RichString* out) { char buffer[50]; Meter* this = (Meter*)cast; RichString_init(out); + if (this->param > this->pl->processorCount) { + RichString_append(out, CRT_colors[METER_TEXT], "absent"); + return; + } sprintf(buffer, "%5.1f%% ", this->values[1]); RichString_append(out, CRT_colors[METER_TEXT], ":"); RichString_append(out, CRT_colors[CPU_NORMAL], buffer); -- cgit v1.2.3