From 7cd84658111b2c92d7684a13c4883d581fd513c3 Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Wed, 4 Jan 2012 12:52:25 +0100 Subject: [PATCH] openbsd: handle case where minutes_left might be negative might not be useful since apm_fd is accessed through the singleton.. Signed-off-by: Richard Hughes --- src/openbsd/up-backend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openbsd/up-backend.c b/src/openbsd/up-backend.c index 4ff9c58..528f636 100644 --- a/src/openbsd/up-backend.c +++ b/src/openbsd/up-backend.c @@ -322,8 +322,8 @@ up_backend_update_battery_state(UpDevice* device) if (a.ac_state == APM_AC_ON) new_state = UP_DEVICE_STATE_CHARGING; - // zero out new_time_to empty if we're not discharging - new_time_to_empty = (new_state == UP_DEVICE_STATE_DISCHARGING ? a.minutes_left : 0); + // zero out new_time_to empty if we're not discharging or minutes_left is negative + new_time_to_empty = (new_state == UP_DEVICE_STATE_DISCHARGING && a.minutes_left > 0 ? a.minutes_left : 0); if (cur_state != new_state || percentage != (gdouble) a.battery_life ||