[Pkg-wmaker-commits] [wmbattery] 100/241: * Don't spew error messages if optional hal properties are not available.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:37:40 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmbattery.
commit a651819f3eca01aa1dcdc8d0072fa250ddb448e0
Author: Joey Hess <joey at kodama.kitenet.net>
Date: Sat Feb 2 16:23:45 2008 -0500
* Don't spew error messages if optional hal properties are not available.
---
debian/changelog | 6 ++++++
simplehal.c | 26 ++++++++++++++------------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index e959e4c..1ca86ec 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+wmbattery (2.35) UNRELEASED; urgency=low
+
+ * Don't spew error messages if optional hal properties are not available.
+
+ -- Joey Hess <joeyh at debian.org> Sat, 02 Feb 2008 16:23:24 -0500
+
wmbattery (2.34) unstable; urgency=low
* Bit the bullet, stopped trying to track the kernel's ever changing
diff --git a/simplehal.c b/simplehal.c
index 1c53e31..632cea9 100644
--- a/simplehal.c
+++ b/simplehal.c
@@ -16,7 +16,7 @@ int num_batteries = 0;
char **ac_adapters = NULL;
char **batteries = NULL;
-signed int get_hal_int (const char *udi, const char *key) {
+signed int get_hal_int (const char *udi, const char *key, int optional) {
int ret;
DBusError error;
@@ -24,15 +24,16 @@ signed int get_hal_int (const char *udi, const char *key) {
ret = libhal_device_get_property_int (hal_ctx, udi, key, &error);
if (dbus_error_is_set (&error)) {
- fprintf(stderr, "error: libhal_device_get_property_int: %s: %s\n",
- error.name, error.message);
+ if (! optional)
+ fprintf(stderr, "error: libhal_device_get_property_int: %s: %s\n",
+ error.name, error.message);
dbus_error_free (&error);
return -1;
}
return ret;
}
-signed int get_hal_bool (const char *udi, const char *key) {
+signed int get_hal_bool (const char *udi, const char *key, int optional) {
int ret;
DBusError error;
@@ -40,8 +41,9 @@ signed int get_hal_bool (const char *udi, const char *key) {
ret = libhal_device_get_property_bool (hal_ctx, udi, key, &error);
if (dbus_error_is_set (&error)) {
- fprintf(stderr, "error: libhal_device_get_property_int: %s: %s\n",
- error.name, error.message);
+ if (! optional)
+ fprintf(stderr, "error: libhal_device_get_property_int: %s: %s\n",
+ error.name, error.message);
dbus_error_free (&error);
return -1;
}
@@ -126,7 +128,7 @@ int simplehal_read (int battery, apm_info *info) {
info->ac_line_status=0;
for (i = 0 ; i < num_ac_adapters && ! info->ac_line_status ; i++) {
- info->ac_line_status = (get_hal_bool(ac_adapters[i], "ac_adapter.present") == 1);
+ info->ac_line_status = (get_hal_bool(ac_adapters[i], "ac_adapter.present", 0) == 1);
}
if (battery > num_batteries) {
@@ -139,7 +141,7 @@ int simplehal_read (int battery, apm_info *info) {
device=batteries[battery-1];
}
- if (get_hal_bool(device, "battery.present") != 1) {
+ if (get_hal_bool(device, "battery.present", 0) != 1) {
info->battery_percentage = 0;
info->battery_time = 0;
info->battery_status = BATTERY_STATUS_ABSENT;
@@ -148,9 +150,9 @@ int simplehal_read (int battery, apm_info *info) {
/* remaining_time and charge_level.percentage are not a mandatory
* keys, so if not present, -1 will be returned */
- info->battery_time = get_hal_int(device, "battery.remaining_time");
- info->battery_percentage = get_hal_int(device, "battery.charge_level.percentage");
- if (get_hal_bool(device, "battery.rechargeable.is_discharging") == 1) {
+ info->battery_time = get_hal_int(device, "battery.remaining_time", 1);
+ info->battery_percentage = get_hal_int(device, "battery.charge_level.percentage", 1);
+ if (get_hal_bool(device, "battery.rechargeable.is_discharging", 0) == 1) {
info->battery_status = BATTERY_STATUS_CHARGING;
/* charge_level.warning and charge_level.low are not
* required to be available; this is good enough */
@@ -161,7 +163,7 @@ int simplehal_read (int battery, apm_info *info) {
info->battery_status = BATTERY_STATUS_LOW;
}
}
- else if (get_hal_bool(device, "battery.rechargeable.is_charging") == 1) {
+ else if (get_hal_bool(device, "battery.rechargeable.is_charging", 0) == 1) {
info->battery_status = BATTERY_STATUS_CHARGING;
info->battery_flags = info->battery_flags | BATTERY_FLAGS_CHARGING;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git
More information about the Pkg-wmaker-commits
mailing list