aboutsummaryrefslogtreecommitdiffstats
path: root/TasksMeter.c
diff options
context:
space:
mode:
authorGraham Inggs <ginggs@debian.org>2018-02-05 14:48:53 +0200
committerGraham Inggs <ginggs@debian.org>2018-02-05 14:48:53 +0200
commit0bffedf65c053726a3a09be93c5eabfc113550fc (patch)
tree8c14970f1890c710df6f72aaa85781d62cee11e5 /TasksMeter.c
parentba3d665468e9752a81a50bb2df7639950e0a3c77 (diff)
parent2ee50d030178cede83eb9d0005fbc19f819d30fe (diff)
downloaddebian_htop-0bffedf65c053726a3a09be93c5eabfc113550fc.tar.gz
debian_htop-0bffedf65c053726a3a09be93c5eabfc113550fc.tar.bz2
debian_htop-0bffedf65c053726a3a09be93c5eabfc113550fc.zip
Merge tag 'upstream/2.1.0'
Upstream version 2.1.0
Diffstat (limited to 'TasksMeter.c')
-rw-r--r--TasksMeter.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/TasksMeter.c b/TasksMeter.c
index 78a1468..f56c861 100644
--- a/TasksMeter.c
+++ b/TasksMeter.c
@@ -23,14 +23,14 @@ static void TasksMeter_updateValues(Meter* this, char* buffer, int len) {
this->values[0] = pl->kernelThreads;
this->values[1] = pl->userlandThreads;
this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads;
- this->values[3] = pl->runningTasks;
+ this->values[3] = MIN(pl->runningTasks, pl->cpuCount);
if (pl->totalTasks > this->total) {
this->total = pl->totalTasks;
}
if (this->pl->settings->hideKernelThreads) {
this->values[0] = 0;
}
- snprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total);
+ xSnprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total);
}
static void TasksMeter_display(Object* cast, RichString* out) {
@@ -40,7 +40,7 @@ static void TasksMeter_display(Object* cast, RichString* out) {
int processes = (int) this->values[2];
- sprintf(buffer, "%d", processes);
+ xSnprintf(buffer, sizeof(buffer), "%d", processes);
RichString_write(out, CRT_colors[METER_VALUE], buffer);
int threadValueColor = CRT_colors[METER_VALUE];
int threadCaptionColor = CRT_colors[METER_TEXT];
@@ -50,18 +50,18 @@ static void TasksMeter_display(Object* cast, RichString* out) {
}
if (!settings->hideUserlandThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", ");
- sprintf(buffer, "%d", (int)this->values[1]);
+ xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[1]);
RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " thr");
}
if (!settings->hideKernelThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", ");
- sprintf(buffer, "%d", (int)this->values[0]);
+ xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[0]);
RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " kthr");
}
RichString_append(out, CRT_colors[METER_TEXT], "; ");
- sprintf(buffer, "%d", (int)this->values[3]);
+ xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[3]);
RichString_append(out, CRT_colors[TASKS_RUNNING], buffer);
RichString_append(out, CRT_colors[METER_TEXT], " running");
}

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