Xinqi Bao's Git

corrected calculation for swap on openbsd
[slstatus.git] / components / swap.c
index 031b713..caa4788 100644 (file)
        #include <sys/types.h>
        #include <unistd.h>
 
-       #define dbtoqb(b) dbtob((int64_t)(b))
-
        static void
        getstats(int *total, int *used)
        {
                *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);
 
                getstats(&total, &used);
 
-               return bprintf("%f", (float)(total - used) / 1024 / 1024 / 1024);
+               return bprintf("%f", (float)(total - used) / 1024 / 1024);
        }
 
        const char *
 
                getstats(&total, &used);
 
-               return bprintf("%f", (float)total / 1024 / 1024 / 1024);
+               return bprintf("%f", (float)total / 1024 / 1024);
        }
 
        const char *
 
                getstats(&total, &used);
 
-               return bprintf("%f", (float)used / 1024 / 1024 / 1024);
+               return bprintf("%f", (float)used / 1024 / 1024);
        }
 #endif