diff options
author | Ivan Shapovalov <intelfx@intelfx.name> | 2023-03-12 20:17:03 +0400 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2023-04-23 16:00:17 +0200 |
commit | b2ada278403e643a3bc339783740f262b7879803 (patch) | |
tree | 081651d2cfa0c86d02c633cea81dcc40a233c825 | |
parent | 1b640dff5759d73458204c87e217dab8759badd9 (diff) |
{Memory,Swap}Meter: make sure new constants are used consistently
-rw-r--r-- | MemoryMeter.c | 6 | ||||
-rw-r--r-- | SwapMeter.c | 6 | ||||
-rw-r--r-- | linux/Platform.c | 4 |
3 files changed, 9 insertions, 7 deletions
diff --git a/MemoryMeter.c b/MemoryMeter.c index ac01dfe7..1dad1356 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -34,7 +34,9 @@ static void MemoryMeter_updateValues(Meter* this) { Platform_setMemoryValues(this); /* Do not print available memory in bar mode */ - this->curItems = 4; + static_assert(MEMORY_METER_AVAILABLE + 1 == MEMORY_METER_ITEMCOUNT, + "MEMORY_METER_AVAILABLE is not the last item in MemoryMeterValues"); + this->curItems = MEMORY_METER_AVAILABLE; written = Meter_humanUnit(buffer, this->values[MEMORY_METER_USED], size); METER_BUFFER_CHECK(buffer, size, written); @@ -87,7 +89,7 @@ const MeterClass MemoryMeter_class = { }, .updateValues = MemoryMeter_updateValues, .defaultMode = BAR_METERMODE, - .maxItems = 5, + .maxItems = MEMORY_METER_ITEMCOUNT, .total = 100.0, .attributes = MemoryMeter_attributes, .name = "Memory", diff --git a/SwapMeter.c b/SwapMeter.c index c0f48200..fea8e88b 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -28,10 +28,10 @@ static void SwapMeter_updateValues(Meter* this) { size_t size = sizeof(this->txtBuffer); int written; - this->values[1] = NAN; /* 'cached' not present on all platforms */ + this->values[SWAP_METER_CACHE] = NAN; /* 'cached' not present on all platforms */ Platform_setSwapValues(this); - written = Meter_humanUnit(buffer, this->values[0], size); + written = Meter_humanUnit(buffer, this->values[SWAP_METER_USED], size); METER_BUFFER_CHECK(buffer, size, written); METER_BUFFER_APPEND_CHR(buffer, size, '/'); @@ -64,7 +64,7 @@ const MeterClass SwapMeter_class = { }, .updateValues = SwapMeter_updateValues, .defaultMode = BAR_METERMODE, - .maxItems = 2, + .maxItems = SWAP_METER_ITEMCOUNT, .total = 100.0, .attributes = SwapMeter_attributes, .name = "Swap", diff --git a/linux/Platform.c b/linux/Platform.c index e004b9b1..c14736bb 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -376,8 +376,8 @@ void Platform_setMemoryValues(Meter* this) { void Platform_setSwapValues(Meter* this) { const ProcessList* pl = this->pl; this->total = pl->totalSwap; - this->values[0] = pl->usedSwap; - this->values[1] = pl->cachedSwap; + this->values[SWAP_METER_USED] = pl->usedSwap; + this->values[SWAP_METER_CACHE] = pl->cachedSwap; } void Platform_setZramValues(Meter* this) { |