diff options
author | Nathan Scott <nathans@redhat.com> | 2020-12-07 11:41:22 +1100 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2020-12-07 11:41:22 +1100 |
commit | b92cfa7d7ac09b4e8a3c377496edd49228221f72 (patch) | |
tree | aefa244b8140e21e2d02018e57c7b9fa0c7d23ec /linux | |
parent | 57d9ecc5519a44d4d08f1739ab4b741ccfc2d35a (diff) | |
parent | ad764ff972082608604634c84e5427e7bfdcda1a (diff) |
Merge branch 'conversion' of https://github.com/cgzones/htop into cgzones-conversion
Diffstat (limited to 'linux')
-rw-r--r-- | linux/LinuxProcess.c | 2 | ||||
-rw-r--r-- | linux/PressureStallMeter.c | 2 | ||||
-rw-r--r-- | linux/SELinuxMeter.c | 2 | ||||
-rw-r--r-- | linux/SystemdMeter.c | 2 | ||||
-rw-r--r-- | linux/ZramMeter.c | 35 |
5 files changed, 16 insertions, 27 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index f51cf1e3..8298000a 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -618,7 +618,7 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces bool coloring = this->settings->highlightMegabytes; char buffer[256]; buffer[255] = '\0'; int attr = CRT_colors[DEFAULT_COLOR]; - int n = sizeof(buffer) - 1; + size_t n = sizeof(buffer) - 1; switch ((int)field) { case TTY_NR: { if (lp->ttyDevice) { 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..e6b6937e 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); @@ -20,29 +20,18 @@ static void ZramMeter_updateValues(Meter* this, char* buffer, int size) { this->curItems = 1; written = Meter_humanUnit(buffer, this->values[0], size); - buffer += written; - size -= written; - if (size <= 0) { - return; - } - *buffer++ = '('; - size--; - if (size <= 0) { - return; - } + METER_BUFFER_CHECK(buffer, size, written); + + METER_BUFFER_APPEND_CHR(buffer, size, '('); + written = Meter_humanUnit(buffer, this->values[1], size); - buffer += written; - size -= written; - if (size <= 0) { - return; - } - *buffer++ = ')'; - size--; - if ((size -= written) > 0) { - *buffer++ = '/'; - size--; - Meter_humanUnit(buffer, this->total, size); - } + METER_BUFFER_CHECK(buffer, size, written); + + METER_BUFFER_APPEND_CHR(buffer, size, ')'); + + METER_BUFFER_APPEND_CHR(buffer, size, '/'); + + Meter_humanUnit(buffer, this->total, size); } static void ZramMeter_display(const Object* cast, RichString* out) { |