Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/apm - Bail out when failed to ioctl.



details:   https://anonhg.NetBSD.org/src/rev/bfd032abb364
branches:  trunk
changeset: 514891:bfd032abb364
user:      enami <enami%NetBSD.org@localhost>
date:      Thu Sep 13 11:05:58 2001 +0000

description:
- Bail out when failed to ioctl.
- Clear args to APM_IOC_GETPOWER.

diffstat:

 usr.sbin/apm/apm.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (34 lines):

diff -r 81beede622af -r bfd032abb364 usr.sbin/apm/apm.c
--- a/usr.sbin/apm/apm.c        Thu Sep 13 11:05:02 2001 +0000
+++ b/usr.sbin/apm/apm.c        Thu Sep 13 11:05:58 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apm.c,v 1.11 2001/09/13 11:01:49 enami Exp $ */
+/*     $NetBSD: apm.c,v 1.12 2001/09/13 11:05:58 enami Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -232,7 +232,7 @@
        case NONE:
                verbose = doac = dopct = domin = dobstate = dostatus = TRUE;
                action = GETSTATUS;
-               /* fallthrough */
+               /* FALLTHROUGH */
        case GETSTATUS:
                if (fd == -1) {
                        /* open the device directly and get status */
@@ -242,10 +242,13 @@
                                    "cannot open "
                                    _PATH_APM_NORMAL);
                        }
+                       memset(&reply, 0, sizeof(reply));
                        if (ioctl(fd, APM_IOC_GETPOWER,
-                           &reply.batterystate) == 0)
-                               goto printval;
+                           &reply.batterystate) == -1)
+                               err(1, "ioctl(APM_IOC_GETPOWER)");
+                       goto printval;
                }
+               /* FALLTHROUGH */
        case SUSPEND:
        case STANDBY:
                if (nodaemon && fd == -1) {



Home | Main Index | Thread Index | Old Index