summaryrefslogtreecommitdiff
path: root/components/ram.c
diff options
context:
space:
mode:
authordrkhsh <me@drkhsh.at>2022-10-28 00:21:02 +0200
committerdrkhsh <me@drkhsh.at>2022-10-28 01:03:46 +0200
commitcce2e5ecb05cdf68831fbf44c5ab90f4e16364b3 (patch)
tree7caa1faa12adf6f32dfaf10a61cc69985b9bcb79 /components/ram.c
parent3251e911878b78b0aad8fc09c782f8d81c878f75 (diff)
downloadslstatus-cce2e5ecb05cdf68831fbf44c5ab90f4e16364b3.tar.gz
radical re-formatting 3/3: Error checks
Check for `< 0` instead of `== -1`. Fixes coding style. Formatting commits suck, incoherent coding style sucks more. https://suckless.org/coding_style/
Diffstat (limited to 'components/ram.c')
-rw-r--r--components/ram.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/components/ram.c b/components/ram.c
index 326153f..15c4b74 100644
--- a/components/ram.c
+++ b/components/ram.c
@@ -159,8 +159,8 @@
size_t len;
len = sizeof(struct vmtotal);
- if (sysctl(mib, 2, &vm_stats, &len, NULL, 0) == -1
- || !len)
+ if (sysctl(mib, 2, &vm_stats, &len, NULL, 0) < 0
+ || !len)
return NULL;
return fmt_human(vm_stats.t_free * getpagesize(), 1024);
@@ -172,8 +172,8 @@
size_t len;
len = sizeof(npages);
- if (sysctlbyname("vm.stats.vm.v_page_count", &npages, &len, NULL, 0) == -1
- || !len)
+ if (sysctlbyname("vm.stats.vm.v_page_count",
+ &npages, &len, NULL, 0) < 0 || !len)
return NULL;
return fmt_human(npages * getpagesize(), 1024);
@@ -186,12 +186,12 @@
size_t len;
len = sizeof(npages);
- if (sysctlbyname("vm.stats.vm.v_page_count", &npages, &len, NULL, 0) == -1
- || !len)
+ if (sysctlbyname("vm.stats.vm.v_page_count",
+ &npages, &len, NULL, 0) < 0 || !len)
return NULL;
- if (sysctlbyname("vm.stats.vm.v_active_count", &active, &len, NULL, 0) == -1
- || !len)
+ if (sysctlbyname("vm.stats.vm.v_active_count",
+ &active, &len, NULL, 0) < 0 || !len)
return NULL;
return bprintf("%d", active * 100 / npages);
@@ -203,8 +203,8 @@
size_t len;
len = sizeof(active);
- if (sysctlbyname("vm.stats.vm.v_active_count", &active, &len, NULL, 0) == -1
- || !len)
+ if (sysctlbyname("vm.stats.vm.v_active_count",
+ &active, &len, NULL, 0) < 0 || !len)
return NULL;
return fmt_human(active * getpagesize(), 1024);