Use size_t as len type for Meter_UpdateValues

Most of the time the parameter is passed to snprintf type functions
This commit is contained in:
Christian Göttsche
2020-11-24 18:31:03 +01:00
committed by Benny Baumann
parent d9224c66a4
commit e1ce141bc3
21 changed files with 33 additions and 30 deletions

View File

@ -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";

View File

@ -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();

View File

@ -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;

View File

@ -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) {