diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-01-27 15:11:48 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-01-30 14:21:26 +0100 |
commit | fdaa15bd8d6df7dd4721ed70a913865b343a80c7 (patch) | |
tree | 2015c85afa9a2167e1c92a151dea924e05c72570 /Process.c | |
parent | fee744abd2d7c1a3a9b8fa4ece7ddfc872078850 (diff) |
Linux: overhaul io process fields
- avoid UBSAN conversions
- print N/A on no data (i.e. as unprivileged user)
- fix rate calculation to show bytes (instead of a thousandth)
- print bytes as human number (i.e. 8MB) instead of 8388608
- stabilize sorting by adjusting NAN values to very tiny negative number
Diffstat (limited to 'Process.c')
-rw-r--r-- | Process.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -53,17 +53,16 @@ void Process_humanNumber(RichString* str, unsigned long long number, bool colori char buffer[10]; int len; - int largeNumberColor = CRT_colors[LARGE_NUMBER]; - int processMegabytesColor = CRT_colors[PROCESS_MEGABYTES]; - int processGigabytesColor = CRT_colors[PROCESS_GIGABYTES]; + int largeNumberColor = coloring ? CRT_colors[LARGE_NUMBER] : CRT_colors[PROCESS]; + int processMegabytesColor = coloring ? CRT_colors[PROCESS_MEGABYTES] : CRT_colors[PROCESS]; + int processGigabytesColor = coloring ? CRT_colors[PROCESS_GIGABYTES] : CRT_colors[PROCESS]; + int shadowColor = coloring ? CRT_colors[PROCESS_SHADOW] : CRT_colors[PROCESS]; int processColor = CRT_colors[PROCESS]; - if (!coloring) { - largeNumberColor = CRT_colors[PROCESS]; - processMegabytesColor = CRT_colors[PROCESS]; - processGigabytesColor = CRT_colors[PROCESS]; - } - if (number < 1000) { + if (number == ULLONG_MAX) { + //Invalid number + RichString_appendAscii(str, shadowColor, " N/A "); + } else if (number < 1000) { //Plain number, no markings len = xSnprintf(buffer, sizeof(buffer), "%5llu ", number); RichString_appendnAscii(str, processColor, buffer, len); |