From 6db2d52261d676a378625a24c307fa718025bc5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 28 Sep 2020 12:23:07 +0200 Subject: [PATCH] Covert Meter attributes to file-local constant arrays --- BatteryMeter.c | 2 +- BatteryMeter.h | 2 -- CPUMeter.c | 11 +++++++++-- CPUMeter.h | 2 -- ClockMeter.c | 2 +- ClockMeter.h | 2 -- HostnameMeter.c | 2 +- HostnameMeter.h | 2 -- LoadAverageMeter.c | 10 +++++++--- LoadAverageMeter.h | 4 ---- MemoryMeter.c | 6 ++++-- MemoryMeter.h | 2 -- Meter.c | 2 +- Meter.h | 2 -- SwapMeter.c | 2 +- SwapMeter.h | 2 -- TasksMeter.c | 7 +++++-- TasksMeter.h | 2 -- UptimeMeter.c | 2 +- UptimeMeter.h | 2 -- 20 files changed, 31 insertions(+), 37 deletions(-) diff --git a/BatteryMeter.c b/BatteryMeter.c index 0ae2834c..733298a1 100644 --- a/BatteryMeter.c +++ b/BatteryMeter.c @@ -20,7 +20,7 @@ This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com). #include -int BatteryMeter_attributes[] = { +static const int BatteryMeter_attributes[] = { BATTERY }; diff --git a/BatteryMeter.h b/BatteryMeter.h index 658cd3f9..b67754d3 100644 --- a/BatteryMeter.h +++ b/BatteryMeter.h @@ -17,8 +17,6 @@ typedef enum ACPresence_ { AC_ERROR } ACPresence; -extern int BatteryMeter_attributes[]; - extern MeterClass BatteryMeter_class; #endif diff --git a/CPUMeter.c b/CPUMeter.c index c5e27124..44ef1add 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -16,8 +16,15 @@ in the source distribution for its full text. #include #include -int CPUMeter_attributes[] = { - CPU_NICE, CPU_NORMAL, CPU_SYSTEM, CPU_IRQ, CPU_SOFTIRQ, CPU_STEAL, CPU_GUEST, CPU_IOWAIT +static const int CPUMeter_attributes[] = { + CPU_NICE, + CPU_NORMAL, + CPU_SYSTEM, + CPU_IRQ, + CPU_SOFTIRQ, + CPU_STEAL, + CPU_GUEST, + CPU_IOWAIT }; static void CPUMeter_init(Meter* this) { diff --git a/CPUMeter.h b/CPUMeter.h index 62a1ddc3..6244c42a 100644 --- a/CPUMeter.h +++ b/CPUMeter.h @@ -22,8 +22,6 @@ typedef enum { CPU_METER_ITEMCOUNT = 9, // number of entries in this enum } CPUMeterValues; -extern int CPUMeter_attributes[]; - extern MeterClass CPUMeter_class; extern MeterClass AllCPUsMeter_class; diff --git a/ClockMeter.c b/ClockMeter.c index 3168b3e9..6ad191a2 100644 --- a/ClockMeter.c +++ b/ClockMeter.c @@ -12,7 +12,7 @@ in the source distribution for its full text. #include -int ClockMeter_attributes[] = { +static const int ClockMeter_attributes[] = { CLOCK }; diff --git a/ClockMeter.h b/ClockMeter.h index e888d585..bb6881ae 100644 --- a/ClockMeter.h +++ b/ClockMeter.h @@ -9,8 +9,6 @@ in the source distribution for its full text. #include "Meter.h" -extern int ClockMeter_attributes[]; - extern MeterClass ClockMeter_class; #endif diff --git a/HostnameMeter.c b/HostnameMeter.c index 60bd8125..edb23358 100644 --- a/HostnameMeter.c +++ b/HostnameMeter.c @@ -12,7 +12,7 @@ in the source distribution for its full text. #include -int HostnameMeter_attributes[] = { +static const int HostnameMeter_attributes[] = { HOSTNAME }; diff --git a/HostnameMeter.h b/HostnameMeter.h index ecfab1aa..152100d0 100644 --- a/HostnameMeter.h +++ b/HostnameMeter.h @@ -9,8 +9,6 @@ in the source distribution for its full text. #include "Meter.h" -extern int HostnameMeter_attributes[]; - extern MeterClass HostnameMeter_class; #endif diff --git a/LoadAverageMeter.c b/LoadAverageMeter.c index db397b6c..3f75aeca 100644 --- a/LoadAverageMeter.c +++ b/LoadAverageMeter.c @@ -11,11 +11,15 @@ in the source distribution for its full text. #include "Platform.h" -int LoadAverageMeter_attributes[] = { - LOAD_AVERAGE_ONE, LOAD_AVERAGE_FIVE, LOAD_AVERAGE_FIFTEEN +static const int LoadAverageMeter_attributes[] = { + LOAD_AVERAGE_ONE, + LOAD_AVERAGE_FIVE, + LOAD_AVERAGE_FIFTEEN }; -int LoadMeter_attributes[] = { LOAD }; +static const int LoadMeter_attributes[] = { + LOAD +}; static void LoadAverageMeter_updateValues(Meter* this, char* buffer, int size) { Platform_getLoadAverage(&this->values[0], &this->values[1], &this->values[2]); diff --git a/LoadAverageMeter.h b/LoadAverageMeter.h index 83d3c8f5..5ac771a4 100644 --- a/LoadAverageMeter.h +++ b/LoadAverageMeter.h @@ -9,10 +9,6 @@ in the source distribution for its full text. #include "Meter.h" -extern int LoadAverageMeter_attributes[]; - -extern int LoadMeter_attributes[]; - extern MeterClass LoadAverageMeter_class; extern MeterClass LoadMeter_class; diff --git a/MemoryMeter.c b/MemoryMeter.c index 91f75b9c..cac0da72 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -17,8 +17,10 @@ in the source distribution for its full text. #include -int MemoryMeter_attributes[] = { - MEMORY_USED, MEMORY_BUFFERS, MEMORY_CACHE +static const int MemoryMeter_attributes[] = { + MEMORY_USED, + MEMORY_BUFFERS, + MEMORY_CACHE }; static void MemoryMeter_updateValues(Meter* this, char* buffer, int size) { diff --git a/MemoryMeter.h b/MemoryMeter.h index 771aa735..f8df247d 100644 --- a/MemoryMeter.h +++ b/MemoryMeter.h @@ -9,8 +9,6 @@ in the source distribution for its full text. #include "Meter.h" -extern int MemoryMeter_attributes[]; - extern MeterClass MemoryMeter_class; #endif diff --git a/Meter.c b/Meter.c index d144b5b8..c453b4bc 100644 --- a/Meter.c +++ b/Meter.c @@ -433,7 +433,7 @@ static void BlankMeter_display(Object* cast, RichString* out) { RichString_prune(out); } -int BlankMeter_attributes[] = { +static const int BlankMeter_attributes[] = { DEFAULT_COLOR }; diff --git a/Meter.h b/Meter.h index c4d00396..03b49608 100644 --- a/Meter.h +++ b/Meter.h @@ -105,8 +105,6 @@ ListItem* Meter_toListItem(Meter* this, bool moving); extern MeterMode* Meter_modes[]; -extern int BlankMeter_attributes[]; - extern MeterClass BlankMeter_class; #endif diff --git a/SwapMeter.c b/SwapMeter.c index fcf450ee..ae4d4097 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -17,7 +17,7 @@ in the source distribution for its full text. #include -int SwapMeter_attributes[] = { +static const int SwapMeter_attributes[] = { SWAP }; diff --git a/SwapMeter.h b/SwapMeter.h index 69a5855f..2ba596cb 100644 --- a/SwapMeter.h +++ b/SwapMeter.h @@ -9,8 +9,6 @@ in the source distribution for its full text. #include "Meter.h" -extern int SwapMeter_attributes[]; - extern MeterClass SwapMeter_class; #endif diff --git a/TasksMeter.c b/TasksMeter.c index 0b37ab27..45d3ba15 100644 --- a/TasksMeter.c +++ b/TasksMeter.c @@ -11,8 +11,11 @@ in the source distribution for its full text. #include "CRT.h" -int TasksMeter_attributes[] = { - CPU_SYSTEM, PROCESS_THREAD, PROCESS, TASKS_RUNNING +static const int TasksMeter_attributes[] = { + CPU_SYSTEM, + PROCESS_THREAD, + PROCESS, + TASKS_RUNNING }; static void TasksMeter_updateValues(Meter* this, char* buffer, int len) { diff --git a/TasksMeter.h b/TasksMeter.h index bdb62a73..82ddc081 100644 --- a/TasksMeter.h +++ b/TasksMeter.h @@ -9,8 +9,6 @@ in the source distribution for its full text. #include "Meter.h" -extern int TasksMeter_attributes[]; - extern MeterClass TasksMeter_class; #endif diff --git a/UptimeMeter.c b/UptimeMeter.c index da1c9fd0..0a9589a0 100644 --- a/UptimeMeter.c +++ b/UptimeMeter.c @@ -10,7 +10,7 @@ in the source distribution for its full text. #include "CRT.h" -int UptimeMeter_attributes[] = { +static const int UptimeMeter_attributes[] = { UPTIME }; diff --git a/UptimeMeter.h b/UptimeMeter.h index 5fa1e931..cac51aad 100644 --- a/UptimeMeter.h +++ b/UptimeMeter.h @@ -9,8 +9,6 @@ in the source distribution for its full text. #include "Meter.h" -extern int UptimeMeter_attributes[]; - extern MeterClass UptimeMeter_class; #endif