summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-10-06 13:13:16 +0200
committerBenBE <BenBE@geshi.org>2021-03-04 23:57:45 +0100
commit2d1042adb382aa95456beff31b40abb7196567a0 (patch)
tree29e1a48c2927ce887a777b20847efae16b73c977
parent23c5b9ce3c50a7c7aaa9a5734cad50d12610d8d8 (diff)
Save text buffer in Meter
-rw-r--r--BatteryMeter.c6
-rw-r--r--CPUMeter.c6
-rw-r--r--ClockMeter.c4
-rw-r--r--DateMeter.c4
-rw-r--r--DateTimeMeter.c4
-rw-r--r--DiskIOMeter.c6
-rw-r--r--HostnameMeter.c4
-rw-r--r--LoadAverageMeter.c8
-rw-r--r--MemoryMeter.c4
-rw-r--r--Meter.c32
-rw-r--r--Meter.h11
-rw-r--r--NetworkIOMeter.c6
-rw-r--r--SwapMeter.c4
-rw-r--r--SysArchMeter.c4
-rw-r--r--TasksMeter.c4
-rw-r--r--UptimeMeter.c6
-rw-r--r--linux/HugePageMeter.c4
-rw-r--r--linux/PressureStallMeter.c4
-rw-r--r--linux/SELinuxMeter.c4
-rw-r--r--linux/SystemdMeter.c4
-rw-r--r--linux/ZramMeter.c4
-rw-r--r--zfs/ZfsArcMeter.c4
-rw-r--r--zfs/ZfsCompressedArcMeter.c4
23 files changed, 73 insertions, 68 deletions
diff --git a/BatteryMeter.c b/BatteryMeter.c
index 2c808c72..26a5ac48 100644
--- a/BatteryMeter.c
+++ b/BatteryMeter.c
@@ -21,7 +21,7 @@ static const int BatteryMeter_attributes[] = {
BATTERY
};
-static void BatteryMeter_updateValues(Meter* this, char* buffer, size_t len) {
+static void BatteryMeter_updateValues(Meter* this) {
ACPresence isOnAC;
double percent;
@@ -29,7 +29,7 @@ static void BatteryMeter_updateValues(Meter* this, char* buffer, size_t len) {
if (isnan(percent)) {
this->values[0] = NAN;
- xSnprintf(buffer, len, "N/A");
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "N/A");
return;
}
@@ -49,7 +49,7 @@ static void BatteryMeter_updateValues(Meter* this, char* buffer, size_t len) {
break;
}
- xSnprintf(buffer, len, "%.1f%%%s", percent, text);
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.1f%%%s", percent, text);
}
const MeterClass BatteryMeter_class = {
diff --git a/CPUMeter.c b/CPUMeter.c
index a39a3cb9..ad98dcdc 100644
--- a/CPUMeter.c
+++ b/CPUMeter.c
@@ -50,10 +50,10 @@ static void CPUMeter_init(Meter* this) {
Meter_setCaption(this, "Avg");
}
-static void CPUMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void CPUMeter_updateValues(Meter* this) {
int cpu = this->param;
if (cpu > this->pl->cpuCount) {
- xSnprintf(buffer, size, "absent");
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "absent");
for (uint8_t i = 0; i < this->curItems; i++)
this->values[i] = 0;
return;
@@ -91,7 +91,7 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, size_t size) {
}
#endif
- xSnprintf(buffer, size, "%s%s%s%s%s",
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s%s%s%s%s",
cpuUsageBuffer,
(cpuUsageBuffer[0] && (cpuFrequencyBuffer[0] || cpuTemperatureBuffer[0])) ? " " : "",
cpuFrequencyBuffer,
diff --git a/ClockMeter.c b/ClockMeter.c
index 654d9074..410c7e8a 100644
--- a/ClockMeter.c
+++ b/ClockMeter.c
@@ -19,12 +19,12 @@ static const int ClockMeter_attributes[] = {
CLOCK
};
-static void ClockMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void ClockMeter_updateValues(Meter* this) {
time_t t = time(NULL);
struct tm result;
const struct tm* lt = localtime_r(&t, &result);
this->values[0] = lt->tm_hour * 60 + lt->tm_min;
- strftime(buffer, size, "%H:%M:%S", lt);
+ strftime(this->txtBuffer, sizeof(this->txtBuffer), "%H:%M:%S", lt);
}
const MeterClass ClockMeter_class = {
diff --git a/DateMeter.c b/DateMeter.c
index c2aa7ea1..ac653b62 100644
--- a/DateMeter.c
+++ b/DateMeter.c
@@ -19,7 +19,7 @@ static const int DateMeter_attributes[] = {
DATE
};
-static void DateMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void DateMeter_updateValues(Meter* this) {
time_t t = time(NULL);
struct tm result;
const struct tm* lt = localtime_r(&t, &result);
@@ -30,7 +30,7 @@ static void DateMeter_updateValues(Meter* this, char* buffer, size_t size) {
} else {
this->total = 365;
}
- strftime(buffer, size, "%F", lt);
+ strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F", lt);
}
const MeterClass DateMeter_class = {
diff --git a/DateTimeMeter.c b/DateTimeMeter.c
index fc9e0c89..3fb515b5 100644
--- a/DateTimeMeter.c
+++ b/DateTimeMeter.c
@@ -19,7 +19,7 @@ static const int DateTimeMeter_attributes[] = {
DATETIME
};
-static void DateTimeMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void DateTimeMeter_updateValues(Meter* this) {
time_t t = time(NULL);
struct tm result;
const struct tm* lt = localtime_r(&t, &result);
@@ -30,7 +30,7 @@ static void DateTimeMeter_updateValues(Meter* this, char* buffer, size_t size) {
this->total = 365;
}
this->values[0] = lt->tm_yday;
- strftime(buffer, size, "%F %H:%M:%S", lt);
+ strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F %H:%M:%S", lt);
}
const MeterClass DateTimeMeter_class = {
diff --git a/DiskIOMeter.c b/DiskIOMeter.c
index 1be40aa6..dde007ed 100644
--- a/DiskIOMeter.c
+++ b/DiskIOMeter.c
@@ -30,7 +30,7 @@ static uint32_t cached_read_diff;
static uint32_t cached_write_diff;
static double cached_utilisation_diff;
-static void DiskIOMeter_updateValues(Meter* this, char* buffer, size_t len) {
+static void DiskIOMeter_updateValues(Meter* this) {
static uint64_t cached_last_update;
struct timeval tv;
@@ -52,7 +52,7 @@ static void DiskIOMeter_updateValues(Meter* this, char* buffer, size_t len) {
hasData = Platform_getDiskIO(&data);
if (!hasData) {
this->values[0] = 0;
- xSnprintf(buffer, len, "no data");
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "no data");
return;
}
@@ -89,7 +89,7 @@ static void DiskIOMeter_updateValues(Meter* this, char* buffer, size_t len) {
char bufferRead[12], bufferWrite[12];
Meter_humanUnit(bufferRead, cached_read_diff, sizeof(bufferRead));
Meter_humanUnit(bufferWrite, cached_write_diff, sizeof(bufferWrite));
- snprintf(buffer, len, "%sB %sB %.1f%%", bufferRead, bufferWrite, cached_utilisation_diff);
+ snprintf(this->txtBuffer, sizeof(this->txtBuffer), "%sB %sB %.1f%%", bufferRead, bufferWrite, cached_utilisation_diff);
}
static void DiskIOMeter_display(ATTR_UNUSED const Object* cast, RichString* out) {
diff --git a/HostnameMeter.c b/HostnameMeter.c
index 924def11..4968fd30 100644
--- a/HostnameMeter.c
+++ b/HostnameMeter.c
@@ -20,8 +20,8 @@ static const int HostnameMeter_attributes[] = {
HOSTNAME
};
-static void HostnameMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t size) {
- Platform_getHostname(buffer, size);
+static void HostnameMeter_updateValues(Meter* this) {
+ Platform_getHostname(this->txtBuffer, sizeof(this->txtBuffer));
}
const MeterClass HostnameMeter_class = {
diff --git a/LoadAverageMeter.c b/LoadAverageMeter.c
index 0c7b8339..196cee9f 100644
--- a/LoadAverageMeter.c
+++ b/LoadAverageMeter.c
@@ -36,7 +36,7 @@ static const int High_attributes[] = {
METER_VALUE_ERROR
};
-static void LoadAverageMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void LoadAverageMeter_updateValues(Meter* this) {
Platform_getLoadAverage(&this->values[0], &this->values[1], &this->values[2]);
// only show bar for 1min value
@@ -54,7 +54,7 @@ static void LoadAverageMeter_updateValues(Meter* this, char* buffer, size_t size
this->total = 2 * this->pl->cpuCount;
}
- xSnprintf(buffer, size, "%.2f/%.2f/%.2f", this->values[0], this->values[1], this->values[2]);
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.2f/%.2f/%.2f", this->values[0], this->values[1], this->values[2]);
}
static void LoadAverageMeter_display(const Object* cast, RichString* out) {
@@ -68,7 +68,7 @@ static void LoadAverageMeter_display(const Object* cast, RichString* out) {
RichString_appendAscii(out, CRT_colors[LOAD_AVERAGE_FIFTEEN], buffer);
}
-static void LoadMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void LoadMeter_updateValues(Meter* this) {
double five, fifteen;
Platform_getLoadAverage(&this->values[0], &five, &fifteen);
@@ -84,7 +84,7 @@ static void LoadMeter_updateValues(Meter* this, char* buffer, size_t size) {
this->total = 2 * this->pl->cpuCount;
}
- xSnprintf(buffer, size, "%.2f", this->values[0]);
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.2f", this->values[0]);
}
static void LoadMeter_display(const Object* cast, RichString* out) {
diff --git a/MemoryMeter.c b/MemoryMeter.c
index dd219bc0..7075f229 100644
--- a/MemoryMeter.c
+++ b/MemoryMeter.c
@@ -21,7 +21,9 @@ static const int MemoryMeter_attributes[] = {
MEMORY_CACHE
};
-static void MemoryMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void MemoryMeter_updateValues(Meter* this) {
+ char* buffer = this->txtBuffer;
+ size_t size = sizeof(this->txtBuffer);
int written;
/* available memory is not supported on all platforms */
diff --git a/Meter.c b/Meter.c
index e8bfaad0..1099a0bc 100644
--- a/Meter.c
+++ b/Meter.c
@@ -96,11 +96,11 @@ void Meter_setCaption(Meter* this, const char* caption) {
free_and_xStrdup(&this->caption, caption);
}
-static inline void Meter_displayBuffer(const Meter* this, const char* buffer, RichString* out) {
+static inline void Meter_displayBuffer(const Meter* this, RichString* out) {
if (Object_displayFn(this)) {
Object_display(this, out);
} else {
- RichString_writeWide(out, CRT_colors[Meter_attributes(this)[0]], buffer);
+ RichString_writeWide(out, CRT_colors[Meter_attributes(this)[0]], this->txtBuffer);
}
}
@@ -153,9 +153,8 @@ ListItem* Meter_toListItem(const Meter* this, bool moving) {
/* ---------- TextMeterMode ---------- */
-static void TextMeterMode_draw(Meter* this, int x, int y, int w) {
- char buffer[METER_BUFFER_LEN];
- Meter_updateValues(this, buffer, sizeof(buffer));
+static void TextMeterMode_draw(Meter* this, int x, int y, ATTR_UNUSED int w) {
+ Meter_updateValues(this);
attrset(CRT_colors[METER_TEXT]);
mvaddnstr(y, x, this->caption, w - 1);
@@ -168,7 +167,7 @@ static void TextMeterMode_draw(Meter* this, int x, int y, int w) {
return;
RichString_begin(out);
- Meter_displayBuffer(this, buffer, &out);
+ Meter_displayBuffer(this, &out);
RichString_printoffnVal(out, y, x, 0, w - 1);
RichString_end(out);
}
@@ -178,8 +177,7 @@ static void TextMeterMode_draw(Meter* this, int x, int y, int w) {
static const char BarMeterMode_characters[] = "|#*@$%&.";
static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
- char buffer[METER_BUFFER_LEN];
- Meter_updateValues(this, buffer, sizeof(buffer));
+ Meter_updateValues(this);
w -= 2;
attrset(CRT_colors[METER_TEXT]);
@@ -202,7 +200,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
// Pad with maximal spaces and then calculate needed starting position offset
RichString_begin(bar);
RichString_appendChr(&bar, 0, ' ', w);
- RichString_appendWide(&bar, 0, buffer);
+ RichString_appendWide(&bar, 0, this->txtBuffer);
int startPos = RichString_sizeVal(bar) - w;
if (startPos > w) {
// Text is too large for bar
@@ -297,7 +295,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
this->drawData = xCalloc(1, sizeof(GraphData));
}
GraphData* data = this->drawData;
- const int nValues = METER_BUFFER_LEN;
+ const int nValues = METER_GRAPHDATA_SIZE;
const char* const* GraphMeterMode_dots;
int GraphMeterMode_pixPerRow;
@@ -328,8 +326,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
for (int i = 0; i < nValues - 1; i++)
data->values[i] = data->values[i + 1];
- char buffer[METER_BUFFER_LEN];
- Meter_updateValues(this, buffer, sizeof(buffer));
+ Meter_updateValues(this);
double value = 0.0;
for (uint8_t i = 0; i < this->curItems; i++)
@@ -397,11 +394,10 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
#endif
LEDMeterMode_digits = LEDMeterMode_digitsAscii;
- char buffer[METER_BUFFER_LEN];
- Meter_updateValues(this, buffer, sizeof(buffer));
+ Meter_updateValues(this);
RichString_begin(out);
- Meter_displayBuffer(this, buffer, &out);
+ Meter_displayBuffer(this, &out);
int yText =
#ifdef HAVE_LIBNCURSESW
@@ -466,10 +462,8 @@ const MeterMode* const Meter_modes[] = {
/* Blank meter */
-static void BlankMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t size) {
- if (size > 0) {
- *buffer = 0;
- }
+static void BlankMeter_updateValues(Meter* this) {
+ this->txtBuffer[0] = '\0';
}
static void BlankMeter_display(ATTR_UNUSED const Object* cast, RichString* out) {
diff --git a/Meter.h b/Meter.h
index 2a3cb7af..ad30f3b1 100644
--- a/Meter.h
+++ b/Meter.h
@@ -18,7 +18,8 @@ in the source distribution for its full text.
#include "ProcessList.h"
-#define METER_BUFFER_LEN 256
+#define METER_TXTBUFFER_LEN 256
+#define METER_GRAPHDATA_SIZE 256
#define METER_BUFFER_CHECK(buffer, size, written) \
do { \
@@ -49,7 +50,7 @@ typedef struct Meter_ Meter;
typedef void(*Meter_Init)(Meter*);
typedef void(*Meter_Done)(Meter*);
typedef void(*Meter_UpdateMode)(Meter*, int);
-typedef void(*Meter_UpdateValues)(Meter*, char*, size_t);
+typedef void(*Meter_UpdateValues)(Meter*);
typedef void(*Meter_Draw)(Meter*, int, int, int);
typedef struct MeterClass_ {
@@ -77,8 +78,7 @@ typedef struct MeterClass_ {
#define Meter_updateMode(this_, m_) As_Meter(this_)->updateMode((Meter*)(this_), m_)
#define Meter_drawFn(this_) As_Meter(this_)->draw
#define Meter_doneFn(this_) As_Meter(this_)->done
-#define Meter_updateValues(this_, buf_, sz_) \
- As_Meter(this_)->updateValues((Meter*)(this_), buf_, sz_)
+#define Meter_updateValues(this_) As_Meter(this_)->updateValues((Meter*)(this_))
#define Meter_defaultMode(this_) As_Meter(this_)->defaultMode
#define Meter_attributes(this_) As_Meter(this_)->attributes
#define Meter_name(this_) As_Meter(this_)->name
@@ -86,7 +86,7 @@ typedef struct MeterClass_ {
typedef struct GraphData_ {
struct timeval time;
- double values[METER_BUFFER_LEN];
+ double values[METER_GRAPHDATA_SIZE];
} GraphData;
struct Meter_ {
@@ -102,6 +102,7 @@ struct Meter_ {
const ProcessList* pl;
uint8_t curItems;
const int* curAttributes;
+ char txtBuffer[METER_TXTBUFFER_LEN];
double* values;
double total;
void* meterData;
diff --git a/NetworkIOMeter.c b/NetworkIOMeter.c
index 47605cd3..c0e1b06f 100644
--- a/NetworkIOMeter.c
+++ b/NetworkIOMeter.c
@@ -24,7 +24,7 @@ static uint32_t cached_rxp_diff;
static uint32_t cached_txb_diff;
static uint32_t cached_txp_diff;
-static void NetworkIOMeter_updateValues(Meter* this, char* buffer, size_t len) {
+static void NetworkIOMeter_updateValues(Meter* this) {
static uint64_t cached_last_update = 0;
struct timeval tv;
@@ -45,7 +45,7 @@ static void NetworkIOMeter_updateValues(Meter* this, char* buffer, size_t len) {
NetworkIOData data;
hasData = Platform_getNetworkIO(&data);
if (!hasData) {
- xSnprintf(buffer, len, "no data");
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "no data");
return;
}
@@ -95,7 +95,7 @@ static void NetworkIOMeter_updateValues(Meter* this, char* buffer, size_t len) {
char bufferBytesReceived[12], bufferBytesTransmitted[12];
Meter_humanUnit(bufferBytesReceived, cached_rxb_diff, sizeof(bufferBytesReceived));
Meter_humanUnit(bufferBytesTransmitted, cached_txb_diff, sizeof(bufferBytesTransmitted));
- xSnprintf(buffer, len, "rx:%siB/s tx:%siB/s", bufferBytesReceived, bufferBytesTransmitted);
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "rx:%siB/s tx:%siB/s", bufferBytesReceived, bufferBytesTransmitted);
}
static void NetworkIOMeter_display(ATTR_UNUSED const Object* cast, RichString* out) {
diff --git a/SwapMeter.c b/SwapMeter.c
index 81f006ec..fe10eab0 100644
--- a/SwapMeter.c
+++ b/SwapMeter.c
@@ -18,7 +18,9 @@ static const int SwapMeter_attributes[] = {
SWAP_CACHE
};
-static void SwapMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void SwapMeter_updateValues(Meter* this) {
+ char* buffer = this->txtBuffer;
+ size_t size = sizeof(this->txtBuffer);
int written;
Platform_setSwapValues(this);
diff --git a/SysArchMeter.c b/SysArchMeter.c
index c368e944..220ed466 100644
--- a/SysArchMeter.c
+++ b/SysArchMeter.c
@@ -14,13 +14,13 @@ in the source distribution for its full text.
static const int SysArchMeter_attributes[] = {HOSTNAME};
-static void SysArchMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t size) {
+static void SysArchMeter_updateValues(Meter* this) {
static char* string;
if (string == NULL)
Platform_getRelease(&string);
- String_safeStrncpy(buffer, string, size);
+ String_safeStrncpy(this->txtBuffer, string, sizeof(this->txtBuffer));
}
const MeterClass SysArchMeter_class = {
diff --git a/TasksMeter.c b/TasksMeter.c
index a760ce07..7b649b0c 100644
--- a/TasksMeter.c
+++ b/TasksMeter.c
@@ -23,7 +23,7 @@ static const int TasksMeter_attributes[] = {
TASKS_RUNNING
};
-static void TasksMeter_updateValues(Meter* this, char* buffer, size_t len) {
+static void TasksMeter_updateValues(Meter* this) {
const ProcessList* pl = this->pl;
this->values[0] = pl->kernelThreads;
this->values[1] = pl->userlandThreads;
@@ -35,7 +35,7 @@ static void TasksMeter_updateValues(Meter* this, char* buffer, size_t len) {
if (pl->settings->hideKernelThreads) {
this->values[0] = 0;
}
- xSnprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total);
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%d/%d", (int) this->values[3], (int) this->total);
}
static void TasksMeter_display(const Object* cast, RichString* out) {
diff --git a/UptimeMeter.c b/UptimeMeter.c
index 37740c21..51ceef8c 100644
--- a/UptimeMeter.c
+++ b/UptimeMeter.c
@@ -17,10 +17,10 @@ static const int UptimeMeter_attributes[] = {
UPTIME
};
-static void UptimeMeter_updateValues(Meter* this, char* buffer, size_t len) {
+static void UptimeMeter_updateValues(Meter* this) {
int totalseconds = Platform_getUptime();
if (totalseconds == -1) {
- xSnprintf(buffer, len, "(unknown)");
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "(unknown)");
return;
}
int seconds = totalseconds % 60;
@@ -41,7 +41,7 @@ static void UptimeMeter_updateValues(Meter* this, char* buffer, size_t len) {
} else {
daysbuf[0] = '\0';
}
- xSnprintf(buffer, len, "%s%02d:%02d:%02d", daysbuf, hours, minutes, seconds);
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s%02d:%02d:%02d", daysbuf, hours, minutes, seconds);
}
const MeterClass UptimeMeter_class = {
diff --git a/linux/HugePageMeter.c b/linux/HugePageMeter.c
index 242d2857..2a35c125 100644
--- a/linux/HugePageMeter.c
+++ b/linux/HugePageMeter.c
@@ -31,9 +31,11 @@ static const char* const HugePageMeter_labels[] = {
" 1G:", " 2G:", " 4G:", " 8G:", " 16G:", " 32G:", " 64G:", " 128G:", " 256G:", " 512G:",
};
-static void HugePageMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void HugePageMeter_updateValues(Meter* this) {
assert(ARRAYSIZE(HugePageMeter_labels) == HTOP_HUGEPAGE_COUNT);
+ char* buffer = this->txtBuffer;
+ size_t size = sizeof(this->txtBuffer);
int written;
memory_t usedTotal = 0;
unsigned nextUsed = 0;
diff --git a/linux/PressureStallMeter.c b/linux/PressureStallMeter.c
index 7486968f..238df7e4 100644
--- a/linux/PressureStallMeter.c
+++ b/linux/PressureStallMeter.c
@@ -25,7 +25,7 @@ static const int PressureStallMeter_attributes[] = {
PRESSURE_STALL_THREEHUNDRED
};
-static void PressureStallMeter_updateValues(Meter* this, char* buffer, size_t len) {
+static void PressureStallMeter_updateValues(Meter* this) {
const char* file;
if (strstr(Meter_name(this), "CPU")) {
file = "cpu";
@@ -47,7 +47,7 @@ static void PressureStallMeter_updateValues(Meter* this, char* buffer, size_t le
/* only print bar for ten (not sixty and threehundred), cause the sum is meaningless */
this->curItems = 1;
- xSnprintf(buffer, len, "%s %s %5.2lf%% %5.2lf%% %5.2lf%%", some ? "some" : "full", file, this->values[0], this->values[1], this->values[2]);
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s %s %5.2lf%% %5.2lf%% %5.2lf%%", some ? "some" : "full", file, this->values[0], this->values[1], this->values[2]);
}
static void PressureStallMeter_display(const Object* cast, RichString* out) {
diff --git a/linux/SELinuxMeter.c b/linux/SELinuxMeter.c
index c9fa1468..617e035f 100644
--- a/linux/SELinuxMeter.c
+++ b/linux/SELinuxMeter.c
@@ -69,11 +69,11 @@ static bool isSelinuxEnforcing(void) {
return !!enforce;
}
-static void SELinuxMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t len) {
+static void SELinuxMeter_updateValues(ATTR_UNUSED Meter* this) {
enabled = isSelinuxEnabled();
enforcing = isSelinuxEnforcing();
- xSnprintf(buffer, len, "%s%s", enabled ? "enabled" : "disabled", enabled ? (enforcing ? "; mode: enforcing" : "; mode: permissive") : "");
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s%s", enabled ? "enabled" : "disabled", enabled ? (enforcing ? "; mode: enforcing" : "; mode: permissive") : "");
}
const MeterClass SELinuxMeter_class = {
diff --git a/linux/SystemdMeter.c b/linux/SystemdMeter.c
index 54abbe50..24a47f74 100644
--- a/linux/SystemdMeter.c
+++ b/linux/SystemdMeter.c
@@ -262,7 +262,7 @@ static void updateViaExec(void) {
fclose(commandOutput);
}
-static void SystemdMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t size) {
+static void SystemdMeter_updateValues(Meter* this) {
free(systemState);
systemState = NULL;
nFailedUnits = nInstalledJobs = nNames = nJobs = INVALID_VALUE;
@@ -274,7 +274,7 @@ static void SystemdMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, siz
updateViaExec();
#endif /* !BUILD_STATIC || HAVE_LIBSYSTEMD */
- xSnprintf(buffer, size, "%s", systemState ? systemState : "???");
+ xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s", systemState ? systemState : "???");
}
static int zeroDigitColor(unsigned int value) {
diff --git a/linux/ZramMeter.c b/linux/ZramMeter.c
index 723de0ac..e91a499b 100644
--- a/linux/ZramMeter.c
+++ b/linux/ZramMeter.c
@@ -11,7 +11,9 @@ static const int ZramMeter_attributes[] = {
ZRAM
};
-static void ZramMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void ZramMeter_updateValues(Meter* this) {
+ char* buffer = this->txtBuffer;
+ size_t size = sizeof(this->txtBuffer);
int written;
Platform_setZramValues(this);
diff --git a/zfs/ZfsArcMeter.c b/zfs/ZfsArcMeter.c
index 81fd240e..766ff39e 100644
--- a/zfs/ZfsArcMeter.c
+++ b/zfs/ZfsArcMeter.c
@@ -33,7 +33,9 @@ void ZfsArcMeter_readStats(Meter* this, const ZfsArcStats* stats) {
this->values[5] = stats->size;
}
-static void ZfsArcMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void ZfsArcMeter_updateValues(Meter* this) {
+ char* buffer = this->txtBuffer;
+ size_t size = sizeof(this->txtBuffer);
int written;
Platform_setZfsArcValues(this);
diff --git a/zfs/ZfsCompressedArcMeter.c b/zfs/ZfsCompressedArcMeter.c
index d574215f..9e5ef3ea 100644
--- a/zfs/ZfsCompressedArcMeter.c
+++ b/zfs/ZfsCompressedArcMeter.c
@@ -36,10 +36,10 @@ static void ZfsCompressedArcMeter_printRatioString(const Meter* this, char* buff
xSnprintf(buffer, size, "%.2f:1", this->total / this->values[0]);
}
-static void ZfsCompressedArcMeter_updateValues(Meter* this, char* buffer, size_t size) {
+static void ZfsCompressedArcMeter_updateValues(Meter* this) {
Platform_setZfsCompressedArcValues(this);
- ZfsCompressedArcMeter_printRatioString(this, buffer, size);
+ ZfsCompressedArcMeter_printRatioString(this, this->txtBuffer, sizeof(this->txtBuffer));
}
static void ZfsCompressedArcMeter_display(const Object* cast, RichString* out) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy