all repos — slstatus @ c1f79d741a160ea17a110ca09b3deb705636ec4a

my build of slstatus (tools.suckless.org/slstatus/)

corrected calculation for swap on openbsd

The swapctl(2) function fills the swapent struct with 512KB blocks.
As we want to display in GB, i just modified the calculation for this to
get the expected output.
Tobias Tschinkowitz he4d@posteo.de
Wed, 16 May 2018 13:26:34 +0200
commit

c1f79d741a160ea17a110ca09b3deb705636ec4a

parent

82eb6e3832dea63be4c22ac4415c3190add43f0b

1 files changed, 5 insertions(+), 7 deletions(-)

jump to
M components/swap.ccomponents/swap.c

@@ -131,8 +131,6 @@ #include <sys/swap.h>

#include <sys/types.h> #include <unistd.h> - #define dbtoqb(b) dbtob((int64_t)(b)) - static void getstats(int *total, int *used) {

@@ -162,8 +160,8 @@ *total = 0;

*used = 0; for (i = 0; i < rnswap; i++) { - *total += dbtoqb(sep->se_nblks); - *used += dbtoqb(sep->se_inuse); + *total += sep->se_nblks >> 1; + *used += sep->se_inuse >> 1; } free(fsep);

@@ -176,7 +174,7 @@ int total, used;

getstats(&total, &used); - return bprintf("%f", (float)(total - used) / 1024 / 1024 / 1024); + return bprintf("%f", (float)(total - used) / 1024 / 1024); } const char *

@@ -196,7 +194,7 @@ int total, used;

getstats(&total, &used); - return bprintf("%f", (float)total / 1024 / 1024 / 1024); + return bprintf("%f", (float)total / 1024 / 1024); } const char *

@@ -206,6 +204,6 @@ int total, used;

getstats(&total, &used); - return bprintf("%f", (float)used / 1024 / 1024 / 1024); + return bprintf("%f", (float)used / 1024 / 1024); } #endif