[hackers] [slstatus] swap_perc: check for division by zero || Aaron Marcher

From: <git_AT_suckless.org>
Date: Sun, 20 May 2018 23:53:47 +0200 (CEST)

commit 806815778fe75f13b569a1b5fe6d6d74a50c89ff
Author: Aaron Marcher <me_AT_drkhsh.at>
AuthorDate: Sun May 20 23:53:26 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Sun May 20 23:53:26 2018 +0200

    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
_AT_@ -76,6 +76,10 @@
                 }
                 sscanf(match, "SwapFree: %ld kB\n", &free);
 
+ if (total == 0) {
+ return NULL;
+ }
+
                 return bprintf("%d%%", 100 * (total - free - cached) / total);
         }
 
Received on Sun May 20 2018 - 23:53:47 CEST

This archive was generated by hypermail 2.3.0 : Mon May 21 2018 - 00:00:28 CEST