summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorcjc <cjc@FreeBSD.org>2001-11-30 11:35:01 +0000
committercjc <cjc@FreeBSD.org>2001-11-30 11:35:01 +0000
commit5b52488acfbb4cd191092022ca62cfe82e570de7 (patch)
tree205b53f3af6f3e0eaa6b79462b12a435c3f6fe5d /usr.sbin
parentcfe5212a8b36139b260e85fe117efef6bbbc5a4b (diff)
downloadFreeBSD-src-5b52488acfbb4cd191092022ca62cfe82e570de7.zip
FreeBSD-src-5b52488acfbb4cd191092022ca62cfe82e570de7.tar.gz
Make the error messaging more helpful.
PR: 31483 Approved by: iwasaki, ru MFC after: 4 days
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/acpi/acpiconf/acpiconf.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/usr.sbin/acpi/acpiconf/acpiconf.c b/usr.sbin/acpi/acpiconf/acpiconf.c
index f30b406..a5cec5f 100644
--- a/usr.sbin/acpi/acpiconf/acpiconf.c
+++ b/usr.sbin/acpi/acpiconf/acpiconf.c
@@ -33,6 +33,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
+#include <sysexits.h>
#include <unistd.h>
#include <dev/acpica/acpiio.h>
@@ -49,10 +50,13 @@ acpi_enable_disable(int enable)
fd = open(ACPIDEV, O_RDWR);
if (fd == -1) {
- err(1, NULL);
+ err(EX_OSFILE, ACPIDEV);
}
if (ioctl(fd, enable, NULL) == -1) {
- err(1, NULL);
+ if (enable == ACPIIO_ENABLE)
+ err(EX_IOERR, "enable failed");
+ else
+ err(EX_IOERR, "disable failed");
}
close(fd);
@@ -66,10 +70,10 @@ acpi_sleep(int sleep_type)
fd = open(ACPIDEV, O_RDWR);
if (fd == -1) {
- err(1, NULL);
+ err(EX_OSFILE, ACPIDEV);
}
if (ioctl(fd, ACPIIO_SETSLPSTATE, &sleep_type) == -1) {
- err(1, NULL);
+ err(EX_IOERR, "sleep type (%d) failed", sleep_type);
}
close(fd);
@@ -107,11 +111,9 @@ main(int argc, char *argv[])
case 's':
sleep_type = optarg[0] - '0';
- if (sleep_type < 0 || sleep_type > 5) {
- fprintf(stderr, "%s: invalid sleep type (%d)\n",
- argv[0], sleep_type);
- return -1;
- }
+ if (sleep_type < 0 || sleep_type > 5)
+ errx(EX_USAGE, "invalid sleep type (%d)",
+ sleep_type);
break;
default:
argc -= optind;
OpenPOWER on IntegriCloud