mirror of
https://github.com/pikami/slstatus.git
synced 2026-10-21 02:34:25 +01:00
swap_perc: check for division by zero
This commit is contained in:
1 parent
d8ce4e6942
commit
806815778f
1 file changed
+4
@@ -76,6 +76,10 @@
|
||||
}
|
||||
sscanf(match, "SwapFree: %ld kB\n", &free);
|
||||
|
||||
if (total == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return bprintf("%d%%", 100 * (total - free - cached) / total);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user