Introduction
Introduction Statistics Contact Development Disclaimer Help
radical re-formatting 3/3: Error checks - slstatus - status monitor
git clone git://git.suckless.org/slstatus
Log
Files
Refs
README
LICENSE
---
commit cce2e5ecb05cdf68831fbf44c5ab90f4e16364b3
parent 3251e911878b78b0aad8fc09c782f8d81c878f75
Author: drkhsh <[email protected]>
Date: Fri, 28 Oct 2022 00:21:02 +0200
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:
M components/cpu.c | 6 ++----
M components/netspeeds.c | 4 ++--
M components/ram.c | 20 ++++++++++----------
M components/swap.c | 2 +-
4 files changed, 15 insertions(+), 17 deletions(-)
---
diff --git a/components/cpu.c b/components/cpu.c
@@ -118,8 +118,7 @@
size = sizeof(freq);
/* in MHz */
- if (sysctlbyname("hw.clockrate", &freq, &size, NULL, 0) == -1
- || !size) {
+ if (sysctlbyname("hw.clockrate", &freq, &size, NULL, 0) < 0 ||…
warn("sysctlbyname 'hw.clockrate':");
return NULL;
}
@@ -136,8 +135,7 @@
size = sizeof(a);
memcpy(b, a, sizeof(b));
- if (sysctlbyname("kern.cp_time", &a, &size, NULL, 0) == -1
- || !size) {
+ if (sysctlbyname("kern.cp_time", &a, &size, NULL, 0) < 0 || !s…
warn("sysctlbyname 'kern.cp_time':");
return NULL;
}
diff --git a/components/netspeeds.c b/components/netspeeds.c
@@ -71,7 +71,7 @@
oldrxbytes = rxbytes;
- if (getifaddrs(&ifal) == -1) {
+ if (getifaddrs(&ifal) < 0) {
warn("getifaddrs failed");
return NULL;
}
@@ -105,7 +105,7 @@
oldtxbytes = txbytes;
- if (getifaddrs(&ifal) == -1) {
+ if (getifaddrs(&ifal) < 0) {
warn("getifaddrs failed");
return NULL;
}
diff --git 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, NU…
- || !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, NU…
- || !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, …
- || !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, …
- || !len)
+ if (sysctlbyname("vm.stats.vm.v_active_count",
+ &active, &len, NULL, 0) < 0 || !len)
return NULL;
return fmt_human(active * getpagesize(), 1024);
diff --git a/components/swap.c b/components/swap.c
@@ -204,7 +204,7 @@
return 0;
}
- if(kvm_getswapinfo(kd, swap_info, size, 0 /* Unused flags */) …
+ if (kvm_getswapinfo(kd, swap_info, size, 0 /* Unused flags */)…
warn("kvm_getswapinfo:");
kvm_close(kd);
return 0;
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.