Do not treat missing swap as error on OpenBSD and NetBSD
https://man.openbsd.org/swapctl.2 `SWAP_NSWAP` is always successful. Do not treat a count of zero as error such that the task manager becomes usable on systems without any swap configured. Fix #67.
This commit is contained in:
@@ -254,8 +254,9 @@ get_memory_usage (guint64 *memory_total, guint64 *memory_available, guint64 *mem
|
|||||||
*memory_available = *memory_free + *memory_cache + *memory_buffers;
|
*memory_available = *memory_free + *memory_cache + *memory_buffers;
|
||||||
|
|
||||||
/* get swap stats */
|
/* get swap stats */
|
||||||
|
*swap_total = *swap_free = 0;
|
||||||
if ((nswap = swapctl(SWAP_NSWAP, 0, 0)) == 0)
|
if ((nswap = swapctl(SWAP_NSWAP, 0, 0)) == 0)
|
||||||
errx(1,"failed to get swap device count");
|
return TRUE;
|
||||||
|
|
||||||
if ((swdev = calloc(nswap, sizeof(*swdev))) == NULL)
|
if ((swdev = calloc(nswap, sizeof(*swdev))) == NULL)
|
||||||
errx(1,"failed to allocate memory for swdev structures");
|
errx(1,"failed to allocate memory for swdev structures");
|
||||||
@@ -266,7 +267,6 @@ get_memory_usage (guint64 *memory_total, guint64 *memory_available, guint64 *mem
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Total things up */
|
/* Total things up */
|
||||||
*swap_total = *swap_free = 0;
|
|
||||||
for (i = 0; i < nswap; i++) {
|
for (i = 0; i < nswap; i++) {
|
||||||
if (swdev[i].se_flags & SWF_ENABLE) {
|
if (swdev[i].se_flags & SWF_ENABLE) {
|
||||||
*swap_free += (swdev[i].se_nblks - swdev[i].se_inuse);
|
*swap_free += (swdev[i].se_nblks - swdev[i].se_inuse);
|
||||||
|
|||||||
Reference in New Issue
Block a user