projects
/
suckless
/
slstatus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d8ce4e6
)
swap_perc: check for division by zero
author
Aaron Marcher
<me@drkhsh.at>
Sun, 20 May 2018 21:53:26 +0000
(23:53 +0200)
committer
Aaron Marcher
<me@drkhsh.at>
Sun, 20 May 2018 21:53:26 +0000
(23:53 +0200)
components/swap.c
patch
|
blob
|
history
diff --git
a/components/swap.c
b/components/swap.c
index c005691a111e76fd116c2bb154b85976d39bda88..465ffd4fc1f412f117a68517cc28bed5b655faf4 100644
(file)
--- 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);
}