From c4564879173f285d6145f93afb87c765bc36c57b Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Sun, 25 Dec 2022 17:07:09 +0400 Subject: [PATCH] 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. --- src/task-manager-bsd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/task-manager-bsd.c b/src/task-manager-bsd.c index b3b3590..afbed2d 100644 --- a/src/task-manager-bsd.c +++ b/src/task-manager-bsd.c @@ -254,8 +254,9 @@ get_memory_usage (guint64 *memory_total, guint64 *memory_available, guint64 *mem *memory_available = *memory_free + *memory_cache + *memory_buffers; /* get swap stats */ + *swap_total = *swap_free = 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) 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 */ - *swap_total = *swap_free = 0; for (i = 0; i < nswap; i++) { if (swdev[i].se_flags & SWF_ENABLE) { *swap_free += (swdev[i].se_nblks - swdev[i].se_inuse);