summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-11-24 18:31:03 +0100
committerBenny Baumann <BenBE@geshi.org>2020-12-06 16:03:44 +0100
commite1ce141bc3123c1dea7eb2ef908c8ebce945c72a (patch)
tree2da1f500777ba003c3ea1d73d97e259f0e099974 /linux
parentd9224c66a41e7918570b81d41495870c20380c1d (diff)
Use size_t as len type for Meter_UpdateValues
Most of the time the parameter is passed to snprintf type functions
Diffstat (limited to 'linux')
-rw-r--r--linux/PressureStallMeter.c2
-rw-r--r--linux/SELinuxMeter.c2
-rw-r--r--linux/SystemdMeter.c2
-rw-r--r--linux/ZramMeter.c14
4 files changed, 12 insertions, 8 deletions
diff --git a/linux/PressureStallMeter.c b/linux/PressureStallMeter.c
index d2fd7d37..745068c9 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, int len) {
+static void PressureStallMeter_updateValues(Meter* this, char* buffer, size_t len) {
const char* file;
if (strstr(Meter_name(this), "CPU")) {
file = "cpu";
diff --git a/linux/SELinuxMeter.c b/linux/SELinuxMeter.c
index a8b07bd3..64a3f2a7 100644
--- a/linux/SELinuxMeter.c
+++ b/linux/SELinuxMeter.c
@@ -70,7 +70,7 @@ static bool isSelinuxEnforcing(void) {
return !!enforce;
}
-static void SELinuxMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, int len) {
+static void SELinuxMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t len) {
enabled = isSelinuxEnabled();
enforcing = isSelinuxEnforcing();
diff --git a/linux/SystemdMeter.c b/linux/SystemdMeter.c
index d49185ee..4350d264 100644
--- a/linux/SystemdMeter.c
+++ b/linux/SystemdMeter.c
@@ -229,7 +229,7 @@ static void updateViaExec(void) {
fclose(commandOutput);
}
-static void SystemdMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, int size) {
+static void SystemdMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t size) {
free(systemState);
systemState = NULL;
nFailedUnits = nInstalledJobs = nNames = nJobs = INVALID_VALUE;
diff --git a/linux/ZramMeter.c b/linux/ZramMeter.c
index cee70586..35148871 100644
--- a/linux/ZramMeter.c
+++ b/linux/ZramMeter.c
@@ -11,7 +11,7 @@ static const int ZramMeter_attributes[] = {
ZRAM
};
-static void ZramMeter_updateValues(Meter* this, char* buffer, int size) {
+static void ZramMeter_updateValues(Meter* this, char* buffer, size_t size) {
int written;
Platform_setZramValues(this);
@@ -38,11 +38,15 @@ static void ZramMeter_updateValues(Meter* this, char* buffer, int size) {
}
*buffer++ = ')';
size--;
- if ((size -= written) > 0) {
- *buffer++ = '/';
- size--;
- Meter_humanUnit(buffer, this->total, size);
+ if (size <= 0) {
+ return;
+ }
+ *buffer++ = '/';
+ size--;
+ if (size <= 0) {
+ return;
}
+ Meter_humanUnit(buffer, this->total, size);
}
static void ZramMeter_display(const Object* cast, RichString* out) {

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