Date: Thu, 20 May 2004 20:57:12 +0100 From: "Liam J. Foy" <liamfoy@sepulcrum.org> To: freebsd-acpi@freebsd.org Subject: apm code Message-ID: <20040520205712.57abc39b.liamfoy@sepulcrum.org>
next in thread | raw e-mail | index | archive | help
Hey, Just writing to the list to make sure am correct here. The issue concerns /usr/src/usr.sbin/apm/apm.c. --- /usr/src/usr.sbin/apm/apm.c Thu May 20 20:30:57 2004 +++ /hd2/apm.c Thu May 20 20:44:36 2004 @@ -174,7 +174,7 @@ printf("Remaining battery life: "); if (aip->ai_batt_life == 255) printf("unknown\n"); - else if (aip->ai_batt_life <= 100) + else if (aip->ai_batt_life >= 0 && aip->ai_batt_life <= 100) printf("%d%%\n", aip->ai_batt_life); else printf("invalid value (0x%x)\n", aip->ai_batt_life); The above patch will make apm print invalid value when ai_batt_life does not equal 0-100. The reason for this was the the current code was printing -1 as a so called valid value(normally when acline is connected). I dont think printing -1 is correct, and really it should be printing invalid value since that is what it is. Do you guys agree with me or does -1 symbolise something? Something else I am curious over is this snippet of code: if (aip->ai_infoversion >= 1) { printf("Number of batteries: "); if (aip->ai_batteries == (u_int) -1) printf("unknown\n"); else { ai_batteries in machine/apm_bios.h is defined as u_int. Yet the above code is testing for -1. I _think_ this should be testing for 255(unknown). Anyone shead any light on this? I ask since I do not know apm very well. Would you guys agree my patch is correct also? Thanks in advance, Liam Foy
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040520205712.57abc39b.liamfoy>