[hackers] [slstatus][PATCH] ram.c, cpu.c: FreeBSD reporting fixes

From: K. Eugene Carlson <kvngncrlsn_AT_gmail.com>
Date: Mon, 16 May 2022 19:25:49 +0900

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
_AT_@ -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
_AT_@ -178,7 +178,7 @@
 
 	const char *
 	ram_total(void) {
-		long npages;
+		int npages;
 		size_t len;
 
 		len = sizeof(npages);
_AT_@ -191,8 +191,8 @@
 
 	const char *
 	ram_perc(void) {
-		long npages;
-		long active;
+		int npages;
+		int active;
 		size_t len;
 
 		len = sizeof(npages);
_AT_@ -209,7 +209,7 @@
 
 	const char *
 	ram_used(void) {
-		long active;
+		int active;
 		size_t len;
 
 		len = sizeof(active);
-- 
2.35.3
Received on Mon May 16 2022 - 12:25:49 CEST

This archive was generated by hypermail 2.3.0 : Mon May 16 2022 - 13:00:30 CEST