From: Aaron Marcher Date: Sun, 20 May 2018 21:53:26 +0000 (+0200) Subject: swap_perc: check for division by zero X-Git-Url: https://git.atheridis.org/?a=commitdiff_plain;h=806815778fe75f13b569a1b5fe6d6d74a50c89ff;p=suckless%2Fslstatus.git swap_perc: check for division by zero --- diff --git a/components/swap.c b/components/swap.c index c005691..465ffd4 100644 --- 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); }