commit 826a5dc86202624b00ad2a51d781758a7f7ca1fa
Author:     drkhsh <[email protected]>
AuthorDate: Fri Oct 28 00:13:12 2022 +0200
Commit:     drkhsh <[email protected]>
CommitDate: Fri Oct 28 01:03:20 2022 +0200

    ram: Refactor on OpenBSD
    
    Fixes up overly complicated lines, by splitting up logic

diff --git a/components/ram.c b/components/ram.c
index 9a69db8..0cec4b9 100644
--- a/components/ram.c
+++ b/components/ram.c
@@ -107,13 +107,12 @@
                struct uvmexp uvmexp;
                int free_pages;
 
-               if (load_uvmexp(&uvmexp)) {
-                       free_pages = uvmexp.npages - uvmexp.active;
-                       return fmt_human(pagetok(free_pages, uvmexp.pageshift) *
-                                        1024, 1024);
-               }
+               if (!load_uvmexp(&uvmexp))
+                       return NULL;
 
-               return NULL;
+               free_pages = uvmexp.npages - uvmexp.active;
+               return fmt_human(pagetok(free_pages, uvmexp.pageshift) *
+                                1024, 1024);
        }
 
        const char *
@@ -122,12 +121,11 @@
                struct uvmexp uvmexp;
                int percent;
 
-               if (load_uvmexp(&uvmexp)) {
-                       percent = uvmexp.active * 100 / uvmexp.npages;
-                       return bprintf("%d", percent);
-               }
+               if (!load_uvmexp(&uvmexp))
+                       return NULL;
 
-               return NULL;
+               percent = uvmexp.active * 100 / uvmexp.npages;
+               return bprintf("%d", percent);
        }
 
        const char *
@@ -135,13 +133,11 @@
        {
                struct uvmexp uvmexp;
 
-               if (load_uvmexp(&uvmexp)) {
-                       return fmt_human(pagetok(uvmexp.npages,
-                                                uvmexp.pageshift) * 1024,
-                                        1024);
-               }
+               if (!load_uvmexp(&uvmexp))
+                       return NULL;
 
-               return NULL;
+               return fmt_human(pagetok(uvmexp.npages,
+                                        uvmexp.pageshift) * 1024, 1024);
        }
 
        const char *
@@ -149,13 +145,11 @@
        {
                struct uvmexp uvmexp;
 
-               if (load_uvmexp(&uvmexp)) {
-                       return fmt_human(pagetok(uvmexp.active,
-                                                uvmexp.pageshift) * 1024,
-                                        1024);
-               }
+               if (!load_uvmexp(&uvmexp))
+                       return NULL;
 
-               return NULL;
+               return fmt_human(pagetok(uvmexp.active,
+                                        uvmexp.pageshift) * 1024, 1024);
        }
 #elif defined(__FreeBSD__)
        #include <sys/sysctl.h>

Reply via email to