size = sizeof(freq);
/* in MHz */
- if (sysctlbyname("hw.clockrate", &freq, &size, NULL, 0) == -1
- || !size) {
+ if (sysctlbyname("hw.clockrate", &freq, &size, NULL, 0) < 0 || !size) {
warn("sysctlbyname 'hw.clockrate':");
return NULL;
}
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 || !size) {
warn("sysctlbyname 'kern.cp_time':");
return NULL;
}
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);
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);
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);
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);