swap_perc: check for division by zero
This commit is contained in:
parent
d8ce4e6942
commit
806815778f
@ -76,6 +76,10 @@
|
|||||||
}
|
}
|
||||||
sscanf(match, "SwapFree: %ld kB\n", &free);
|
sscanf(match, "SwapFree: %ld kB\n", &free);
|
||||||
|
|
||||||
|
if (total == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return bprintf("%d%%", 100 * (total - free - cached) / total);
|
return bprintf("%d%%", 100 * (total - free - cached) / total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user