summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2005-03-29 16:25:20 +0000
committermiod <miod@openbsd.org>2005-03-29 16:25:20 +0000
commite4613c9e670f3d408da3555d26d12129ed474094 (patch)
tree4e3463f32c77d12dc57ca54ceeea6d9165b60b9f
parentfix memleak (diff)
downloadwireguard-openbsd-e4613c9e670f3d408da3555d26d12129ed474094.tar.xz
wireguard-openbsd-e4613c9e670f3d408da3555d26d12129ed474094.zip
Allow an apm implementation to return -1 in the minutes_left field of the
apm_power_info struct, if it has no reasonable value to provide. ok deraadt@ mickey@
-rw-r--r--usr.sbin/apm/apm.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index 49ab37ba77b..ec0a8bd5d71 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.9 2003/07/30 21:44:32 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.10 2005/03/29 16:25:20 miod Exp $ */
/*
* Copyright (c) 1996 John T. Kohl
@@ -244,9 +244,14 @@ main(int argc, char *argv[])
if (dopct)
printf("%d\n",
reply.batterystate.battery_life);
- if (domin)
- printf("%d\n",
- reply.batterystate.minutes_left);
+ if (domin) {
+ if (reply.batterystate.minutes_left ==
+ (u_int)-1)
+ printf("unknown\n");
+ else
+ printf("%d\n",
+ reply.batterystate.minutes_left);
+ }
if (doac)
printf("%d\n",
reply.batterystate.ac_state);
@@ -273,8 +278,15 @@ main(int argc, char *argv[])
"not available\n");
else
#endif
- printf("Battery life estimate: %d minutes\n",
- reply.batterystate.minutes_left);
+ {
+ printf("Battery life estimate: ");
+ if (reply.batterystate.minutes_left ==
+ (u_int)-1)
+ printf("unknown\n");
+ else
+ printf("%d minutes\n",
+ reply.batterystate.minutes_left);
+ }
}
if (doac)
printf("A/C adapter state: %s\n",