Subject: bin/34593: apm(8) prints meaningless default unknow value for minutes_left
To: None <,>
From: None <>
List: netbsd-bugs
Date: 09/23/2006 21:40:01
>Number:         34593
>Category:       bin
>Synopsis:       apm(8) prints meaningless default unknow value for minutes_left
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 23 21:40:00 +0000 2006
>Originator:     Arnaud LACOMBE
>Release:        -current
NetBSD ouikka 4.99.2 NetBSD 4.99.2 (GENERIC_LAPTOP) #2: Fri Sep 22 13:22:29 EDT 2006  foo@ouikka:/netbsd/obj/sys/arch/i386/compile/GENERIC_LAPTOP i386
In the output of apm(8) when battery information are printed, if the APM/ACPI driver (src/sys/dev/acpi/acpi_apm.c) is unable to get the value of `minutes_left', the value returned to userland will be the default unknown value (0xffff) which will be printed on the screen.

I dream of having 45 days of battery on my laptop, but I guess the technology is not yet available :( , and thus, printing this is meaningless (and also wrong).
run apm(8)
Index: apm.c
RCS file: /netbsd/cvsroot/src/usr.sbin/apm/apm.c,v
retrieving revision 1.16
diff -b -u -r1.16 apm.c
--- apm.c	23 Jan 2005 20:55:57 -0000	1.16
+++ apm.c	22 Sep 2006 17:38:29 -0000
@@ -279,6 +279,9 @@
 		switch (action) {
 		case GETSTATUS:
+			/* default unknown value for minutes_left, from sys/dev/acpi/acpi_apm.c */
+			if(api->minutes_left == 0xffff) 
+				domin = FALSE;
 			if (verbose) {
 				if (dobstate)
 					printf("Battery charge state: %s\n",