From 06f42f13f230e03ae20179d0011629c522d7168e Mon Sep 17 00:00:00 2001 From: sdk Date: Sat, 10 Sep 2022 10:10:09 +0000 Subject: [PATCH] apm(1): Display unknown recharge time estimate instead of -1 OK miod@ --- usr.sbin/apm/apm.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c index 8c5662957c6..dd2b2578e0d 100644 --- a/usr.sbin/apm/apm.c +++ b/usr.sbin/apm/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.41 2022/02/13 21:27:51 jmc Exp $ */ +/* $OpenBSD: apm.c,v 1.42 2022/09/10 10:10:09 sdk Exp $ */ /* * Copyright (c) 1996 John T. Kohl @@ -376,8 +376,15 @@ balony: } else if (domin) { if (reply.batterystate.battery_state == APM_BATT_CHARGING) - printf(", %d minutes recharge time estimate\n", - reply.batterystate.minutes_left); + { + if (reply.batterystate.minutes_left == + (u_int)-1) + printf(", unknown"); + else + printf(", %d minutes", + reply.batterystate.minutes_left); + printf(" recharge time estimate\n"); + } else if (reply.batterystate.minutes_left == 0 && reply.batterystate.battery_life > 10) printf(", unknown life estimate\n"); -- 2.20.1