Skip to content

Commit

Permalink
Explicitly specify supported modes of all meters
Browse files Browse the repository at this point in the history
This reduces code size by not needing to check if 'supportedModes' is
zero.
  • Loading branch information
Explorer09 committed May 2, 2024
1 parent 252c882 commit 98f0ce3
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 6 deletions.
1 change: 1 addition & 0 deletions BatteryMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions CPUMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions DiskIOMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions DynamicMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions FileDescriptorMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions LoadAverageMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions MemoryMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions MemorySwapMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions NetworkIOMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions SwapMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions TasksMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions linux/GPUMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions linux/HugePageMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions linux/PressureStallMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions linux/ZramMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions zfs/ZfsArcMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions zfs/ZfsCompressedArcMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 98f0ce3

Please sign in to comment.