[patch] Move negative checks to util.c, from acpi.c (resend)

Danny Kukawka danny.kukawka at web.de
Thu Aug 18 04:12:49 PDT 2005


Hi,

On Thursday 18 August 2005 09:16, Richard Hughes wrote:
> Okay, from a user program PoV, maybe the error conditions should be
> reported as 100% (else like David says, programs might mis-interpret
> this as a low power condition) - or what about using 101%? that's enough
> for a user to notice, and bugzilla, but wouldn't trigger a low power
> shutdown.

If you report a error with a value from a defined range of correct values 
(0-100 for percentage)  you'll be always in trouble (for 100% : HAL 
reports 100% also if the battery is emtpy and your machine *die* without any 
notification).

Again: I don't understood: What the difference for you to handle 101% as error 
or -1 ? "-1" Is a well defined return value at all (kernel, userspace 
programmes with return values >= 0).

> If we include such a -1 error value then each program has to handle the
> fallback, when it should be relying on hal for the properly sanitised
> data.

See above, you must handle 101% also as you should handle -1%. If you wouldn't 
handle the error you can ignore -1% as returnvalue and set 100% within our 
programm as if you would do it for 101%. But if I would like to do something 
in my programm I know if I get -1 for percentage or remainig time: "There is 
a error" and can react.

> Maybe we should use a key such as linux.acpi.problems where we could put
> "no charge_level" as a indicator that something was wrong. Maybe a crazy
> idea.

If we get a correct and distinct errorcode we don't need this.

Cheers,

Danny


More information about the hal mailing list