[Midnightbsd-cvs] src [7170] trunk/usr.sbin/powerd/powerd.c: Improve the error message when powerd fails

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Jul 26 15:25:24 EDT 2015


Revision: 7170
          http://svnweb.midnightbsd.org/src/?rev=7170
Author:   laffer1
Date:     2015-07-26 15:25:24 -0400 (Sun, 26 Jul 2015)
Log Message:
-----------
Improve the error message when powerd fails

Modified Paths:
--------------
    trunk/usr.sbin/powerd/powerd.c

Modified: trunk/usr.sbin/powerd/powerd.c
===================================================================
--- trunk/usr.sbin/powerd/powerd.c	2015-07-26 19:19:42 UTC (rev 7169)
+++ trunk/usr.sbin/powerd/powerd.c	2015-07-26 19:25:24 UTC (rev 7170)
@@ -45,6 +45,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sysexits.h>
 #include <unistd.h>
 
 #ifdef __i386__
@@ -72,7 +73,7 @@
 	SRC_UNKNOWN,
 } power_src_t;
 
-const char *modes[] = {
+static const char *modes[] = {
 	"AC",
 	"battery",
 	"unknown"
@@ -127,6 +128,12 @@
 #define DEVD_RETRY_INTERVAL 60 /* seconds */
 static struct timeval tried_devd;
 
+/*
+ * This function returns summary load of all CPUs.  It was made so
+ * intentionally to not reduce performance in scenarios when several
+ * threads are processing requests as a pipeline -- running one at
+ * a time on different CPUs and waiting for each other.
+ */
 static int
 read_usage_times(int *load)
 {
@@ -532,7 +539,7 @@
 		err(1, "lookup kern.cp_times");
 	len = 4;
 	if (sysctlnametomib("dev.cpu.0.freq", freq_mib, &len))
-		err(1, "lookup freq");
+		err(EX_UNAVAILABLE, "no cpufreq(4) support -- aborting");
 	len = 4;
 	if (sysctlnametomib("dev.cpu.0.freq_levels", levels_mib, &len))
 		err(1, "lookup freq_levels");



More information about the Midnightbsd-cvs mailing list