Skip to content

Commit

Permalink
Process: Fix PID & UID column widths off-by-one error
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Explorer09 authored and BenBE committed Apr 18, 2022
1 parent afc4a9d commit ee1bf2f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit ee1bf2f

Please sign in to comment.