From 98f0ce36d9f2b3e7b0ec955bb6ccbfd8e76c42c5 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Fri, 3 May 2024 03:52:57 +0800 Subject: [PATCH] Explicitly specify supported modes of all meters This reduces code size by not needing to check if 'supportedModes' is zero. --- BatteryMeter.c | 1 + CPUMeter.c | 13 +++++++++++++ DiskIOMeter.c | 1 + DynamicMeter.c | 1 + FileDescriptorMeter.c | 1 + LoadAverageMeter.c | 2 ++ MemoryMeter.c | 1 + MemorySwapMeter.c | 1 + Meter.c | 6 ------ NetworkIOMeter.c | 1 + SwapMeter.c | 1 + TasksMeter.c | 1 + linux/GPUMeter.c | 1 + linux/HugePageMeter.c | 1 + linux/PressureStallMeter.c | 6 ++++++ linux/ZramMeter.c | 1 + zfs/ZfsArcMeter.c | 1 + zfs/ZfsCompressedArcMeter.c | 1 + 18 files changed, 35 insertions(+), 6 deletions(-) diff --git a/BatteryMeter.c b/BatteryMeter.c index dad7754ac..001249d4c 100644 --- a/BatteryMeter.c +++ b/BatteryMeter.c @@ -62,6 +62,7 @@ const MeterClass BatteryMeter_class = { }, .updateValues = BatteryMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 1, .total = 100.0, .attributes = BatteryMeter_attributes, diff --git a/CPUMeter.c b/CPUMeter.c index 1077f4e1b..f5716d93e 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -344,6 +344,7 @@ const MeterClass CPUMeter_class = { .updateValues = CPUMeter_updateValues, .getUiName = CPUMeter_getUiName, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = CPU_METER_ITEMCOUNT, .total = 100.0, .attributes = CPUMeter_attributes, @@ -361,6 +362,7 @@ const MeterClass AllCPUsMeter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .total = 100.0, .attributes = CPUMeter_attributes, .name = "AllCPUs", @@ -381,6 +383,7 @@ const MeterClass AllCPUs2Meter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -402,6 +405,7 @@ const MeterClass LeftCPUsMeter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -423,6 +427,7 @@ const MeterClass RightCPUsMeter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -444,6 +449,7 @@ const MeterClass LeftCPUs2Meter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -465,6 +471,7 @@ const MeterClass RightCPUs2Meter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -486,6 +493,7 @@ const MeterClass AllCPUs4Meter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -507,6 +515,7 @@ const MeterClass LeftCPUs4Meter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -528,6 +537,7 @@ const MeterClass RightCPUs4Meter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -549,6 +559,7 @@ const MeterClass AllCPUs8Meter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -570,6 +581,7 @@ const MeterClass LeftCPUs8Meter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, @@ -591,6 +603,7 @@ const MeterClass RightCPUs8Meter_class = { }, .updateValues = AllCPUsMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .total = 100.0, .attributes = CPUMeter_attributes, diff --git a/DiskIOMeter.c b/DiskIOMeter.c index 8d658de84..8af7d9563 100644 --- a/DiskIOMeter.c +++ b/DiskIOMeter.c @@ -152,6 +152,7 @@ const MeterClass DiskIOMeter_class = { }, .updateValues = DiskIOMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 1, .total = 100.0, .attributes = DiskIOMeter_attributes, diff --git a/DynamicMeter.c b/DynamicMeter.c index 15d853bd3..513296023 100644 --- a/DynamicMeter.c +++ b/DynamicMeter.c @@ -123,6 +123,7 @@ const MeterClass DynamicMeter_class = { .getCaption = DynamicMeter_getCaption, .getUiName = DynamicMeter_getUiName, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 0, .total = 100.0, .attributes = DynamicMeter_attributes, diff --git a/FileDescriptorMeter.c b/FileDescriptorMeter.c index cf1ec9331..cd3baf58c 100644 --- a/FileDescriptorMeter.c +++ b/FileDescriptorMeter.c @@ -108,6 +108,7 @@ const MeterClass FileDescriptorMeter_class = { }, .updateValues = FileDescriptorMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 2, .total = 65536.0, .attributes = FileDescriptorMeter_attributes, diff --git a/LoadAverageMeter.c b/LoadAverageMeter.c index 30c58bb96..6bf13a03e 100644 --- a/LoadAverageMeter.c +++ b/LoadAverageMeter.c @@ -109,6 +109,7 @@ const MeterClass LoadAverageMeter_class = { }, .updateValues = LoadAverageMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 3, .total = 100.0, .attributes = LoadAverageMeter_attributes, @@ -126,6 +127,7 @@ const MeterClass LoadMeter_class = { }, .updateValues = LoadMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 1, .total = 100.0, .attributes = LoadMeter_attributes, diff --git a/MemoryMeter.c b/MemoryMeter.c index 573b89836..3b7835256 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -109,6 +109,7 @@ const MeterClass MemoryMeter_class = { }, .updateValues = MemoryMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = MEMORY_METER_ITEMCOUNT, .total = 100.0, .attributes = MemoryMeter_attributes, diff --git a/MemorySwapMeter.c b/MemorySwapMeter.c index e1e5b1042..079c0d2ea 100644 --- a/MemorySwapMeter.c +++ b/MemorySwapMeter.c @@ -93,6 +93,7 @@ const MeterClass MemorySwapMeter_class = { }, .updateValues = MemorySwapMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .isMultiColumn = true, .name = "MemorySwap", .uiName = "Memory & Swap", diff --git a/Meter.c b/Meter.c index 6ba80e553..9c8fa5cd3 100644 --- a/Meter.c +++ b/Meter.c @@ -451,9 +451,6 @@ void Meter_setMode(Meter* this, MeterModeId modeIndex) { } uint32_t supportedModes = Meter_supportedModes(this); - if (!supportedModes) { - supportedModes = METERMODE_DEFAULT_SUPPORTED; - } assert(supportedModes); assert(!(supportedModes & (1 << 0))); @@ -480,9 +477,6 @@ void Meter_setMode(Meter* this, MeterModeId modeIndex) { MeterModeId Meter_nextSupportedMode(const Meter* this) { uint32_t supportedModes = Meter_supportedModes(this); - if (!supportedModes) { - supportedModes = METERMODE_DEFAULT_SUPPORTED; - } assert(supportedModes); assert(this->mode < UINT32_WIDTH); diff --git a/NetworkIOMeter.c b/NetworkIOMeter.c index 6bc2d0827..da3ce71da 100644 --- a/NetworkIOMeter.c +++ b/NetworkIOMeter.c @@ -169,6 +169,7 @@ const MeterClass NetworkIOMeter_class = { }, .updateValues = NetworkIOMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 2, .total = 100.0, .attributes = NetworkIOMeter_attributes, diff --git a/SwapMeter.c b/SwapMeter.c index 1055a6e70..29c295d32 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -73,6 +73,7 @@ const MeterClass SwapMeter_class = { }, .updateValues = SwapMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = SWAP_METER_ITEMCOUNT, .total = 100.0, .attributes = SwapMeter_attributes, diff --git a/TasksMeter.c b/TasksMeter.c index aa41e631e..fc1e4b0ed 100644 --- a/TasksMeter.c +++ b/TasksMeter.c @@ -72,6 +72,7 @@ const MeterClass TasksMeter_class = { }, .updateValues = TasksMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 4, .total = 100.0, .attributes = TasksMeter_attributes, diff --git a/linux/GPUMeter.c b/linux/GPUMeter.c index fbd32ea82..628d4c71c 100644 --- a/linux/GPUMeter.c +++ b/linux/GPUMeter.c @@ -170,6 +170,7 @@ const MeterClass GPUMeter_class = { .done = GPUMeter_done, .updateValues = GPUMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = ARRAYSIZE(GPUMeter_engineData) + 1, .total = 100.0, .attributes = GPUMeter_attributes, diff --git a/linux/HugePageMeter.c b/linux/HugePageMeter.c index 058ab4b64..bd16f5dc2 100644 --- a/linux/HugePageMeter.c +++ b/linux/HugePageMeter.c @@ -99,6 +99,7 @@ const MeterClass HugePageMeter_class = { }, .updateValues = HugePageMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = ARRAYSIZE(HugePageMeter_active_labels), .total = 100.0, .attributes = HugePageMeter_attributes, diff --git a/linux/PressureStallMeter.c b/linux/PressureStallMeter.c index f7962475e..5010c11d2 100644 --- a/linux/PressureStallMeter.c +++ b/linux/PressureStallMeter.c @@ -75,6 +75,7 @@ const MeterClass PressureStallCPUSomeMeter_class = { }, .updateValues = PressureStallMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 3, .total = 100.0, .attributes = PressureStallMeter_attributes, @@ -92,6 +93,7 @@ const MeterClass PressureStallIOSomeMeter_class = { }, .updateValues = PressureStallMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 3, .total = 100.0, .attributes = PressureStallMeter_attributes, @@ -109,6 +111,7 @@ const MeterClass PressureStallIOFullMeter_class = { }, .updateValues = PressureStallMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 3, .total = 100.0, .attributes = PressureStallMeter_attributes, @@ -126,6 +129,7 @@ const MeterClass PressureStallIRQFullMeter_class = { }, .updateValues = PressureStallMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 3, .total = 100.0, .attributes = PressureStallMeter_attributes, @@ -143,6 +147,7 @@ const MeterClass PressureStallMemorySomeMeter_class = { }, .updateValues = PressureStallMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 3, .total = 100.0, .attributes = PressureStallMeter_attributes, @@ -160,6 +165,7 @@ const MeterClass PressureStallMemoryFullMeter_class = { }, .updateValues = PressureStallMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 3, .total = 100.0, .attributes = PressureStallMeter_attributes, diff --git a/linux/ZramMeter.c b/linux/ZramMeter.c index 8329f0146..2a1c7715c 100644 --- a/linux/ZramMeter.c +++ b/linux/ZramMeter.c @@ -75,6 +75,7 @@ const MeterClass ZramMeter_class = { }, .updateValues = ZramMeter_updateValues, .defaultMode = BAR_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = ZRAM_METER_ITEMCOUNT, .total = 100.0, .attributes = ZramMeter_attributes, diff --git a/zfs/ZfsArcMeter.c b/zfs/ZfsArcMeter.c index 32f5bb34b..87b7e19ce 100644 --- a/zfs/ZfsArcMeter.c +++ b/zfs/ZfsArcMeter.c @@ -91,6 +91,7 @@ const MeterClass ZfsArcMeter_class = { }, .updateValues = ZfsArcMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 6, .total = 100.0, .attributes = ZfsArcMeter_attributes, diff --git a/zfs/ZfsCompressedArcMeter.c b/zfs/ZfsCompressedArcMeter.c index 4d47040ca..35ab8b379 100644 --- a/zfs/ZfsCompressedArcMeter.c +++ b/zfs/ZfsCompressedArcMeter.c @@ -79,6 +79,7 @@ const MeterClass ZfsCompressedArcMeter_class = { }, .updateValues = ZfsCompressedArcMeter_updateValues, .defaultMode = TEXT_METERMODE, + .supportedModes = METERMODE_DEFAULT_SUPPORTED, .maxItems = 1, .total = 100.0, .attributes = ZfsCompressedArcMeter_attributes,