X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/c12b9cc50b5f476cd7b1de1dbd49e6282b1a042f..cf2b604507a71c61e757d7bf85458c7300eb3cf5:/components/ram.c diff --git a/components/ram.c b/components/ram.c index 7c0870c..0ac9753 100644 --- a/components/ram.c +++ b/components/ram.c @@ -17,7 +17,7 @@ return NULL; } - return fmt_human_2(free * 1024, "B"); + return fmt_human(free * 1024, 1024); } const char * @@ -34,8 +34,8 @@ return NULL; } - return bprintf("%d%%", 100 * ((total - free) - - (buffers + cached)) / total); + return bprintf("%d", 100 * ((total - free) - + (buffers + cached)) / total); } const char * @@ -48,7 +48,7 @@ return NULL; } - return fmt_human_2(total * 1024, "B"); + return fmt_human(total * 1024, 1024); } const char * @@ -65,8 +65,8 @@ return NULL; } - return fmt_human_2((total - free - buffers - cached) * 1024, - "B"); + return fmt_human((total - free - buffers - cached) * 1024, + 1024); } #elif defined(__OpenBSD__) #include @@ -85,7 +85,11 @@ size = sizeof(*uvmexp); - return sysctl(uvmexp_mib, 2, uvmexp, &size, NULL, 0) >= 0 ? 1 : 0; + if (sysctl(uvmexp_mib, 2, uvmexp, &size, NULL, 0) >= 0) { + return 1; + } + + return 0; } const char * @@ -96,7 +100,8 @@ if (load_uvmexp(&uvmexp)) { free_pages = uvmexp.npages - uvmexp.active; - return fmt_human_2(pagetok(free_pages, uvmexp.pageshift) * 1024, "B"); + return fmt_human(pagetok(free_pages, uvmexp.pageshift) * + 1024, 1024); } return NULL; @@ -110,7 +115,7 @@ if (load_uvmexp(&uvmexp)) { percent = uvmexp.active * 100 / uvmexp.npages; - return bprintf("%d%%", percent); + return bprintf("%d", percent); } return NULL; @@ -122,7 +127,9 @@ struct uvmexp uvmexp; if (load_uvmexp(&uvmexp)) { - return fmt_human_2(pagetok(uvmexp.npages, uvmexp.pageshift) * 1024, "B"); + return fmt_human(pagetok(uvmexp.npages, + uvmexp.pageshift) * 1024, + 1024); } return NULL; @@ -134,7 +141,9 @@ struct uvmexp uvmexp; if (load_uvmexp(&uvmexp)) { - return fmt_human_2(pagetok(uvmexp.active, uvmexp.pageshift) * 1024, "B"); + return fmt_human(pagetok(uvmexp.active, + uvmexp.pageshift) * 1024, + 1024); } return NULL;