From 43d274a6179846e5dfaf1bd0b75b57f6e65a8e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Thu, 29 Oct 2020 23:17:12 +0100 Subject: [PATCH] Use integer type for item count instead of char --- CPUMeter.c | 3 +-- Meter.c | 8 +++----- Meter.h | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CPUMeter.c b/CPUMeter.c index 10635478..4997f6f8 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -51,8 +51,7 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, int size) { int cpu = this->param; if (cpu > this->pl->cpuCount) { xSnprintf(buffer, size, "absent"); - int items = this->curItems; - for (int i = 0; i < items; i++) + for (uint8_t i = 0; i < this->curItems; i++) this->values[i] = 0; return; } diff --git a/Meter.c b/Meter.c index a04a5832..59daa0f5 100644 --- a/Meter.c +++ b/Meter.c @@ -195,8 +195,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { // First draw in the bar[] buffer... int offset = 0; - int items = this->curItems; - for (int i = 0; i < items; i++) { + for (uint8_t i = 0; i < this->curItems; i++) { double value = this->values[i]; value = CLAMP(value, 0.0, this->total); if (value > 0) { @@ -220,7 +219,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { // ...then print the buffer. offset = 0; - for (int i = 0; i < items; i++) { + for (uint8_t i = 0; i < this->curItems; i++) { attrset(CRT_colors[Meter_attributes(this)[i]]); mvaddnstr(y, x + offset, bar + offset, blockSizes[i]); offset += blockSizes[i]; @@ -296,8 +295,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { Meter_updateValues(this, buffer, nValues - 1); double value = 0.0; - int items = this->curItems; - for (int i = 0; i < items; i++) + for (uint8_t i = 0; i < this->curItems; i++) value += this->values[i]; value /= this->total; data->values[nValues - 1] = value; diff --git a/Meter.h b/Meter.h index 32c167cb..125c0cd5 100644 --- a/Meter.h +++ b/Meter.h @@ -42,7 +42,7 @@ typedef struct MeterClass_ { const char* const uiName; const char* const caption; const char* const description; - const char maxItems; + const uint8_t maxItems; } MeterClass; #define As_Meter(this_) ((const MeterClass*)((this_)->super.klass)) @@ -75,7 +75,7 @@ struct Meter_ { GraphData* drawData; int h; const ProcessList* pl; - char curItems; + uint8_t curItems; double* values; double total; void* meterData;