slstatus

status monitor
git clone git://git.suckless.org/slstatus
Log | Files | Refs | README | LICENSE

commit 806815778fe75f13b569a1b5fe6d6d74a50c89ff
parent d8ce4e694217bc69e95372f705d023e71dd70115
Author: Aaron Marcher <me@drkhsh.at>
Date:   Sun, 20 May 2018 23:53:26 +0200

swap_perc: check for division by zero

Diffstat:
components/swap.c | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/components/swap.c b/components/swap.c @@ -76,6 +76,10 @@ } sscanf(match, "SwapFree: %ld kB\n", &free); + if (total == 0) { + return NULL; + } + return bprintf("%d%%", 100 * (total - free - cached) / total); }