hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Mon Aug 6 06:51:32 PDT 2007


 hald/linux/addons/addon-acpi.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

New commits:
diff-tree 89b8830183dfd5755133b9fabccb37ecbc29d979 (from edb23c093069e45afc0fe17b01b669a32f07886d)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Aug 6 15:51:37 2007 +0200

    cleanup DBusError handling in addon-acpi main_loop()
    
    Cleanup the DBusError handling in addon-acpi main_loop() to
    reduce not needed calls of dbus_error_free() and dbus_error_init().

diff --git a/hald/linux/addons/addon-acpi.c b/hald/linux/addons/addon-acpi.c
index 5a67c1d..08b92be 100644
--- a/hald/linux/addons/addon-acpi.c
+++ b/hald/linux/addons/addon-acpi.c
@@ -180,6 +180,7 @@ main_loop (LibHalContext *ctx, FILE *eve
 	char event[256];
 
 	dbus_error_init (&error);
+
 	while (fgets (event, sizeof event, eventfp))
 	{
 		HAL_DEBUG (("event is '%s'", event));
@@ -195,12 +196,14 @@ main_loop (LibHalContext *ctx, FILE *eve
 				HAL_DEBUG (("button event"));
 
 				/* TODO: only rescan if button got state */
-				dbus_error_init (&error);
 				if (libhal_device_rescan (ctx, udi, &error)) {
-					dbus_error_init (&error);
 					type = libhal_device_get_property_string(ctx, udi, 
 										 "button.type",
 										 &error);
+					if (dbus_error_is_set (&error)) {
+			                        dbus_error_free (&error);
+					}
+
 					if (type != NULL) {
 						libhal_device_emit_condition (ctx, udi, "ButtonPressed",
 									      type, &error);
@@ -211,11 +214,9 @@ main_loop (LibHalContext *ctx, FILE *eve
 				}
 			} else if (strncmp (acpi_path, "ac_adapter", sizeof ("ac_adapter") - 1) == 0) {
 				HAL_DEBUG (("ac_adapter event"));
-				dbus_error_init (&error);
 				libhal_device_rescan (ctx, udi, &error);
 			} else if (strncmp (acpi_path, "battery", sizeof ("battery") - 1) == 0) {
 				HAL_DEBUG (("battery event"));
-				dbus_error_init (&error);
 				libhal_device_rescan (ctx, udi, &error);
 #ifdef BUILD_ACPI_IBM
 			} else if (strncmp (acpi_path, "ibm/hotkey", sizeof ("ibm/hotkey") -1) == 0) {
@@ -235,7 +236,6 @@ main_loop (LibHalContext *ctx, FILE *eve
 		}
 	}
 
-	dbus_error_free (&error);
 	fclose (eventfp);
 }
 


More information about the hal-commit mailing list