For FreeBSD:
ram.c: Using "int" instead of "long" prevents crazy values.
cpu.c: Report the actual frequency of CPU0 rather than the base CPU
frequency.
---
components/cpu.c | 4 ++--
components/ram.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/components/cpu.c b/components/cpu.c
index 9e28003..910e99a 100644
--- a/components/cpu.c
+++ b/components/cpu.c
@@ -121,9 +121,9 @@
size = sizeof(freq);
/* in MHz */
- if (sysctlbyname("hw.clockrate", &freq, &size, NULL, 0) == -1
+ if (sysctlbyname("dev.cpu.0.freq", &freq, &size, NULL, 0) == -1
|| !size) {
- warn("sysctlbyname 'hw.clockrate':");
+ warn("sysctlbyname 'dev.cpu.0.freq':");
return NULL;
}
diff --git a/components/ram.c b/components/ram.c
index 47e6fda..6663cb6 100644
--- a/components/ram.c
+++ b/components/ram.c
@@ -178,7 +178,7 @@
const char *
ram_total(void) {
- long npages;
+ int npages;
size_t len;
len = sizeof(npages);
@@ -191,8 +191,8 @@
const char *
ram_perc(void) {
- long npages;
- long active;
+ int npages;
+ int active;
size_t len;
len = sizeof(npages);
@@ -209,7 +209,7 @@
const char *
ram_used(void) {
- long active;
+ int active;
size_t len;
len = sizeof(active);
--
2.35.3