summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2022-04-18 11:17:21 +0800
committerBenBE <BenBE@geshi.org>2022-04-18 12:30:40 +0200
commitee1bf2f9172ab11f867a87d7031408f9df1d8889 (patch)
tree0837add6fdd1afa7ba67e7ad5244ec79965b5d36
parentafc4a9d657790265dc8b005366d6ba7ca9cc2f95 (diff)
Process: Fix PID & UID column widths off-by-one error
If the max PID or UID value for a platform is exactly a power of ten (10000, 100000, etc.) the column widths of PID and UID would be 1 char less than the correct number of digits. This is caused by the wrong rounding function (ceil(x)); change to the correct one (trunc(x) + 1). Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
-rw-r--r--Process.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Process.c b/Process.c
index 77e78f04..59006fa7 100644
--- a/Process.c
+++ b/Process.c
@@ -54,7 +54,7 @@ void Process_setupColumnWidths() {
return;
}
- Process_pidDigits = ceil(log10(maxPid));
+ Process_pidDigits = (int)log10(maxPid) + 1;
assert(Process_pidDigits <= PROCESS_MAX_PID_DIGITS);
}
@@ -64,7 +64,7 @@ void Process_setUidColumnWidth(uid_t maxUid) {
return;
}
- Process_uidDigits = ceil(log10(maxUid));
+ Process_uidDigits = (int)log10(maxUid) + 1;
assert(Process_uidDigits <= PROCESS_MAX_UID_DIGITS);
}

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