Xinqi Bao's Git

swap_perc: check for division by zero on obsd too
authorAaron Marcher <[email protected]>
Sun, 20 May 2018 22:02:33 +0000 (00:02 +0200)
committerAaron Marcher <[email protected]>
Sun, 20 May 2018 22:02:33 +0000 (00:02 +0200)
components/swap.c

index 465ffd4..f5db667 100644 (file)
 
                getstats(&total, &used);
 
 
                getstats(&total, &used);
 
+               if (total == 0) {
+                       return NULL;
+               }
+
                return bprintf("%d%%", 100 * used / total);
        }
 
                return bprintf("%d%%", 100 * used / total);
        }