swap_perc: check for division by zero
Aaron Marcher me@drkhsh.at
Sun, 20 May 2018 23:53:26 +0200
1 files changed,
4 insertions(+),
0 deletions(-)
jump to
M
components/swap.c
→
components/swap.c
@@ -76,6 +76,10 @@ return NULL;
} sscanf(match, "SwapFree: %ld kB\n", &free); + if (total == 0) { + return NULL; + } + return bprintf("%d%%", 100 * (total - free - cached) / total); }