pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/hal hald-netbsd: clear is_charging/is_dischar...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/27c66e9f6e4e
branches:  trunk
changeset: 550719:27c66e9f6e4e
user:      jmcneill <jmcneill%pkgsrc.org@localhost>
date:      Thu Nov 27 12:24:02 2008 +0000

description:
hald-netbsd: clear is_charging/is_discharging before walking through the
sensor properties, and make sure we don't read an invalid sensor in
the process. Bump PKGREVISION.

diffstat:

 sysutils/hal/Makefile                   |   4 ++--
 sysutils/hal/files/hald-netbsd/envsys.c |  32 +++++++++++++-------------------
 2 files changed, 15 insertions(+), 21 deletions(-)

diffs (75 lines):

diff -r 735942e829c1 -r 27c66e9f6e4e sysutils/hal/Makefile
--- a/sysutils/hal/Makefile     Thu Nov 27 09:03:30 2008 +0000
+++ b/sysutils/hal/Makefile     Thu Nov 27 12:24:02 2008 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.10 2008/11/27 03:32:19 jmcneill Exp $
+# $NetBSD: Makefile,v 1.11 2008/11/27 12:24:02 jmcneill Exp $
 #
 
 DISTNAME=              hal-0.5.11
-PKGREVISION=           6
+PKGREVISION=           7
 CATEGORIES=            sysutils
 MASTER_SITES=          http://hal.freedesktop.org/releases/
 EXTRACT_SUFX=          .tar.bz2
diff -r 735942e829c1 -r 27c66e9f6e4e sysutils/hal/files/hald-netbsd/envsys.c
--- a/sysutils/hal/files/hald-netbsd/envsys.c   Thu Nov 27 09:03:30 2008 +0000
+++ b/sysutils/hal/files/hald-netbsd/envsys.c   Thu Nov 27 12:24:02 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: envsys.c,v 1.1 2008/11/27 01:45:00 jmcneill Exp $ */
+/* $NetBSD: envsys.c,v 1.2 2008/11/27 12:24:02 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -174,6 +174,8 @@
        device_property_atomic_update_begin ();
 
        hal_device_property_set_bool (d, "battery.is_rechargeable", TRUE);
+       hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE);
+       hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE);
 
        iter = prop_array_iterator (properties);
        while ((prop = (prop_dictionary_t)prop_object_iterator_next (iter)) != NULL) {
@@ -181,10 +183,10 @@
                const char *valid;
                int64_t intval;
 
-               if (prop_dictionary_get_cstring_nocopy (prop, "description", &descr) == false)
-                       continue;
-
-               if (prop_dictionary_get_int64 (prop, "cur-value", &intval) == false)
+               if (prop_dictionary_get_cstring_nocopy (prop, "description", &descr) == false ||
+                   prop_dictionary_get_int64 (prop, "cur-value", &intval) == false ||
+                   prop_dictionary_get_cstring_nocopy (prop, "state", &valid) == false ||
+                   strcmp (valid, "valid") != 0)
                        continue;
 
                if (strcmp (descr, "present") == 0)
@@ -204,21 +206,13 @@
                                hal_device_property_set_int (d, "battery.charge_level.percentage", 0);
                }
                else if (strcmp (descr, "charge rate") == 0) {
-                       if (prop_dictionary_get_cstring_nocopy (prop, "state", &valid) == false)
-                               continue;
-                       if (strcmp (valid, "valid") == 0) {
-                               hal_device_property_set_bool (d, "battery.rechargeable.is_charging", TRUE);
-                               hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE);
-                               hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600);
-                       }
+                       hal_device_property_set_bool (d, "battery.rechargeable.is_charging", TRUE);
+                       hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE);
+                       hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600);
                } else if (strcmp (descr, "discharge rate") == 0) {
-                       if (prop_dictionary_get_cstring_nocopy (prop, "state", &valid) == false)
-                               continue;
-                       if (strcmp (valid, "valid") == 0) {
-                               hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE);
-                               hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", TRUE);
-                               hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600);
-                       }
+                       hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE);
+                       hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", TRUE);
+                       hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600);
                }
        }
 



Home | Main Index | Thread Index | Old Index