Date: Thu, 20 May 2004 15:03:56 -0700 From: "Grover, Andrew" <andrew.grover@intel.com> To: "Liam J. Foy" <liamfoy@sepulcrum.org>, <freebsd-acpi@freebsd.org> Subject: RE: apm code Message-ID: <F760B14C9561B941B89469F59BA3A8470637E27C@orsmsx401.amr.corp.intel.com>
next in thread | raw e-mail | index | archive | help
> Just writing to the list to make sure am correct here. The=20 > issue concerns /usr/src/usr.sbin/apm/apm.c.=20 >=20 > --- /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 =3D=3D 255) > printf("unknown\n"); > - else if (aip->ai_batt_life <=3D 100) > + else if (aip->ai_batt_life >=3D 0 && aip->ai_batt_life <=3D 100) > printf("%d%%\n", aip->ai_batt_life); > else > printf("invalid value (0x%x)\n", aip->ai_batt_life); >=20 > The above patch will make apm print invalid value when=20 > ai_batt_life does not equal 0-100. The reason for this was=20 > the the current code was printing -1 as a so called valid=20 > value(normally when acline is connected). I dont think=20 > printing -1 is correct, and really it should be printing=20 > invalid value since that is what it is. Do you guys agree=20 > with me or does -1 symbolise something? if (aip->ai_batt_life =3D=3D 255) printf("unknown\n"); The above line should catch the -1 case. There's a uint/uchar sign extension problem. Changing the 255 to -1 will probably fix things. Regards -- Andy
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F760B14C9561B941B89469F59BA3A8470637E27C>