hal: Branch 'master' - 29 commits

Danny Kukawka dkukawka at kemper.freedesktop.org
Thu Jul 30 12:04:47 PDT 2009


 configure.in                                   |    2 
 doc/spec/hal-spec-properties.xml               |   65 +++++++++++++++++
 fdi/policy/10osvendor/20-storage-methods.fdi   |   27 +++++++
 hald/access-check.c                            |   17 ++++
 hald/ci-tracker.c                              |    5 +
 hald/ck-tracker.c                              |   16 +++-
 hald/ck-tracker.h                              |    4 -
 hald/device_info.c                             |    3 
 hald/hald_dbus.c                               |   92 +++++++++++++++++--------
 hald/hald_runner.c                             |   27 ++++---
 hald/hald_test.c                               |    2 
 hald/hald_test_libhal.c                        |    9 +-
 hald/linux/addons/addon-acpi-buttons-toshiba.c |   19 ++++-
 hald/linux/addons/addon-acpi.c                 |   32 +++++---
 hald/linux/addons/addon-cpufreq.c              |   15 +++-
 hald/linux/addons/addon-dell-backlight.cpp     |   41 ++++++++---
 hald/linux/addons/addon-generic-backlight.c    |   34 ++++++---
 hald/linux/addons/addon-hid-ups.c              |   16 +++-
 hald/linux/addons/addon-imac-backlight.c       |   29 ++++++-
 hald/linux/addons/addon-input.c                |   16 ++--
 hald/linux/addons/addon-ipw-killswitch.c       |   36 +++++++--
 hald/linux/addons/addon-leds.c                 |   11 +-
 hald/linux/addons/addon-macbook-backlight.c    |   30 +++++++-
 hald/linux/addons/addon-macbookpro-backlight.c |   45 ++++++++----
 hald/linux/addons/addon-omap-backlight.c       |   29 ++++++-
 hald/linux/addons/addon-pmu.c                  |   19 ++---
 hald/linux/addons/addon-rfkill-killswitch.c    |   14 ++-
 hald/linux/addons/addon-storage.c              |   41 ++++++-----
 hald/linux/addons/addon-usb-csr.c              |   70 +++++++++++++++----
 hald/linux/blockdev.c                          |    7 +
 hald/linux/device.c                            |   90 +++++++++++-------------
 hald/linux/probing/probe-hiddev.c              |    6 +
 hald/linux/probing/probe-ieee1394-unit.c       |    8 ++
 hald/linux/probing/probe-input.c               |    5 -
 hald/linux/probing/probe-net-bluetooth.c       |   24 ++----
 hald/linux/probing/probe-printer.c             |   18 +++-
 hald/linux/probing/probe-smbios.c              |    8 +-
 hald/linux/probing/probe-storage.c             |    6 +
 hald/linux/probing/probe-video4linux.c         |   35 ++++++---
 hald/linux/probing/probe-volume.c              |   11 +-
 hald/util_helper_priv.c                        |    1 
 libhal-storage/libhal-storage.c                |    2 
 libhal/libhal.c                                |   16 ++++
 libhal/libhal.h                                |    5 +
 tools/hal-disable-polling.c                    |    6 +
 45 files changed, 739 insertions(+), 275 deletions(-)

New commits:
commit 556f69e1171822e6e4ad2de97772836fc9b13074
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 30 19:24:11 2009 +0200

    fix commit 141ca8cd7b768ddefa1bfaa563cbef4337e32b7c
    
    Fixed commit 141ca8cd7b768ddefa1bfaa563cbef4337e32b7c:
    add void as return type to hotplug_event_begin_add_blockdev, which was
    removed with this previous commit.

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 7ae91bb..7fb15ef 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -878,7 +878,7 @@ error:
 }
 
 
-
+void
 hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_file, gboolean is_partition,
 				  HalDevice *parent, void *end_token)
 {
commit 58980ebfe77b932a36e831bfaa36552d559e2a30
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 30 19:21:09 2009 +0200

    fix compiler warning in libhal-storage
    
    Fixed compiler warning in libhal-storage:
    "libhal-storage.c:352: warning: ‘name’ may be used uninitialized
    in this function"

diff --git a/libhal-storage/libhal-storage.c b/libhal-storage/libhal-storage.c
index 0e381b6..4e95c49 100644
--- a/libhal-storage/libhal-storage.c
+++ b/libhal-storage/libhal-storage.c
@@ -356,6 +356,8 @@ libhal_volume_policy_compute_display_name (LibHalDrive *drive, LibHalVolume *vol
 	dbus_bool_t drive_is_removable;
 	char buf[MAX_STRING_SZ];
 
+	name = NULL;
+
 	volume_label = libhal_volume_get_label (volume);
 	drive_type = libhal_drive_get_type (drive);
 	drive_is_removable = libhal_drive_uses_removable_media (drive);
commit d0878de83c95757674e59f01ba0a5f86dd6c5b7e
Author: Drew Moseley <dmoseley at mvista.com>
Date:   Thu Jul 30 19:19:53 2009 +0200

    add libhal_device_property_remove_watch_all() to libhal
    
    Added libhal_device_property_remove_watch_all() to libhal.
    
    libhal.c and libhal.h define a function libhal_device_property_watch_all()
    allowing a callback on any device changed.  There is not a corresponding
    remove function that I could find.  I was triggering a resource fault
    (too many watches not surprisingly) in network manager by continually
    restarting hal.  I added the function shown below and ensured that the
    hal_deinit() function in network manager called this and that seemed to
    resolve the issue.

diff --git a/libhal/libhal.c b/libhal/libhal.c
index 9e4b99f..c9d9f74 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -3196,6 +3196,22 @@ libhal_device_property_watch_all (LibHalContext *ctx, DBusError *error)
 }
 
 
+dbus_bool_t
+libhal_device_property_remove_watch_all (LibHalContext *ctx, DBusError *error)
+{
+	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+
+	dbus_bus_remove_match (ctx->connection,
+			    "type='signal',"
+			    "interface='org.freedesktop.Hal.Device',"
+			    "sender='org.freedesktop.Hal'", error);
+	if (error != NULL && dbus_error_is_set (error)) {
+		return FALSE;
+	}
+	return TRUE;
+}
+
+
 /**
  * libhal_device_add_property_watch:
  * @ctx: the context for the connection to hald
diff --git a/libhal/libhal.h b/libhal/libhal.h
index 99ba191..23c7d13 100644
--- a/libhal/libhal.h
+++ b/libhal/libhal.h
@@ -685,6 +685,11 @@ char **libhal_find_device_by_capability (LibHalContext *ctx,
 dbus_bool_t libhal_device_property_watch_all (LibHalContext *ctx,
 					      DBusError *error);
 
+/* Remove a watch of all devices.
+ */
+dbus_bool_t libhal_device_property_remove_watch_all (LibHalContext *ctx,
+					      DBusError *error);
+
 /* Add a watch on a device, so the device_property_changed callback is
  * invoked when the properties on the given device changes.
  */
commit a9f78d29dac1129defdc3352de120d1d3d6da592
Merge: 3ff458b... 141ca8c...
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 30 18:46:39 2009 +0200

    Merge branch 'master' of ssh://dkukawka@git.freedesktop.org/git/hal

commit 3ff458bd44fd0a92486c0a818ce6d48ade26e1bd
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Jul 24 19:25:47 2009 +0200

    fix DBusError handling in linux addon directory
    
    Fixed DBusError handling in probe directory:
    - free DBusError if a potential error happend (use
      LIBHAL_FREE_DBUS_ERROR() where possible)
    - don't use dbus_error_init() to free a DBusError, use
      dbus_error_free()/LIBHAL_FREE_DBUS_ERROR() instead
    - removed unused DBusError variables
    
    Also fixed:
    - call libhal_ctx_shutdown() and libhal_ctx_free() on
      exit or if a happen in main() of an addon

diff --git a/hald/linux/addons/addon-acpi-buttons-toshiba.c b/hald/linux/addons/addon-acpi-buttons-toshiba.c
index f0dc09d..74d413a 100644
--- a/hald/linux/addons/addon-acpi-buttons-toshiba.c
+++ b/hald/linux/addons/addon-acpi-buttons-toshiba.c
@@ -175,19 +175,19 @@ main (int argc, char **argv)
 	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
 		HAL_ERROR (("Unable to initialise libhal context: %s", error.message));
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		return 1;
 	}
 
-	dbus_error_init (&error);
 	if (!libhal_device_addon_is_ready (ctx, udi, &error)) {
-		return 1;
+		goto out;	
 	}
 
 	/* Check for Toshiba ACPI interface /proc/acpi/toshiba/keys */
 	fp = fopen (TOSHIBA_ACPI_KEYS, "r+");
 	if (!fp) {
 		HAL_ERROR (("Could not open %s! Aborting.", TOSHIBA_ACPI_KEYS));
-		return 0;
+		goto out;
 	}
 	fclose (fp);
 
@@ -200,4 +200,17 @@ main (int argc, char **argv)
 	loop = g_main_loop_new (NULL, FALSE);
 	g_main_loop_run (loop);
 	return 0;
+
+out:
+        HAL_DEBUG (("An error occured, exiting cleanly"));
+
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
+        if (ctx != NULL) {
+                libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
+                libhal_ctx_free (ctx);
+        }
+
+	return 0;
 }
diff --git a/hald/linux/addons/addon-acpi.c b/hald/linux/addons/addon-acpi.c
index 8a1cac9..6365780 100644
--- a/hald/linux/addons/addon-acpi.c
+++ b/hald/linux/addons/addon-acpi.c
@@ -224,14 +224,13 @@ main_loop (LibHalContext *ctx, FILE *eventfp)
 						type = libhal_device_get_property_string(ctx, udi, 
 											 "button.type",
 											 &error);
-						if (dbus_error_is_set (&error)) {
-							dbus_error_free (&error);
-						}
+						LIBHAL_FREE_DBUS_ERROR(&error);
 
 						if (type != NULL) {
 							libhal_device_emit_condition (ctx, udi, "ButtonPressed",
 										      type, &error);
 							libhal_free_string(type);
+							LIBHAL_FREE_DBUS_ERROR(&error);
 						} else {
 							libhal_device_emit_condition (ctx, udi, "ButtonPressed", "", &error);
 						}
@@ -249,11 +248,7 @@ main_loop (LibHalContext *ctx, FILE *eventfp)
 			HAL_DEBUG (("cannot parse event"));
 		}
 
-		if (dbus_error_is_set (&error)) {
-	        	/* Free the error (which include a dbus_error_init()) 
-			   This should prevent errors if a call above fails */
-			dbus_error_free (&error);
-		}
+		LIBHAL_FREE_DBUS_ERROR(&error);
 	}
 
 	fclose (eventfp);
@@ -279,12 +274,11 @@ main (int argc, char **argv)
 	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
 		HAL_ERROR (("Unable to initialise libhal context: %s", error.message));
-		return 1;
+		goto out;
 	}
 
-	dbus_error_init (&error);
 	if (!libhal_device_addon_is_ready (ctx, getenv ("UDI"), &error)) {
-		return 1;
+		goto out;
 	}
 
 #ifdef ACPI_PROC
@@ -296,7 +290,7 @@ main (int argc, char **argv)
 		hal_set_proc_title ("hald-addon-acpi: listening on acpi kernel interface /proc/acpi/event");
 		main_loop (ctx, eventfp);
 		HAL_ERROR (("Lost connection to kernel acpi event source - exiting"));
-		return 1;
+		goto out;
 	}
 #endif
 
@@ -315,6 +309,20 @@ main (int argc, char **argv)
 		 * sleep for 5s and try to reconnect (again). */
 		sleep (5);
 	}
+
+out:
+
+        HAL_DEBUG (("An error occured, exiting cleanly"));
+
+        LIBHAL_FREE_DBUS_ERROR (&error);
+
+        if (ctx != NULL) {
+                libhal_ctx_shutdown (ctx, &error);
+                LIBHAL_FREE_DBUS_ERROR (&error);
+                libhal_ctx_free (ctx);
+        }
+
+	return 1;
 }
 
 /* vim:set sw=8 noet: */
diff --git a/hald/linux/addons/addon-cpufreq.c b/hald/linux/addons/addon-cpufreq.c
index 1d66e23..2669d3a 100644
--- a/hald/linux/addons/addon-cpufreq.c
+++ b/hald/linux/addons/addon-cpufreq.c
@@ -1071,6 +1071,7 @@ static DBusHandlerResult dbus_filter_function(DBusConnection *connection,
 
 		if (!dbus_get_argument(connection, message, &dbus_error,
 				       DBUS_TYPE_STRING, &arg)) {
+			LIBHAL_FREE_DBUS_ERROR (&dbus_error);
 			return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 		}
  		HAL_DEBUG(("Received argument: %s", arg));
@@ -1084,6 +1085,7 @@ static DBusHandlerResult dbus_filter_function(DBusConnection *connection,
 
 		if (!dbus_get_argument(connection, message, &dbus_error,
 				       DBUS_TYPE_INT32, &arg)) {
+			LIBHAL_FREE_DBUS_ERROR (&dbus_error);
 			return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 		}
  		HAL_DEBUG(("Received argument: %d", arg));
@@ -1097,6 +1099,7 @@ static DBusHandlerResult dbus_filter_function(DBusConnection *connection,
 
 		if (!dbus_get_argument(connection, message, &dbus_error,
 				       DBUS_TYPE_BOOLEAN, &arg)) {
+			LIBHAL_FREE_DBUS_ERROR (&dbus_error);
 			return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 		}
  		HAL_DEBUG(("Received argument: %d", arg));
@@ -1164,6 +1167,7 @@ gboolean dbus_init_local(void)
 
 	dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
 	if (dbus_error_is_set(&dbus_error)) {
+		dbus_error_free (&dbus_error);
 		HAL_WARNING(("Cannot get D-Bus connection"));
 		return TRUE;
 	}
@@ -1244,7 +1248,14 @@ gboolean dbus_init(void)
 	return TRUE;
 
 Error:
-	dbus_error_free(&dbus_error);
+        LIBHAL_FREE_DBUS_ERROR (&dbus_error);
+
+	if (halctx != NULL) {
+                libhal_ctx_shutdown (halctx, &dbus_error);
+                LIBHAL_FREE_DBUS_ERROR (&dbus_error);
+                libhal_ctx_free (halctx);
+        }
+
 	return FALSE;
 }
 /********************* DBus end *********************/
diff --git a/hald/linux/addons/addon-dell-backlight.cpp b/hald/linux/addons/addon-dell-backlight.cpp
index fa27fac..b22de3b 100644
--- a/hald/linux/addons/addon-dell-backlight.cpp
+++ b/hald/linux/addons/addon-dell-backlight.cpp
@@ -185,6 +185,7 @@ check_priv (DBusConnection *connection, DBusMessage *message, const char *udi, c
         ret = TRUE;
 
 out:
+	LIBHAL_FREE_DBUS_ERROR (&error);
         if (polkit_result != NULL)
                 libhal_free_string (polkit_result);
         return ret;
@@ -215,8 +216,7 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 	/* Mechanism to ensure that we always set the AC brightness when we are on AC-power etc. */
 	if ((udis = libhal_find_device_by_capability(halctx, "ac_adapter", &num_devices, &err)) != NULL) {
 		for (i = 0; udis[i] != NULL; i++) {
-			if (dbus_error_is_set(&err)) 
-				dbus_error_free (&err);
+			LIBHAL_FREE_DBUS_ERROR (&err);
 
 			if (libhal_device_property_exists (halctx, udis[i], "ac_adapter.present", &err)) {
 				AC = libhal_device_get_property_bool (halctx, udis[i], "ac_adapter.present", &err);
@@ -233,8 +233,7 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 		
 		HAL_DEBUG (("Received SetBrightness DBus call"));
 
-		if (dbus_error_is_set(&err)) 
-			dbus_error_free (&err);
+		LIBHAL_FREE_DBUS_ERROR (&err);
 
 		if (dbus_message_get_args (message, 
 					   &err,
@@ -290,6 +289,8 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 		}
 	}	
 error:
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
 	if (reply != NULL)
 		dbus_message_unref (reply);
 	
@@ -300,6 +301,7 @@ int
 main (int argc, char *argv[])
 {
  	DBusError err;
+	int retval = 0;
 
 	setup_logger ();
 
@@ -308,18 +310,20 @@ main (int argc, char *argv[])
 	HAL_DEBUG (("udi=%s", udi));
 	if (udi == NULL) {
 		HAL_ERROR (("No device specified"));
-		return -2;
+		retval = -2;
+		goto out;
 	}
 
 	dbus_error_init (&err);
 	if ((halctx = libhal_ctx_init_direct (&err)) == NULL) {
 		HAL_ERROR (("Cannot connect to hald"));
-		return -3;
+		retval = -3;
+		goto out;
 	}
 
-	dbus_error_init (&err);
 	if (!libhal_device_addon_is_ready(halctx, udi, &err)) {
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
 	conn = libhal_ctx_get_dbus_connection (halctx);
@@ -335,7 +339,8 @@ main (int argc, char *argv[])
 
 	if (maxValue == 0) {
 		HAL_ERROR (("This machine don't support set brightness."));
-		return -5;
+		retval = -5;
+		goto out;
 	}
 	
 	if (!libhal_device_set_property_int (halctx, 
@@ -344,7 +349,8 @@ main (int argc, char *argv[])
 					    maxValue + 1,
 					    &err)) {
 		HAL_ERROR (("Could not set 'laptop_panel.numlevels' to %d", maxValue));
-		return -4;
+		retval = -4;
+		goto out;
 	}
 	HAL_DEBUG (("laptop_panel.numlevels is set to %d", maxValue + 1));
 
@@ -361,12 +367,25 @@ main (int argc, char *argv[])
 					    "    </method>\n",
 					    &err)) {
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.LaptopPanel'"));
-		return -4;
+		retval = -4;
+		goto out;
 	}
 	
 	main_loop = g_main_loop_new (NULL, FALSE);
 	g_main_loop_run (main_loop);
 	return 0;
+
+out: 
+
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
+	if (halctx != NULL) {
+		libhal_ctx_shutdown (halctx, &err);
+		LIBHAL_FREE_DBUS_ERROR (&err);
+		libhal_ctx_free (halctx);
+	}
+
+	return retval;
 }
 
 
diff --git a/hald/linux/addons/addon-generic-backlight.c b/hald/linux/addons/addon-generic-backlight.c
index fd2d8f5..8ab2b22 100644
--- a/hald/linux/addons/addon-generic-backlight.c
+++ b/hald/linux/addons/addon-generic-backlight.c
@@ -138,6 +138,7 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 {
 	DBusError err;
 	DBusMessage *reply;
+	int brightness;
 
 	if (!check_priv (halctx, connection, message, dbus_message_get_path (message),
 	                 "org.freedesktop.hal.power-management.lcd-panel")) {
@@ -146,12 +147,11 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 
 	reply = NULL;
 
+	dbus_error_init (&err);
+
 	if (dbus_message_is_method_call (message,
 					 "org.freedesktop.Hal.Device.LaptopPanel",
 					 "SetBrightness")) {
-		int brightness;
-
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_INT32, &brightness,
@@ -185,9 +185,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 	} else if (dbus_message_is_method_call (message,
 						"org.freedesktop.Hal.Device.LaptopPanel",
 						"GetBrightness")) {
-		int brightness;
-
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_INVALID)) {
@@ -205,6 +202,8 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 	}
 
 error:
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
 	if (reply != NULL)
 		dbus_message_unref (reply);
 
@@ -216,6 +215,7 @@ main (int argc, char *argv[])
 {
 	DBusError err;
 	char * level_str;
+	int retval = 0;
 
 	setup_logger ();
 	udi = getenv ("UDI");
@@ -241,7 +241,8 @@ main (int argc, char *argv[])
 	dbus_error_init (&err);
 	if ((halctx = libhal_ctx_init_direct (&err)) == NULL) {
 		HAL_ERROR (("Cannot connect to hald"));
-		return -3;
+		retval = -3;
+		goto out;
 	}
 
 	conn = libhal_ctx_get_dbus_connection (halctx);
@@ -261,15 +262,28 @@ main (int argc, char *argv[])
 					    "    </method>\n",
 					    &err)) {
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.LaptopPanel'"));
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
 	dbus_error_init (&err);
 	if (!libhal_device_addon_is_ready (halctx, udi, &err)) {
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
 	main_loop = g_main_loop_new (NULL, FALSE);
 	g_main_loop_run (main_loop);
 	return 0;
+
+out:
+        LIBHAL_FREE_DBUS_ERROR (&err);
+
+        if (halctx != NULL) {
+                libhal_ctx_shutdown (halctx, &err);
+                LIBHAL_FREE_DBUS_ERROR (&err);
+                libhal_ctx_free (halctx);
+        }
+
+        return retval;
 }
diff --git a/hald/linux/addons/addon-hid-ups.c b/hald/linux/addons/addon-hid-ups.c
index b18e1bc..61afbd2 100644
--- a/hald/linux/addons/addon-hid-ups.c
+++ b/hald/linux/addons/addon-hid-ups.c
@@ -275,12 +275,13 @@ ups_get_static (LibHalContext *ctx, const char *udi, int fd,
 	dbus_error_init (&error);
 	libhal_device_commit_changeset (ctx, cs, &error);
 
-	dbus_error_init (&error);
+	LIBHAL_FREE_DBUS_ERROR (&error);	
 	libhal_device_add_capability (ctx, udi, "battery", &error);
 
 	ret = TRUE;
 
 out:
+	LIBHAL_FREE_DBUS_ERROR (&error);
 	libhal_device_free_changeset (cs);
 
 	return ret;
@@ -328,7 +329,6 @@ main (int argc, char *argv[])
 
 	hal_set_proc_title ("hald-addon-hid-ups: listening on %s", device_file);
 
-	dbus_error_init (&error);
 	if (!libhal_device_addon_is_ready (ctx, udi, &error)) {
 		goto out;
 	}
@@ -338,7 +338,6 @@ main (int argc, char *argv[])
 		FD_SET(fd, &fdset);
 		rd = select(fd+1, &fdset, NULL, NULL, NULL);
 
-		
 		if (rd > 0) {
 			LibHalChangeSet *cs;
 
@@ -399,14 +398,23 @@ main (int argc, char *argv[])
 				}
 			}
 
-			dbus_error_init (&error);
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			/* NOTE: commit_changeset won't do IPC if set is empty */
 			libhal_device_commit_changeset (ctx, cs, &error);
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			libhal_device_free_changeset (cs);
 
 		}
 	}
 
 out:
+        LIBHAL_FREE_DBUS_ERROR (&error);
+
+        if (ctx != NULL) {
+                libhal_ctx_shutdown (ctx, &error);
+                LIBHAL_FREE_DBUS_ERROR (&error);
+                libhal_ctx_free (ctx);
+        }
+	
 	return 0;
 }
diff --git a/hald/linux/addons/addon-imac-backlight.c b/hald/linux/addons/addon-imac-backlight.c
index b082f89..e869192 100644
--- a/hald/linux/addons/addon-imac-backlight.c
+++ b/hald/linux/addons/addon-imac-backlight.c
@@ -120,6 +120,8 @@ filter_function (DBusConnection * connection, DBusMessage * message, void *userd
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
 	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
@@ -130,6 +132,7 @@ main (int argc, char **argv)
 	GMainLoop *main_loop;
 	const char *udi;
 	DBusError err;
+	int retval;
 
 	setup_logger ();
 	udi = getenv ("UDI");
@@ -145,12 +148,15 @@ main (int argc, char **argv)
 	if ((halctx = libhal_ctx_init_direct (&err)) == NULL)
 	{
 		HAL_ERROR (("Cannot connect to hald"));
-		return -3;
+		retval = -3;
+		goto out;
 	}
 
-	dbus_error_init (&err);
-	if (!libhal_device_addon_is_ready (halctx, udi, &err))
-		return -4;
+	if (!libhal_device_addon_is_ready (halctx, udi, &err)) 
+	{
+		retval = -4;
+		goto out;
+	}
 
 	if (ioperm(0xB2, 0xB3, 1) < 0)
 	{
@@ -167,11 +173,22 @@ main (int argc, char **argv)
 					    BACKLIGHT_IFACE, INTERFACE_DESCRIPTION, &err))
 	{
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.LaptopPanel'"));
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
 	main_loop = g_main_loop_new (NULL, FALSE);
 	g_main_loop_run (main_loop);
 	return 0;
-}
 
+out:
+        LIBHAL_FREE_DBUS_ERROR (&err);
+
+        if (halctx != NULL) {
+                libhal_ctx_shutdown (halctx, &err);
+                LIBHAL_FREE_DBUS_ERROR (&err);
+                libhal_ctx_free (halctx);
+        }
+
+        return retval;
+}
diff --git a/hald/linux/addons/addon-input.c b/hald/linux/addons/addon-input.c
index 754a855..0a433b1 100644
--- a/hald/linux/addons/addon-input.c
+++ b/hald/linux/addons/addon-input.c
@@ -217,6 +217,8 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 	if (condition & (G_IO_HUP | G_IO_ERR | G_IO_NVAL))
 		return FALSE;
 
+	dbus_error_init (&error);
+
 	/** tbh, we can probably assume every time we read we have a whole
 	 * event availiable, but hey..*/
 	while (g_io_channel_read_chars (channel,
@@ -284,11 +286,11 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 					if (new_state != input_data->button_state) {
 						input_data->button_state = new_state;
 
-						dbus_error_init (&error);
 						libhal_device_set_property_bool (ctx, input_data->udi, "button.state.value",
 										 input_data->button_state, &error);
 
-						dbus_error_init (&error);
+						LIBHAL_FREE_DBUS_ERROR (&error);
+
 						libhal_device_emit_condition (ctx, input_data->udi,
 									      "ButtonPressed",
 									      name,
@@ -298,7 +300,6 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 				}
 			}
 		} else if (input_data->event.type == EV_KEY && key_name[input_data->event.code] != NULL && input_data->event.value) {
-			dbus_error_init (&error);
 			libhal_device_emit_condition (ctx, input_data->udi,
 						      "ButtonPressed",
 						      key_name[input_data->event.code],
@@ -307,6 +308,8 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 		}
 	}
 
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	return TRUE;
 }
 
@@ -475,8 +478,6 @@ main (int argc, char **argv)
 	dbus_connection_setup_with_g_main (dbus_connection, NULL);
 	dbus_connection_set_exit_on_disconnect (dbus_connection, 0);
 
-	dbus_error_init (&error);
-
 	if (!libhal_device_singleton_addon_is_ready (ctx, commandline, &error)) {
 		goto out;
 	}
@@ -496,8 +497,11 @@ main (int argc, char **argv)
 
 out:
 	HAL_DEBUG (("An error occured, exiting cleanly"));
+
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (ctx != NULL) {
-		dbus_error_init (&error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_shutdown (ctx, &error);
 		libhal_ctx_free (ctx);
 	}
diff --git a/hald/linux/addons/addon-ipw-killswitch.c b/hald/linux/addons/addon-ipw-killswitch.c
index 866819c..7b408e3 100644
--- a/hald/linux/addons/addon-ipw-killswitch.c
+++ b/hald/linux/addons/addon-ipw-killswitch.c
@@ -186,13 +186,14 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 	}
 
 	reply = NULL;
+	
+	dbus_error_init (&err);
 
 	if (dbus_message_is_method_call (message,
 					 "org.freedesktop.Hal.Device.KillSwitch",
 					 "SetPower")) {
 		gboolean status;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_BOOLEAN, &status,
@@ -220,7 +221,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 						"GetPower")) {
 		int status;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_INVALID)) {
@@ -241,6 +241,8 @@ error:
 	if (reply != NULL)
 		dbus_message_unref (reply);
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
 	return DBUS_HANDLER_RESULT_HANDLED;
 }
 
@@ -249,6 +251,7 @@ main (int argc, char *argv[])
 {
 	DBusError err;
 	char *method;
+	int retval = 0;
 
 	setup_logger ();
 	udi = getenv ("UDI");
@@ -268,7 +271,8 @@ main (int argc, char *argv[])
 	dbus_error_init (&err);
 	if ((halctx = libhal_ctx_init_direct (&err)) == NULL) {
 		HAL_ERROR (("Cannot connect to hald"));
-		return -3;
+		retval = -3;
+		goto out;
 	}
 
 	conn = libhal_ctx_get_dbus_connection (halctx);
@@ -276,8 +280,10 @@ main (int argc, char *argv[])
 
 	dbus_connection_add_filter (conn, filter_function, NULL, NULL);
 
-	if (!init_killswitch())
-		return -4;
+	if (!init_killswitch()) {
+		retval = -4;
+		goto out;
+	}
 
 	if (!libhal_device_claim_interface (halctx,
 					    udi,
@@ -291,15 +297,29 @@ main (int argc, char *argv[])
 					    "    </method>\n",
 					    &err)) {
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.KillSwitch'"));
-		return -5;
+		retval = -5;
+		goto out;
 	}
 
-	dbus_error_init (&err);
 	if (!libhal_device_addon_is_ready (halctx, udi, &err)) {
-		return -5;
+		retval = -5;
+		goto out;
 	}
 
 	main_loop = g_main_loop_new (NULL, FALSE);
 	g_main_loop_run (main_loop);
 	return 0;
+
+out:
+        HAL_DEBUG (("An error occured, exiting cleanly"));
+
+        LIBHAL_FREE_DBUS_ERROR (&err);
+
+        if (halctx != NULL) {
+                libhal_ctx_shutdown (halctx, &err);
+                LIBHAL_FREE_DBUS_ERROR (&err);
+                libhal_ctx_free (halctx);
+        }
+
+	return retval;
 }
diff --git a/hald/linux/addons/addon-leds.c b/hald/linux/addons/addon-leds.c
index 86997b1..a42f856 100644
--- a/hald/linux/addons/addon-leds.c
+++ b/hald/linux/addons/addon-leds.c
@@ -163,7 +163,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 					 "SetBrightness")) {
 		int brightness;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_INT32, &brightness,
@@ -193,7 +192,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 						"GetBrightness")) {
 		int brightness;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_INVALID)) {
@@ -214,6 +212,8 @@ error:
 	if (reply != NULL)
 		dbus_message_unref (reply);
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
 	return DBUS_HANDLER_RESULT_HANDLED;
 }
 
@@ -258,6 +258,7 @@ add_device (LibHalContext *ctx,
 					    "    </method>\n",
 					    &err)) {
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.Leds'"));
+		LIBHAL_FREE_DBUS_ERROR (&err);
 		return;
 	}
 	
@@ -322,7 +323,6 @@ main (int argc, char *argv[])
 	dbus_connection_setup_with_g_main (dbus_connection, NULL);
 	dbus_connection_set_exit_on_disconnect (dbus_connection, 0);
 
-	dbus_error_init (&error);
 
 	if (!libhal_device_singleton_addon_is_ready (ctx, commandline, &error)) {
 		goto out;
@@ -337,9 +337,12 @@ main (int argc, char *argv[])
 
 out:
 	HAL_DEBUG (("An error occured, exiting cleanly"));
+	
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/addons/addon-macbook-backlight.c b/hald/linux/addons/addon-macbook-backlight.c
index eb9ed0a..33f9593 100644
--- a/hald/linux/addons/addon-macbook-backlight.c
+++ b/hald/linux/addons/addon-macbook-backlight.c
@@ -246,6 +246,8 @@ filter_function (DBusConnection * connection, DBusMessage * message, void *userd
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
 	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
@@ -256,6 +258,7 @@ main (int argc, char **argv)
 	GMainLoop *main_loop;
 	const char *udi;
 	DBusError err;
+	int retval = 0;
 
 	setup_logger ();
 	udi = getenv ("UDI");
@@ -264,13 +267,16 @@ main (int argc, char **argv)
 		HAL_ERROR (("no device specified"));
 
 	dbus_error_init (&err);
-	if ((halctx = libhal_ctx_init_direct (&err)) == NULL)
+	if ((halctx = libhal_ctx_init_direct (&err)) == NULL) {
 		HAL_ERROR (("cannot connect to hald"));
+		retval = -4;
+		goto out;
+	}
 
-	dbus_error_init (&err);
 	if (!libhal_device_addon_is_ready (halctx, udi, &err)) {
 		HAL_ERROR (("libhal_device_addon_is_ready returned false, exit now"));
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
 	if (!map_register_page ()) {
@@ -284,12 +290,28 @@ main (int argc, char **argv)
 	dbus_connection_add_filter (conn, filter_function, NULL, NULL);
 
 	if (!libhal_device_claim_interface (halctx, BACKLIGHT_OBJECT,
-					    BACKLIGHT_IFACE, INTERFACE_DESCRIPTION, &err))
+					    BACKLIGHT_IFACE, INTERFACE_DESCRIPTION, &err)) {
 		HAL_ERROR (("cannot claim interface"));
+		retval = -4;
+		goto out;
+	}
 
 	main_loop = g_main_loop_new (NULL, FALSE);
 	g_main_loop_run (main_loop);
 
 	return 0;
+
+out:
+        HAL_DEBUG (("An error occured, exiting cleanly"));
+
+        LIBHAL_FREE_DBUS_ERROR (&err);
+
+        if (halctx != NULL) {
+                libhal_ctx_shutdown (halctx, &err);
+                LIBHAL_FREE_DBUS_ERROR (&err);
+                libhal_ctx_free (halctx);
+        }
+
+        return retval;
 }
 
diff --git a/hald/linux/addons/addon-macbookpro-backlight.c b/hald/linux/addons/addon-macbookpro-backlight.c
index 3c1a799..2a6fef6 100644
--- a/hald/linux/addons/addon-macbookpro-backlight.c
+++ b/hald/linux/addons/addon-macbookpro-backlight.c
@@ -239,6 +239,7 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 	     dbus_message_get_member (message));*/
 
 	reply = NULL;
+	dbus_error_init (&err);
 
 	if (dbus_message_is_method_call (message, 
 					 "org.freedesktop.Hal.Device.LaptopPanel", 
@@ -248,7 +249,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
                 if (!check_priv (halctx, connection, message, udi, "org.freedesktop.hal.power-management.lcd-panel"))
                         goto error;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message, 
 					   &err,
 					   DBUS_TYPE_INT32, &brightness,
@@ -285,7 +285,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
                 if (!check_priv (halctx, connection, message, udi, "org.freedesktop.hal.power-management.lcd-panel"))
                         goto error;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message, 
 					   &err,
 					   DBUS_TYPE_INVALID)) {
@@ -388,7 +387,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
                 if (!check_priv (halctx, connection, message, udi, "org.freedesktop.hal.power-management.keyboard-backlight"))
                         goto error;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message, 
 					   &err,
 					   DBUS_TYPE_INT32, &brightness,
@@ -417,6 +415,8 @@ error:
 	if (reply != NULL)
 		dbus_message_unref (reply);
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
 	return DBUS_HANDLER_RESULT_HANDLED;
 }
 
@@ -427,6 +427,7 @@ main (int argc, char *argv[])
  	size_t length = 0;
  	int fd;
  	int state;
+	int retval = 0;
 	struct pci_access *pacc;
  	struct pci_dev *dev;
 
@@ -444,12 +445,13 @@ main (int argc, char *argv[])
 	dbus_error_init (&err);
 	if ((halctx = libhal_ctx_init_direct (&err)) == NULL) {
 		HAL_ERROR (("Cannot connect to hald"));
-		return -3;
+		retval = -3;
+		goto out;
 	}
 
-	dbus_error_init (&err);
 	if (!libhal_device_addon_is_ready (halctx, udi, &err)) {
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
 
@@ -480,21 +482,24 @@ main (int argc, char *argv[])
  
  	if (!address) {
  		HAL_DEBUG (("Failed to detect ATI X1600, aborting..."));
- 		return 1;
+		retval = 1;
+		goto out;
  	}
  
  	fd = open ("/dev/mem", O_RDWR);
  	
  	if (fd < 0) {
  		HAL_DEBUG (("cannot open /dev/mem"));
- 		return 1;
+		retval = 1;
+		goto out;
  	}
  
  	memory = mmap (NULL, length, PROT_READ|PROT_WRITE, MAP_SHARED, fd, address);
  
  	if (memory == MAP_FAILED) {
  		HAL_ERROR (("mmap failed"));
- 		return 2;
+		retval = 2;
+		goto out;
  	}
  
  	/* Is it really necessary ? */
@@ -520,7 +525,8 @@ main (int argc, char *argv[])
 					    "    </method>\n",
 					    &err)) {
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.LaptopPanel'"));
-		return -4;
+		retval = -4;
+		goto out;
 	}
 	if (!libhal_device_claim_interface (halctx, 
 					    "/org/freedesktop/Hal/devices/macbook_pro_light_sensor",
@@ -530,7 +536,8 @@ main (int argc, char *argv[])
 					    "    </method>\n",
 					    &err)) {
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.LightSensor'"));
-		return -4;
+		retval = -4;
+		goto out;
 	}
 	if (!libhal_device_claim_interface (halctx, 
 					    "/org/freedesktop/Hal/devices/macbook_pro_keyboard_backlight",
@@ -543,10 +550,24 @@ main (int argc, char *argv[])
 					    "    </method>\n",
 					    &err)) {
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.KeyboardBacklight'"));
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
 	main_loop = g_main_loop_new (NULL, FALSE);
 	g_main_loop_run (main_loop);
 	return 0;
+
+out:
+        HAL_DEBUG (("An error occured, exiting cleanly"));
+
+        LIBHAL_FREE_DBUS_ERROR (&err);
+
+        if (halctx != NULL) {
+                libhal_ctx_shutdown (halctx, &err);
+                LIBHAL_FREE_DBUS_ERROR (&err);
+                libhal_ctx_free (halctx);
+        }
+
+        return retval;
 }
diff --git a/hald/linux/addons/addon-omap-backlight.c b/hald/linux/addons/addon-omap-backlight.c
index a0105be..780d36d 100644
--- a/hald/linux/addons/addon-omap-backlight.c
+++ b/hald/linux/addons/addon-omap-backlight.c
@@ -158,13 +158,13 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 	     dbus_message_get_member (message));
 #endif
 	reply = NULL;
+	dbus_error_init (&err);
 
 	if (dbus_message_is_method_call (message,
 					 "org.freedesktop.Hal.Device.LaptopPanel",
 					 "SetBrightness")) {
 		int brightness;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_INT32, &brightness,
@@ -195,7 +195,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 						"GetBrightness")) {
 		int brightness;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_INVALID)) {
@@ -223,6 +222,8 @@ error:
 	if (reply != NULL)
 		dbus_message_unref (reply);
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
 	return DBUS_HANDLER_RESULT_HANDLED;
 }
 
@@ -240,6 +241,7 @@ int
 main (int argc, char *argv[])
 {
 	DBusError err;
+	int retval = 0;
 
 	setup_logger ();
 	setup_cb ();
@@ -254,7 +256,8 @@ main (int argc, char *argv[])
 	dbus_error_init (&err);
 	if ((halctx = libhal_ctx_init_direct (&err)) == NULL) {
 		HAL_ERROR (("Cannot connect to hald"));
-		return -3;
+		retval = -3;
+		goto out;
 	}
 
 	conn = libhal_ctx_get_dbus_connection (halctx);
@@ -274,16 +277,30 @@ main (int argc, char *argv[])
 					    "    </method>\n",
 					    &err)) {
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.LaptopPanel'"));
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
-	dbus_error_init (&err);
 	if (!libhal_device_addon_is_ready (halctx, udi, &err)) {
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
 	bl_data.backlight_init (&bl_data);
 	main_loop = g_main_loop_new (NULL, FALSE);
 	g_main_loop_run (main_loop);
 	return 0;
+
+out:
+        HAL_DEBUG (("An error occured, exiting cleanly"));
+
+        LIBHAL_FREE_DBUS_ERROR (&err);
+
+        if (halctx != NULL) {
+                libhal_ctx_shutdown (halctx, &err);
+                LIBHAL_FREE_DBUS_ERROR (&err);
+                libhal_ctx_free (halctx);
+        }
+
+        return retval;
 }
diff --git a/hald/linux/addons/addon-pmu.c b/hald/linux/addons/addon-pmu.c
index f292460..184f8c1 100644
--- a/hald/linux/addons/addon-pmu.c
+++ b/hald/linux/addons/addon-pmu.c
@@ -66,7 +66,6 @@ main (int argc, char *argv[])
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
 		goto out;
 
-	dbus_error_init (&error);
 	if (!libhal_device_addon_is_ready (ctx, udi, &error)) {
 		goto out;
 	}
@@ -117,10 +116,8 @@ main (int argc, char *argv[])
 
 				if (new_state != state) {
 					HAL_DEBUG (("lid state change: %d", new_state));
-					dbus_error_init (&error);
-					libhal_device_set_property_bool (
-						ctx, udi, "button.state.value", new_state, &error);
-					dbus_error_init (&error);
+					libhal_device_set_property_bool (ctx, udi, "button.state.value", new_state, &error);
+					LIBHAL_FREE_DBUS_ERROR (&error);
 					libhal_device_emit_condition (ctx, udi, "ButtonPressed", "", &error);
 				}
 
@@ -129,15 +126,21 @@ main (int argc, char *argv[])
 
 			
 		}
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		usleep (1000 * 1000);
 	}
 
-
-
-
 out:
 	if (fd >= 0)
 		close (fd);
 
+        LIBHAL_FREE_DBUS_ERROR (&error);
+
+        if (ctx != NULL) {
+                libhal_ctx_shutdown (ctx, &error);
+                LIBHAL_FREE_DBUS_ERROR (&error);
+                libhal_ctx_free (ctx);
+        }
+
 	return 0;
 }
diff --git a/hald/linux/addons/addon-rfkill-killswitch.c b/hald/linux/addons/addon-rfkill-killswitch.c
index a6fb54d..9e6a551 100644
--- a/hald/linux/addons/addon-rfkill-killswitch.c
+++ b/hald/linux/addons/addon-rfkill-killswitch.c
@@ -174,6 +174,7 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 
 	if ((type = libhal_device_get_property_string (ctx, _udi, "killswitch.type", &err)) == NULL) {
 		HAL_DEBUG (("Couldn't get the type of the killswitch device (%s). Ignore call.", _udi));
+		LIBHAL_FREE_DBUS_ERROR (&err);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}  
 
@@ -192,7 +193,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 					 "SetPower")) {
 		gboolean status;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_BOOLEAN, &status,
@@ -220,7 +220,6 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 						"GetPower")) {
 		int status;
 
-		dbus_error_init (&err);
 		if (dbus_message_get_args (message,
 					   &err,
 					   DBUS_TYPE_INVALID)) {
@@ -241,6 +240,8 @@ error:
 	if (reply != NULL)
 		dbus_message_unref (reply);
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
+
 	return DBUS_HANDLER_RESULT_HANDLED;
 }
 
@@ -285,6 +286,7 @@ add_device (LibHalContext *ctx,
 					    "    </method>\n",
 					    &err)) {
 		HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.KillSwitch'"));
+		LIBHAL_FREE_DBUS_ERROR (&err);
 		return;
 	}
 	
@@ -349,8 +351,6 @@ main (int argc, char *argv[])
 	dbus_connection_setup_with_g_main (dbus_connection, NULL);
 	dbus_connection_set_exit_on_disconnect (dbus_connection, 0);
 
-	dbus_error_init (&error);
-
 	if (!libhal_device_singleton_addon_is_ready (ctx, commandline, &error)) {
 		goto out;
 	}
@@ -364,9 +364,12 @@ main (int argc, char *argv[])
 
 out:
 	HAL_DEBUG (("An error occured, exiting cleanly"));
+
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/addons/addon-storage.c b/hald/linux/addons/addon-storage.c
index 383b9b8..3acc963 100644
--- a/hald/linux/addons/addon-storage.c
+++ b/hald/linux/addons/addon-storage.c
@@ -157,7 +157,7 @@ unmount_cleartext_devices (LibHalContext *ctx, const char *udi)
 		for (i = 0; i < num_clear_devices; i++) {
 			char *clear_udi;
 			clear_udi = clear_devices[i];
-			dbus_error_init (&error);
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			if (libhal_device_get_property_bool (ctx, clear_udi, "volume.is_mounted", &error)) {
 				HAL_DEBUG (("Forcing unmount of child '%s' (crypto)", clear_udi));
 				force_unmount (ctx, clear_udi);
@@ -166,6 +166,7 @@ unmount_cleartext_devices (LibHalContext *ctx, const char *udi)
 		libhal_free_string_array (clear_devices);
 	}
 
+	LIBHAL_FREE_DBUS_ERROR (&error);
 	return ret;
 }
 
@@ -178,22 +179,22 @@ unmount_childs (LibHalContext *ctx, const char *udi)
 
 	/* need to force unmount all partitions */
 	dbus_error_init (&error);
-	if ((volumes = libhal_manager_find_device_string_match (
-		     ctx, "block.storage_device", udi, &num_volumes, &error)) != NULL) {
+	if ((volumes = libhal_manager_find_device_string_match (ctx, "block.storage_device", udi, &num_volumes, &error)) != NULL) {
 		int i;
 
 		for (i = 0; i < num_volumes; i++) {
 			char *vol_udi;
 
 			vol_udi = volumes[i];
-			dbus_error_init (&error);
+			LIBHAL_FREE_DBUS_ERROR (&error);
+
 			if (libhal_device_get_property_bool (ctx, vol_udi, "block.is_volume", &error)) {
 				dbus_bool_t is_crypto;
 
 				/* unmount all cleartext devices associated with us */
 				is_crypto = unmount_cleartext_devices (ctx, vol_udi);
 
-				dbus_error_init (&error);
+				LIBHAL_FREE_DBUS_ERROR (&error);
 				if (libhal_device_get_property_bool (ctx, vol_udi, "volume.is_mounted", &error)) {
 					HAL_DEBUG (("Forcing unmount of child '%s'", vol_udi));
 					force_unmount (ctx, vol_udi);
@@ -215,12 +216,12 @@ unmount_childs (LibHalContext *ctx, const char *udi)
 						goto teardown_failed;
 					}
 
-					dbus_error_init (&error);
+					LIBHAL_FREE_DBUS_ERROR (&error);
+
 					if (!(reply = dbus_connection_send_with_reply_and_block (
 						      libhal_ctx_get_dbus_connection (ctx), msg, -1, &error)) || 
 					    dbus_error_is_set (&error)) {
-						HAL_DEBUG (("Teardown failed for %s: %s : %s\n", 
-						     udi, error.name, error.message));
+						HAL_DEBUG (("Teardown failed for %s: %s : %s\n", udi, error.name, error.message));
 						dbus_error_free (&error);
 					}
 
@@ -236,6 +237,7 @@ unmount_childs (LibHalContext *ctx, const char *udi)
 		}
 		libhal_free_string_array (volumes);
 	}
+	LIBHAL_FREE_DBUS_ERROR (&error);
 }
 
 /** Check if a filesystem on a special device file is mounted
@@ -357,14 +359,17 @@ poll_for_media (gpointer user_data)
                         HAL_INFO (("... device %s is locked on HAL", device_file));
                         is_locked_by_hal = TRUE;
                         update_proc_title ();
+			LIBHAL_FREE_DBUS_ERROR (&error);
                         goto skip_check;
                 } else {
                         HAL_INFO (("... device %s is not locked on HAL", device_file));
                         is_locked_by_hal = FALSE;
                 }
 
-                dbus_error_init (&error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
+
                 should_poll = libhal_device_get_property_bool (ctx, udi, "storage.media_check_enabled", &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		polling_disabled = !should_poll;
 		update_proc_title ();
         }
@@ -484,6 +489,7 @@ poll_for_media_force (void)
 				/* emit signal from drive device object */
 				dbus_error_init (&error);
 				libhal_device_emit_condition (ctx, udi, "EjectPressed", "", &error);
+				LIBHAL_FREE_DBUS_ERROR (&error);
 			}
 		}
 		close (fd);
@@ -524,6 +530,7 @@ poll_for_media_force (void)
 			/* could have a fs on the main block device; do a rescan to remove it */
 			dbus_error_init (&error);
 			libhal_device_rescan (ctx, udi, &error);
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			
 			/* have to this to trigger appropriate hotplug events */
 			fd = open (device_file, O_RDONLY | O_NONBLOCK);
@@ -547,7 +554,7 @@ poll_for_media_force (void)
 			/* could have a fs on the main block device; do a rescan to add it */
 			dbus_error_init (&error);
 			libhal_device_rescan (ctx, udi, &error);
-			
+			LIBHAL_FREE_DBUS_ERROR (&error);
 		}
 		break;
 		
@@ -604,6 +611,7 @@ get_system_idle_from_ck (void)
        ret = TRUE;
 
 error:
+       LIBHAL_FREE_DBUS_ERROR (&error);
        return ret;
 }
 #endif /* HAVE_CONKIT */
@@ -720,12 +728,10 @@ main (int argc, char *argv[])
 	dbus_connection_setup_with_g_main (con, NULL);
 	dbus_connection_set_exit_on_disconnect (con, 0);
 
-	dbus_error_init (&error);
 	if ((ctx_direct = libhal_ctx_init_direct (&error)) == NULL) {
 		HAL_ERROR (("Cannot connect to hald"));
                 goto out;
 	}
-	dbus_error_init (&error);
 	if (!libhal_device_addon_is_ready (ctx_direct, udi, &error)) {
                 goto out;
 	}
@@ -735,14 +741,11 @@ main (int argc, char *argv[])
 	dbus_connection_add_filter (con_direct, direct_filter_function, NULL, NULL);
 
 
-	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
 		goto out;
 
-	dbus_error_init (&error);
-	if (!libhal_device_addon_is_ready (ctx, udi, &error)) {
+	if (!libhal_device_addon_is_ready (ctx, udi, &error))
 		goto out;
-	}
 
 	HAL_DEBUG (("**************************************************"));
 	HAL_DEBUG (("Doing addon-storage for %s (bus %s) (drive_type %s) (udi %s)", device_file, bus, drive_type, udi));
@@ -818,9 +821,13 @@ main (int argc, char *argv[])
 	g_main_loop_run (loop);
 
 out:
+	HAL_DEBUG (("An error occured, exiting cleanly"));
+
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/addons/addon-usb-csr.c b/hald/linux/addons/addon-usb-csr.c
index 3ffd8a7..c43fa6d 100644
--- a/hald/linux/addons/addon-usb-csr.c
+++ b/hald/linux/addons/addon-usb-csr.c
@@ -79,31 +79,44 @@ property_cache_item_get (const char *hal_device_udi)
 
 	pci->bus_no_present = libhal_device_property_exists (halctx, hal_device_udi, 
 			"usb_device.bus_number", &err);
-	if (dbus_error_is_set (&err))
+
+	if (dbus_error_is_set (&err)) {
 		HAL_ERROR (("Error: [%s]/[%s]", err.name, err.message));	
+		dbus_error_free (&err);
+	}
 
 	if (pci->bus_no_present)
 		pci->bus_no = libhal_device_get_property_int (halctx, hal_device_udi, 
 			"usb_device.bus_number", &err);
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	pci->port_no_present = libhal_device_property_exists (halctx, hal_device_udi, 
 			"usb_device.linux.device_number", &err);
+
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	if (pci->port_no_present)
 		pci->port_no = libhal_device_get_property_int (halctx, hal_device_udi, 
 			"usb_device.linux.device_number", &err);
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	pci->csr_is_dual_present = libhal_device_property_exists (halctx, hal_device_udi,
 			"battery.csr.is_dual",  &err);
+
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	if (pci->csr_is_dual_present)
 		pci->csr_is_dual = libhal_device_get_property_bool (halctx, hal_device_udi,
 			"battery.csr.is_dual",  &err);
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	pci->current_charge_present = libhal_device_property_exists (halctx, hal_device_udi, 
 			"battery.charge_level.current", &err);
+
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	if (pci->current_charge_present)
 		pci->current_charge = libhal_device_get_property_int (halctx, hal_device_udi, 
 			"battery.charge_level.current", &err);
 
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	return pci;
 }
 
@@ -150,9 +163,13 @@ check_battery (const char *hal_device_udi, PropertyCacheItem *pci)
 
 			HAL_DEBUG (("Charge level: %d->%d", pci->current_charge, current_charge));
 			if (current_charge != pci->current_charge) { 
-				pci->current_charge = current_charge; dbus_error_init (&err);
+				pci->current_charge = current_charge; 
+				dbus_error_init (&err);
+
 		 		libhal_device_set_property_int (halctx, hal_device_udi, 
 		 			"battery.charge_level.current", current_charge, &err);
+				LIBHAL_FREE_DBUS_ERROR (&err);
+
 		 		if (current_charge != 0) {
 		 			percentage = (100.0 / 7.0) * current_charge;
 		 			libhal_device_set_property_int (halctx, hal_device_udi, 
@@ -161,10 +178,14 @@ check_battery (const char *hal_device_udi, PropertyCacheItem *pci)
 					libhal_device_remove_property(halctx, hal_device_udi,
 								      "battery.charge_level.percentage", &err);	
 				}
+
+				LIBHAL_FREE_DBUS_ERROR (&err);
 			}
 		}
-	} else
+	} else {
 		perror ("Writing to USB device");
+	}
+
 	usb_close (handle);
 }
 
@@ -266,6 +287,7 @@ int
 main (int argc, char *argv[])
 {
 	DBusError err;
+	int retval = 0;
 
 	hal_set_proc_title_init (argc, argv);
 
@@ -282,24 +304,33 @@ main (int argc, char *argv[])
 	dbus_error_init (&err);
 	if ((halctx = libhal_ctx_init_direct (&err)) == NULL) {
 		HAL_ERROR (("Cannot connect to hald"));
-		return -3;
+		retval = -3;
+		goto out;
 	}
 
 
 	/* update_properties */
-	dbus_error_init (&err);
 	libhal_device_set_property_bool (halctx, device_udi, 
 			"battery.present", TRUE, &err);
+
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	if (!libhal_device_property_exists (halctx, device_udi, 
-			"battery.is_rechargeable", &err))
+			"battery.is_rechargeable", &err)) {
+		LIBHAL_FREE_DBUS_ERROR (&err);
 		libhal_device_set_property_bool (halctx, device_udi, 
 			"battery.is_rechargeable", FALSE, &err);
+	}
+
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	libhal_device_set_property_int (halctx, device_udi, 
 			"battery.charge_level.design", 7, &err);
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	libhal_device_set_property_int (halctx, device_udi, 
 			"battery.charge_level.last_full", 7, &err);
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	libhal_device_set_property_string (halctx, device_udi, 
 			"info.category", "battery", &err);
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	libhal_device_set_property_string (halctx, device_udi, 
 			"battery.command_interface", "csr", &err);
 
@@ -317,12 +348,13 @@ main (int argc, char *argv[])
 	check_all_batteries (NULL);
 
 	/* only add capability when initial charge_level key has been set */
-	dbus_error_init (&err);
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	libhal_device_add_capability (halctx, device_udi, "battery", &err);
 
-	dbus_error_init (&err);
+	LIBHAL_FREE_DBUS_ERROR (&err);
 	if (!libhal_device_addon_is_ready (halctx, device_udi, &err)) {
-		return -4;
+		retval = -4;
+		goto out;
 	}
 
 	hal_set_proc_title ("hald-addon-usb-csr: listening on '%s'", 
@@ -336,8 +368,18 @@ main (int argc, char *argv[])
 	g_timeout_add (1000L * TIMEOUT, check_all_batteries, NULL);
 #endif
 	g_main_loop_run (main_loop);
-
-	libhal_ctx_shutdown (halctx, &err);
-	HAL_ERROR (("** Addon exits normally"));
 	return 0;
+
+out:
+        HAL_DEBUG (("An error occured, exiting cleanly"));
+
+        LIBHAL_FREE_DBUS_ERROR (&err);
+
+        if (halctx != NULL) {
+                libhal_ctx_shutdown (halctx, &err);
+                LIBHAL_FREE_DBUS_ERROR (&err);
+                libhal_ctx_free (halctx);
+        }
+
+        return retval;
 }
commit b27f1ec6041879031b4e301852a91241ca5c9553
Author: Frederic Crozat <fcrozat at mandriva.com>
Date:   Fri Jul 24 15:11:41 2009 +0200

    hide Windows recovery partitions on pre-installed Futjisu laptops
    
    Hide Windows recovery partitions on pre-installed Futjisu laptops.

diff --git a/fdi/policy/10osvendor/20-storage-methods.fdi b/fdi/policy/10osvendor/20-storage-methods.fdi
index 1978e97..462a2a8 100644
--- a/fdi/policy/10osvendor/20-storage-methods.fdi
+++ b/fdi/policy/10osvendor/20-storage-methods.fdi
@@ -129,6 +129,10 @@
 	<match key="volume.label" string_outof="IBM_SERVICE;SERVICEV001;SERVICEV002">
 	  <merge key="volume.ignore" type="bool">true</merge>
 	</match>
+        <!-- Fujitsu ships laptops with a recovery partitions -->
+	<match key="volume.label" string="WinRE">
+	  <merge key="volume.ignore" type="bool">true</merge>
+	</match>
       </match>
 
       <!-- ignore the following MBR partition types (EFI, hidden, etc.) 
commit e6f4d1039b4be94d5e113a86d9bb5e6e7fe5f74b
Author: C. Scott Ananian <cscott at litl.com>
Date:   Fri Jul 24 11:28:19 2009 +0200

    remove action_parameters from DBus XML for IsCallerPrivileged
    
    This argument (which was missing its "direction" attribute in
    any case) was added in commit e4b6fcb2 and incompletely removed
    in commit f2b9797c. This patch finishes the job.

diff --git a/hald/hald_dbus.c b/hald/hald_dbus.c
index 1700930..6d76bb4 100644
--- a/hald/hald_dbus.c
+++ b/hald/hald_dbus.c
@@ -4644,7 +4644,6 @@ do_introspect (DBusConnection  *connection,
 				       "    </method>\n"
 				       "    <method name=\"IsCallerPrivileged\">\n"
 				       "      <arg name=\"action\" direction=\"in\" type=\"s\"/>\n"
-                                       "      <arg name=\"action_parameters\" type=\"as\"/>\n"
 				       "      <arg name=\"caller_sysbus_name\" direction=\"in\" type=\"s\"/>\n"
 				       "      <arg name=\"result\" direction=\"out\" type=\"s\"/>\n"
 				       "    </method>\n"
commit d792a792846f9632edfdea3651a74fcd24b2ead7
Author: Johannes Hessellund <osos at openeyes.dk>
Date:   Fri Jul 24 11:25:02 2009 +0200

    read brightness from actual_brightness and not from brightness
    
    The get_backlight function read from the wrong sysfs file.
    The real backlight value is available from 'actual_brightness', whereas
    'brightness' is used for changing/setting the backlight through software.
    'brightness' always reads last value writen to it.
    Backlight which is hardware controlled, as with many thinkpads (ex T42), does
    not update 'brightness'. Thus hald is not returning the right value!
    
    fd.o#21612

diff --git a/hald/linux/addons/addon-generic-backlight.c b/hald/linux/addons/addon-generic-backlight.c
index 952a369..fd2d8f5 100644
--- a/hald/linux/addons/addon-generic-backlight.c
+++ b/hald/linux/addons/addon-generic-backlight.c
@@ -64,7 +64,7 @@ get_backlight ()
 	f = NULL;
 	value = -1;
 
-	g_snprintf (sysfs_path, sizeof (sysfs_path), "%s/brightness", path);
+	g_snprintf (sysfs_path, sizeof (sysfs_path), "%s/actual_brightness", path);
 
 	f = fopen (sysfs_path, "rb");
         if (f == NULL) {
commit 2f27038f80b534ab60d9666ffd78863a53f71061
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Jul 24 11:17:48 2009 +0200

    replace deprecated g_strcasecmp() with g_ascii_strcasecmp()
    
    Replaced deprecated g_strcasecmp() with g_ascii_strcasecmp().

diff --git a/hald/linux/addons/addon-cpufreq.c b/hald/linux/addons/addon-cpufreq.c
index f8d29ab..1d66e23 100644
--- a/hald/linux/addons/addon-cpufreq.c
+++ b/hald/linux/addons/addon-cpufreq.c
@@ -180,7 +180,7 @@ static gchar **read_line_str_split(char *filename, gchar *delim)
 		return NULL;
 
 	for (i = 0; l[i] != NULL; i++) {
-		if (g_strcasecmp(l[i], "") == 0) {
+		if (g_ascii_strcasecmp(l[i], "") == 0) {
 			free(l[i]);
 			l[i] = NULL;
 		}
diff --git a/hald/linux/addons/addon-usb-csr.c b/hald/linux/addons/addon-usb-csr.c
index fbb2254..3ffd8a7 100644
--- a/hald/linux/addons/addon-usb-csr.c
+++ b/hald/linux/addons/addon-usb-csr.c
@@ -188,13 +188,13 @@ find_device (PropertyCacheItem *pci)
 	for (curr_bus = usb_busses; curr_bus != NULL; curr_bus = curr_bus->next) {
  		struct usb_device *curr_device;
 		/* dbg ("Checking bus: [%s]", curr_bus->dirname); */
-		if (g_strcasecmp (LUdirname, curr_bus->dirname))
+		if (g_ascii_strcasecmp (LUdirname, curr_bus->dirname))
 			continue;
 
  		for (curr_device = curr_bus->devices; curr_device != NULL; 
 		     curr_device = curr_device->next) {
 			/* dbg ("Checking port: [%s]", curr_device->filename); */
-			if (g_strcasecmp (LUfname, curr_device->filename))
+			if (g_ascii_strcasecmp (LUfname, curr_device->filename))
 				continue;
 			HAL_DEBUG (("Matched device: [%s][%s][%04X:%04X]", curr_bus->dirname, 
 				curr_device->filename, 
commit a5bb489c0b91242cda4e6d691600023b5e0d1838
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Jul 24 09:50:12 2009 +0200

    replace another deprecated g_basename() with g_path_get_basename()
    
    Replaced deprecated g_basename() with g_path_get_basename().

diff --git a/hald/hald_dbus.c b/hald/hald_dbus.c
index 268b3cc..1700930 100644
--- a/hald/hald_dbus.c
+++ b/hald/hald_dbus.c
@@ -4269,9 +4269,12 @@ hald_exec_method (HalDevice *d, CICallerInfo *ci, DBusConnection *connection, db
                 /* caller may, or may not, be in a session.. if he is, export the session he belongs to... */
                 ck_session_path = ci_tracker_caller_get_ck_session_path (ci);
                 if (ck_session_path != NULL) {
-                        sprintf (ck_session_path_export, "HAL_METHOD_INVOKED_BY_SESSION=%s", 
-                                 g_basename (ck_session_path));
+			char * basename;
+
+			basename = g_path_get_basename (ck_session_path); 
+                        sprintf (ck_session_path_export, "HAL_METHOD_INVOKED_BY_SESSION=%s", basename);
                         extra_env[n++] = ck_session_path_export;
+			g_free (basename);
                 }
 #endif /* HAVE_CONKIT */
 	}
diff --git a/tools/hal-disable-polling.c b/tools/hal-disable-polling.c
index 83c770a..4aea90c 100644
--- a/tools/hal-disable-polling.c
+++ b/tools/hal-disable-polling.c
@@ -86,6 +86,7 @@ main (int argc, char *argv[])
         LibHalContext *hal_ctx;
         FILE *f;
         char *filename;
+	char *basename;
 
 	if (argc <= 1) {
 		usage (argc, argv);
@@ -234,8 +235,11 @@ main (int argc, char *argv[])
                 return 1;
         }
 
+
+	basename = g_path_get_basename (udi); 
         filename = g_strdup_printf (PACKAGE_SYSCONF_DIR "/hal/fdi/information/media-check-disable-%s.fdi",
-                                    g_basename (udi));
+                                    basename);
+	g_free (basename);
 
         if (enable_polling) {
                 if (libhal_device_get_property_bool (hal_ctx, udi, "storage.media_check_enabled", NULL)) {
commit ebde6620515a64af75a05b280ceedf943e235917
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 19:43:26 2009 +0200

    replace deprecated g_basename() with g_path_get_basename()
    
    Replaced deprecated g_basename() with g_path_get_basename().

diff --git a/hald/access-check.c b/hald/access-check.c
index b664ef6..93fa1a7 100644
--- a/hald/access-check.c
+++ b/hald/access-check.c
@@ -116,11 +116,19 @@ static PolKitSeat *
 get_pk_seat_from_ck_seat (CKSeat *seat)
 {
         char *str;
+	char *seat_id;
         PolKitSeat *pk_seat;
+
+
         pk_seat = polkit_seat_new ();
-        str = g_strdup_printf ("/org/freedesktop/ConsoleKit/%s", ck_seat_get_id (seat));
+	seat_id = ck_seat_get_id (seat);
+
+        str = g_strdup_printf ("/org/freedesktop/ConsoleKit/%s", seat_id );
         polkit_seat_set_ck_objref (pk_seat, str);
+
         g_free (str);
+	g_free (seat_id);
+
         return pk_seat;
 }
 
@@ -128,11 +136,14 @@ static PolKitSession *
 get_pk_session_from_ck_session (CKSession *session)
 {
         char *str;
+	char *ck_session_id;
         CKSeat *seat;
         PolKitSeat *pk_seat;
         PolKitSession *pk_session;
 
         seat = ck_session_get_seat (session);
+	ck_session_id = ck_session_get_id (session);
+
         if (seat == NULL) {
                 pk_seat = NULL;
         } else {
@@ -144,7 +155,7 @@ get_pk_session_from_ck_session (CKSession *session)
                 polkit_session_set_seat (pk_session, pk_seat);
                 polkit_seat_unref (pk_seat);
         }
-        str = g_strdup_printf ("/org/freedesktop/ConsoleKit/%s", ck_session_get_id (session));
+        str = g_strdup_printf ("/org/freedesktop/ConsoleKit/%s", ck_session_id );
         polkit_session_set_ck_objref (pk_session, str);
         g_free (str);
         polkit_session_set_uid (pk_session, ck_session_get_user (session));
@@ -153,6 +164,8 @@ get_pk_session_from_ck_session (CKSession *session)
         if (!ck_session_is_local (session)) {
                 polkit_session_set_ck_remote_host (pk_session, ck_session_get_hostname (session));
         }
+
+	g_free (ck_session_id);
         return pk_session;
 }
 
diff --git a/hald/ck-tracker.c b/hald/ck-tracker.c
index 5d6513b..ae41b10 100644
--- a/hald/ck-tracker.c
+++ b/hald/ck-tracker.c
@@ -767,10 +767,10 @@ ck_seat_get_sessions (CKSeat *seat)
 	return seat->sessions;
 }
 
-const char *
+char *
 ck_seat_get_id (CKSeat *seat)
 {
-	return g_basename (seat->seat_objpath);
+	return g_path_get_basename (seat->seat_objpath);
 }
 
 gboolean
@@ -785,10 +785,10 @@ ck_session_get_seat (CKSession *session)
 	return session->seat;
 }
 
-const char *
+char *
 ck_session_get_id (CKSession *session)
 {
-	return g_basename (session->session_objpath);
+	return g_path_get_basename (session->session_objpath);
 }
 
 uid_t
diff --git a/hald/ck-tracker.h b/hald/ck-tracker.h
index 33fe4b3..a99812d 100644
--- a/hald/ck-tracker.h
+++ b/hald/ck-tracker.h
@@ -84,11 +84,11 @@ GSList     *ck_tracker_get_sessions               (CKTracker *tracker);
 CKSession  *ck_tracker_find_session               (CKTracker *tracker, const char *ck_session_objpath);
 
 GSList     *ck_seat_get_sessions                  (CKSeat *seat);
-const char *ck_seat_get_id                        (CKSeat *seat);
+char 	   *ck_seat_get_id                        (CKSeat *seat);
 
 gboolean    ck_session_is_active                  (CKSession *session);
 CKSeat     *ck_session_get_seat                   (CKSession *session);
-const char *ck_session_get_id                     (CKSession *session);
+char 	   *ck_session_get_id                     (CKSession *session);
 uid_t       ck_session_get_user                   (CKSession *session);
 gboolean    ck_session_is_local                   (CKSession *session);
 const char *ck_session_get_hostname               (CKSession *session);
diff --git a/hald/hald_dbus.c b/hald/hald_dbus.c
index eeac31d..268b3cc 100644
--- a/hald/hald_dbus.c
+++ b/hald/hald_dbus.c
@@ -5649,15 +5649,17 @@ hald_dbus_session_active_changed (CKTracker *tracker, CKSession *session, void *
 {
 	HalDevice *d;
 	char **programs;
+	char *session_id;
 	char *extra_env[5] = {"HALD_ACTION=session_active_changed", 
 			      NULL /* "HALD_SESSION_ACTIVE_CHANGED_SESSION_ID=" */,
 			      NULL /* "HALD_SESSION_ACTIVE_CHANGED_SESSION_UID=" */,
 			      NULL /* "HALD_SESSION_ACTIVE_CHANGED_SESSION_IS_ACTIVE=" */,
 			      NULL};
 
+	session_id = ck_session_get_id (session);
+
 	HAL_INFO (("In hald_dbus_session_active_changed for session '%s': %s", 
-		   ck_session_get_id (session),
-		   ck_session_is_active (session) ? "ACTIVE" : "INACTIVE"));
+		   session_id, ck_session_is_active (session) ? "ACTIVE" : "INACTIVE"));
 
         /* revalidate all locks (to remove locks from callers in that session who no longer has access to devices */
         validate_locks ();
@@ -5678,13 +5680,14 @@ hald_dbus_session_active_changed (CKTracker *tracker, CKSession *session, void *
 		goto out;
 	}
 
-	extra_env[1] = g_strdup_printf ("HALD_SESSION_ACTIVE_CHANGED_SESSION_ID=%s", ck_session_get_id (session));
+	extra_env[1] = g_strdup_printf ("HALD_SESSION_ACTIVE_CHANGED_SESSION_ID=%s", session_id);
 	extra_env[2] = g_strdup_printf ("HALD_SESSION_ACTIVE_CHANGED_SESSION_UID=%u", ck_session_get_user (session));
 	extra_env[3] = g_strdup_printf ("HALD_SESSION_ACTIVE_CHANGED_SESSION_IS_ACTIVE=%s", 
 					ck_session_is_active (session) ? "true" : "false");
 
         session_changes_push (d, programs, extra_env);
 
+	g_free (session_id);
 	g_free (extra_env[1]);
 	g_free (extra_env[2]);
 	g_free (extra_env[3]);
@@ -5697,15 +5700,18 @@ hald_dbus_session_added (CKTracker *tracker, CKSession *session, void *user_data
 {
 	HalDevice *d;
 	char **programs;
+	char *session_id;
+	char *seat_id;
 	char *extra_env[5] = {"HALD_ACTION=session_add", 
 			      NULL /* "HALD_SESSION_ADD_SESSION_ID=" */,
 			      NULL /* "HALD_SESSION_ADD_SESSION_UID=" */,
 			      NULL /* "HALD_SESSION_ADD_SESSION_IS_ACTIVE=" */,
 			      NULL};
-
+	session_id = ck_session_get_id (session);
+	seat_id = ck_seat_get_id (ck_session_get_seat (session));
+	
 	HAL_INFO (("In hald_dbus_session_added for session '%s' on seat '%s'", 
-		   ck_session_get_id (session),
-		   ck_session_get_seat (session) != NULL ? ck_seat_get_id (ck_session_get_seat (session)) : "(NONE)"));
+		   session_id, ck_session_get_seat (session) != NULL ? seat_id : "(NONE)"));
 
 	d = hal_device_store_find (hald_get_gdl (), "/org/freedesktop/Hal/devices/computer");
 	if (d == NULL) {
@@ -5720,13 +5726,15 @@ hald_dbus_session_added (CKTracker *tracker, CKSession *session, void *user_data
 		goto out;
 	}
 
-	extra_env[1] = g_strdup_printf ("HALD_SESSION_ADD_SESSION_ID=%s", ck_session_get_id (session));
+	extra_env[1] = g_strdup_printf ("HALD_SESSION_ADD_SESSION_ID=%s", session_id );
 	extra_env[2] = g_strdup_printf ("HALD_SESSION_ADD_SESSION_UID=%u", ck_session_get_user (session));
 	extra_env[3] = g_strdup_printf ("HALD_SESSION_ADD_SESSION_IS_ACTIVE=%s", 
 					ck_session_is_active (session) ? "true" : "false");
 
         session_changes_push (d, programs, extra_env);
 
+	g_free (session_id);
+	g_free (seat_id);
 	g_free (extra_env[1]);
 	g_free (extra_env[2]);
 	g_free (extra_env[3]);
@@ -5738,6 +5746,8 @@ static void
 hald_dbus_session_removed (CKTracker *tracker, CKSession *session, void *user_data)
 {
 	HalDevice *d;
+	char *session_id;
+	char *seat_id;
 	char **programs;
 	char *extra_env[5] = {"HALD_ACTION=session_remove", 
 			      NULL /* "HALD_SESSION_REMOVE_SESSION_ID=" */,
@@ -5745,9 +5755,11 @@ hald_dbus_session_removed (CKTracker *tracker, CKSession *session, void *user_da
 			      NULL /* "HALD_SESSION_REMOVE_SESSION_IS_ACTIVE=" */,
 			      NULL};
 
+	session_id = ck_session_get_id (session);
+	seat_id = ck_seat_get_id (ck_session_get_seat (session));
+
 	HAL_INFO (("In hald_dbus_session_removed for session '%s' on seat '%s'", 
-		   ck_session_get_id (session),
-		   ck_session_get_seat (session) != NULL ? ck_seat_get_id (ck_session_get_seat (session)) : "(NONE)"));
+		   session_id, ck_session_get_seat (session) != NULL ? seat_id : "(NONE)"));
 
 	d = hal_device_store_find (hald_get_gdl (), "/org/freedesktop/Hal/devices/computer");
 	if (d == NULL) {
@@ -5762,13 +5774,15 @@ hald_dbus_session_removed (CKTracker *tracker, CKSession *session, void *user_da
 		goto out;
 	}
 
-	extra_env[1] = g_strdup_printf ("HALD_SESSION_REMOVE_SESSION_ID=%s", ck_session_get_id (session));
+	extra_env[1] = g_strdup_printf ("HALD_SESSION_REMOVE_SESSION_ID=%s", session_id );
 	extra_env[2] = g_strdup_printf ("HALD_SESSION_REMOVE_SESSION_UID=%d", ck_session_get_user (session));
 	extra_env[3] = g_strdup_printf ("HALD_SESSION_REMOVE_SESSION_IS_ACTIVE=%s", 
 					ck_session_is_active (session) ? "true" : "false");
 
         session_changes_push (d, programs, extra_env);
 
+	g_free (session_id);
+	g_free (seat_id);
 	g_free (extra_env[1]);
 	g_free (extra_env[2]);
 	g_free (extra_env[3]);
diff --git a/hald/hald_runner.c b/hald/hald_runner.c
index 0f5315f..f21e300 100644
--- a/hald/hald_runner.c
+++ b/hald/hald_runner.c
@@ -405,7 +405,7 @@ add_basic_env (DBusMessageIter * iter, const gchar * udi)
 			GSList *j;
 			CKSeat *seat;
 			GSList *sessions;
-			const char *seat_id;
+			char *seat_id;
 			GString *sessions_string;
                         int num_sessions;
 
@@ -484,6 +484,7 @@ add_basic_env (DBusMessageIter * iter, const gchar * udi)
                         add_env (iter, s, p);
                         g_free (p);
 			g_free (s);
+			g_free (seat_id);
 
 		}
 
commit d73988e9617a729c33039b016afb7ee60c00753b
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 19:12:47 2009 +0200

    fix usage of deprected g_io_channel_seek()
    
    Fixed usage of deprected g_io_channel_seek(), replaced
    it with g_io_channel_seek_position().

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 69ba026..310b3cc 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1910,13 +1910,16 @@ blockdev_process_mdstat (void)
         GSList *i;
         GSList *j;
         GSList *k;
+	GError *gerror = NULL;
 
         channel = get_mdstat_channel ();
         if (channel == NULL)
                 goto error;
 
-        if (g_io_channel_seek (channel, 0, G_SEEK_SET) != G_IO_ERROR_NONE) {
+        if (g_io_channel_seek_position (channel, 0, G_SEEK_SET, &gerror) == G_IO_STATUS_ERROR) {
                 HAL_ERROR (("Cannot seek in /proc/mdstat"));
+		if (gerror != NULL) 
+			g_error_free(gerror);
                 goto error;
         }
 
commit 33d8d09e81e9949b1023ddd67dcebe502a19d9bd
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 18:46:34 2009 +0200

    free string after usage
    
    Free string with libhal_free_string() after usage.

diff --git a/hald/linux/addons/addon-rfkill-killswitch.c b/hald/linux/addons/addon-rfkill-killswitch.c
index 553ab89..a6fb54d 100644
--- a/hald/linux/addons/addon-rfkill-killswitch.c
+++ b/hald/linux/addons/addon-rfkill-killswitch.c
@@ -178,6 +178,7 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 	}  
 
 	action = g_strdup_printf ("org.freedesktop.hal.killswitch.%s", type);
+	libhal_free_string (type);
 	
 	if (!check_priv (ctx, connection, message, dbus_message_get_path (message), action)) {
 		HAL_DEBUG(("User don't have the permissions to call the interface"));
commit 673c66ea89bd44bc98a376906573fcafe27161e6
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 15:15:06 2009 +0200

    fix DBusError handling in probe directory
    
    Fixed DBusError handling in probe directory:
    - free DBusError if a potential error happend (use
      LIBHAL_FREE_DBUS_ERROR() where possible)
    - don't use dbus_error_init() to free DBusError, use
      dbus_error_free()/LIBHAL_FREE_DBUS_ERROR() instead
    - removed unused DBusError variables

diff --git a/hald/linux/probing/probe-hiddev.c b/hald/linux/probing/probe-hiddev.c
index fbc1861..45d2084 100644
--- a/hald/linux/probing/probe-hiddev.c
+++ b/hald/linux/probing/probe-hiddev.c
@@ -137,7 +137,7 @@ main (int argc, char *argv[])
 	if (fork () == 0) {
 		sleep (10);
 
-		dbus_error_init (&error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		if ((conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error)) == NULL)
 			goto out;
 		
@@ -161,9 +161,11 @@ out:
 	if (fd >= 0)
 		close (fd);
 
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/probing/probe-input.c b/hald/linux/probing/probe-input.c
index 14b22b4..94e9929 100644
--- a/hald/linux/probing/probe-input.c
+++ b/hald/linux/probing/probe-input.c
@@ -113,7 +113,6 @@ main (int argc, char *argv[])
 		goto out;
 	}
 
-	dbus_error_init (&error);
 	libhal_device_set_property_bool (ctx, udi, "button.state.value", test_bit (sw, bitmask), &error);
 	
 	ret = 0;
@@ -122,9 +121,11 @@ out:
 	if (fd >= 0)
 		close (fd);
 
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/probing/probe-net-bluetooth.c b/hald/linux/probing/probe-net-bluetooth.c
index ec4cd25..0b1b912 100644
--- a/hald/linux/probing/probe-net-bluetooth.c
+++ b/hald/linux/probing/probe-net-bluetooth.c
@@ -52,9 +52,7 @@ get_properties (DBusConnection *conn, LibHalChangeSet *cs,
 
 	dbus_error_init (&error);
 
-	msg = dbus_message_new_method_call (id, path,
-										BLUEZ_NET_CONNECTION_IFACE,
-										"GetInfo");
+	msg = dbus_message_new_method_call (id, path, BLUEZ_NET_CONNECTION_IFACE, "GetInfo");
 
 	if (msg == NULL)
 		goto out;
@@ -62,8 +60,7 @@ get_properties (DBusConnection *conn, LibHalChangeSet *cs,
 	HAL_INFO (("%s.GetInfo()", BLUEZ_NET_CONNECTION_IFACE));
 	reply = dbus_connection_send_with_reply_and_block (conn, msg, -1, &error);
 
-	if (dbus_error_is_set (&error) || dbus_set_error_from_message (&error,
-		reply)) {
+	if (dbus_error_is_set (&error) || dbus_set_error_from_message (&error, reply)) {
 		dbus_error_free (&error);
 		goto out;
 	}
@@ -165,8 +162,7 @@ main (int argc, char *argv[])
 		goto out;
 
 	HAL_INFO (("%s.ActivateService('%s')", BLUEZ_MANAGER_IFACE, pnetwork));
-	dbus_message_append_args (msg, DBUS_TYPE_STRING, &pnetwork,
-								DBUS_TYPE_INVALID);
+	dbus_message_append_args (msg, DBUS_TYPE_STRING, &pnetwork, DBUS_TYPE_INVALID);
 	reply = dbus_connection_send_with_reply_and_block (conn, msg, -1, &error);
 
 	if (dbus_error_is_set (&error) || dbus_set_error_from_message (&error, reply)) {
@@ -198,8 +194,7 @@ main (int argc, char *argv[])
 							DBUS_TYPE_INVALID);
 	reply = dbus_connection_send_with_reply_and_block (conn, msg, -1, &error);
 
-	if (dbus_error_is_set (&error) || dbus_set_error_from_message (&error,
-		reply)) {
+	if (dbus_error_is_set (&error) || dbus_set_error_from_message (&error, reply)) {
 		dbus_error_free (&error);
 		goto out;
 	}
@@ -207,8 +202,7 @@ main (int argc, char *argv[])
 	dbus_message_unref (msg);
 	msg = NULL;
 
-	dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &connection,
-							DBUS_TYPE_INVALID);
+	dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &connection, DBUS_TYPE_INVALID);
 	if (dbus_error_is_set (&error)) {
 		dbus_error_free (&error);
 		goto out;
@@ -231,14 +225,18 @@ out:
 		dbus_message_unref (msg);
 	if (reply)
 		dbus_message_unref (reply);
+
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (cs != NULL) {
-		dbus_error_init (&error);
 		libhal_device_commit_changeset (ctx, cs, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_device_free_changeset (cs);
 	}
+
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/probing/probe-printer.c b/hald/linux/probing/probe-printer.c
index bec6e9b..91ed7bc 100644
--- a/hald/linux/probing/probe-printer.c
+++ b/hald/linux/probing/probe-printer.c
@@ -132,29 +132,35 @@ main (int argc, char *argv[])
 			cmd = *iter + 4;
 	}
 
-	dbus_error_init (&error);
-
 	if (mfg != NULL) {
 		libhal_device_set_property_string (ctx, udi, "info.vendor", mfg, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_device_set_property_string (ctx, udi, "printer.vendor", mfg, &error);
 	}		
 
 	if (model != NULL) {
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_device_set_property_string (ctx, udi, "info.product", model, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_device_set_property_string (ctx, udi, "printer.product", model, &error);
 	}
 
-	if (serial != NULL)
+	if (serial != NULL) {
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_device_set_property_string (ctx, udi, "printer.serial", serial, &error);
+	}
 
 	if (desc != NULL) {
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_device_set_property_string (ctx, udi, "printer.description", desc, &error);
 	}
 
 	if (cmd != NULL) {
 		char **cmdset = g_strsplit (cmd, ",", 0);
-		for (iter = cmdset; *iter != NULL; iter++)
+		for (iter = cmdset; *iter != NULL; iter++) {
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			libhal_device_property_strlist_append (ctx, udi, "printer.commandset", *iter, &error);
+		}
 		g_strfreev (cmdset);
 	}
 
@@ -166,9 +172,11 @@ out:
 	if (fd >= 0)
 		close (fd);
 
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/probing/probe-smbios.c b/hald/linux/probing/probe-smbios.c
index e6556f2..0bc9689 100644
--- a/hald/linux/probing/probe-smbios.c
+++ b/hald/linux/probing/probe-smbios.c
@@ -76,7 +76,9 @@ setstr (char *buf, char *str, char *prop)
 		if (strcmp (value, "Not Specified") == 0)
 			goto out;
 
-		libhal_device_set_property_string (ctx, udi, prop, value, &error);
+		if (!libhal_device_set_property_string (ctx, udi, prop, value, &error))
+			dbus_error_init (&error);
+
 		HAL_DEBUG (("Setting %s='%s'", prop, value));
 		return TRUE;
 	}
@@ -289,10 +291,12 @@ main (int argc, char *argv[])
 	fclose (f);
 
 out:
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	/* free ctx */
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/probing/probe-storage.c b/hald/linux/probing/probe-storage.c
index 1d08893..824a82e 100644
--- a/hald/linux/probing/probe-storage.c
+++ b/hald/linux/probing/probe-storage.c
@@ -526,14 +526,18 @@ main (int argc, char *argv[])
 
 	
 out:
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (cs != NULL) {
 		libhal_device_commit_changeset (ctx, cs, &error);
 		libhal_device_free_changeset (cs);
 	}
 
+	LIBHAL_FREE_DBUS_ERROR (&error);
+		
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/probing/probe-video4linux.c b/hald/linux/probing/probe-video4linux.c
index ffc2f37..cf913c0 100644
--- a/hald/linux/probing/probe-video4linux.c
+++ b/hald/linux/probing/probe-video4linux.c
@@ -88,18 +88,24 @@ main (int argc, char *argv[])
 		libhal_changeset_set_property_string (cset,
 		                                      "info.product", (const char *)v2cap.card);
 
-		if ((v2cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0)
+		if ((v2cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0) {
 			libhal_device_add_capability (ctx, udi, "video4linux.video_capture", &error);
-		if ((v2cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) > 0)
+		} if ((v2cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) > 0) {
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			libhal_device_add_capability (ctx, udi, "video4linux.video_output", &error);
-		if ((v2cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) > 0)
+		} if ((v2cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) > 0) {
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			libhal_device_add_capability (ctx, udi, "video4linux.video_overlay", &error);
-		if ((v2cap.capabilities & V4L2_CAP_AUDIO) > 0)
+		} if ((v2cap.capabilities & V4L2_CAP_AUDIO) > 0) {
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			libhal_device_add_capability (ctx, udi, "video4linux.audio", &error);
-		if ((v2cap.capabilities & V4L2_CAP_TUNER) > 0)
+		} if ((v2cap.capabilities & V4L2_CAP_TUNER) > 0) {
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			libhal_device_add_capability (ctx, udi, "video4linux.tuner", &error);
-		if ((v2cap.capabilities & V4L2_CAP_RADIO) > 0)
+		} if ((v2cap.capabilities & V4L2_CAP_RADIO) > 0) {
+			LIBHAL_FREE_DBUS_ERROR (&error);
 			libhal_device_add_capability (ctx, udi, "video4linux.radio", &error);
+		}
 	} else {
 		HAL_DEBUG (("ioctl VIDIOC_QUERYCAP failed"));
 
@@ -110,19 +116,25 @@ main (int argc, char *argv[])
 			libhal_changeset_set_property_string (cset,
 			                                      "info.product", v1cap.name);
 
-			if ((v1cap.type & VID_TYPE_CAPTURE) > 0)
+			if ((v1cap.type & VID_TYPE_CAPTURE) > 0) {
+				LIBHAL_FREE_DBUS_ERROR (&error);
 				libhal_device_add_capability (ctx, udi, "video4linux.video_capture", &error);
-			if ((v1cap.type & VID_TYPE_OVERLAY) > 0)
+			} if ((v1cap.type & VID_TYPE_OVERLAY) > 0) {
+				LIBHAL_FREE_DBUS_ERROR (&error);
 				libhal_device_add_capability (ctx, udi, "video4linux.video_overlay", &error);
-			if (v1cap.audios > 0)
+			} if (v1cap.audios > 0) {
+				LIBHAL_FREE_DBUS_ERROR (&error);
 				libhal_device_add_capability (ctx, udi, "video4linux.audio", &error);
-			if ((v1cap.type & VID_TYPE_TUNER) > 0)
+			} if ((v1cap.type & VID_TYPE_TUNER) > 0) {
+				LIBHAL_FREE_DBUS_ERROR (&error);
 				libhal_device_add_capability (ctx, udi, "video4linux.tuner", &error);
+			}
 		} else {
 			HAL_DEBUG (("ioctl VIDIOCGCAP failed"));
 		}
 	}
 
+	LIBHAL_FREE_DBUS_ERROR (&error);
 	libhal_device_commit_changeset (ctx, cset, &error);
 	libhal_device_free_changeset (cset);
 
@@ -134,9 +146,10 @@ out:
 	if (fd >= 0)
 		close (fd);
 
+	LIBHAL_FREE_DBUS_ERROR (&error);
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index 02c7d53..0de1b91 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -86,9 +86,6 @@ set_blkid_values (LibHalChangeSet *cs, blkid_probe pr)
 	const char *type_version;
 	const char *label;
 	const char *uuid;
-	DBusError error;
-
-	dbus_error_init (&error);
 
 	if (blkid_probe_lookup_value(pr, "USAGE", &usage, NULL))
 		usage = "";
@@ -161,9 +158,6 @@ advanced_disc_detect (LibHalChangeSet *cs, int fd, const char *device_file)
 	int curr_record = 1; 
 	/* loop counter */
 	int i; 
-	DBusError error;
-	
-	dbus_error_init (&error);
 	
 	/* set defaults */
 	libhal_changeset_set_property_bool (cs, "volume.disc.is_videodvd", FALSE);
@@ -796,6 +790,7 @@ out:
 		   char *values[4] = {"foo", "bar", "baz", NULL};
 		   libhal_changeset_set_property_strlist (cs, "foo.bar", values);
 		*/
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_device_commit_changeset (ctx, cs, &error);
 		libhal_device_free_changeset (cs);
 	}
@@ -804,9 +799,11 @@ out:
 	if (fd >= 0)
 		close (fd);
 
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
 	if (ctx != NULL) {
-		dbus_error_init (&error);
 		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
 		libhal_ctx_free (ctx);
 	}
 
commit 5ecca0209dcedf9a577483cd5098988150937c9c
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 15:13:20 2009 +0200

    fix probe-ieee1394-unit.c DBusError and LibHalContext handling
    
    Fixed probe-ieee1394-unit.c:
    - free DBusError on exit
    - shutdown and free LibHalContext on exit

diff --git a/hald/linux/probing/probe-ieee1394-unit.c b/hald/linux/probing/probe-ieee1394-unit.c
index 70facfd..70b0f86 100644
--- a/hald/linux/probing/probe-ieee1394-unit.c
+++ b/hald/linux/probing/probe-ieee1394-unit.c
@@ -442,5 +442,13 @@ int main (int argc, char *argv[])
 	ret = 0;
 
 out:
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
+        if (ctx != NULL) {
+                libhal_ctx_shutdown (ctx, &error);
+                LIBHAL_FREE_DBUS_ERROR (&error);
+                libhal_ctx_free (ctx);
+        }
+
 	return ret;
 }
commit 76197a7c5b475b1eaf0f77497d9b3e8c2da958aa
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 13:04:34 2009 +0200

    fix configure to get --disable-console-kit working
    
    Fixed configure to get --disable-console-kit working.

diff --git a/configure.in b/configure.in
index 082c9e8..c213345 100644
--- a/configure.in
+++ b/configure.in
@@ -511,7 +511,7 @@ AC_DEFINE_UNQUOTED(DBUS_API_SUBJECT_TO_CHANGE, [], [DBUS API is subject to chang
 
 # check for ConsoleKit
 AM_CONDITIONAL(HAVE_CONKIT, false)
-AC_ARG_ENABLE([console-kit], AS_HELP_STRING([--enable-console-kit], [Use ConsoleKit]), [enable_console_kit=$enableval,enable_console_kit=yes])
+AC_ARG_ENABLE([console-kit], AS_HELP_STRING([--enable-console-kit], [Use ConsoleKit]), [enable_console_kit=$enableval], [enable_console_kit=yes])
 msg_conkit=no
 if test "x$enable_console_kit" != "xno"; then
    AM_CONDITIONAL(HAVE_CONKIT, true)
commit 4c949a14457a889bc5b7d1c61d7c29f2365891e3
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 11:36:24 2009 +0200

    another DBusError fix
    
    Another DBusError fixes:
    - call dbus_error_free()

diff --git a/hald/util_helper_priv.c b/hald/util_helper_priv.c
index a62735e..37909ca 100644
--- a/hald/util_helper_priv.c
+++ b/hald/util_helper_priv.c
@@ -60,6 +60,7 @@ check_priv (LibHalContext *halctx, DBusConnection *connection, DBusMessage *mess
                                                        "Cannot determine if caller is privileged",
                                                        action, polkit_result);
                 dbus_connection_send (connection, reply, NULL);
+		dbus_error_free (&error);
                 goto out;
         }
         if (strcmp (polkit_result, "yes") != 0) {
commit f579a67a196d0fab0bf8f151698d90d4f1880f26
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 11:33:59 2009 +0200

    more DBusError fixes
    
    More DBusError fixes:
    - call dbus_error_free()

diff --git a/hald/hald_test.c b/hald/hald_test.c
index 21c8313..98e21dd 100644
--- a/hald/hald_test.c
+++ b/hald/hald_test.c
@@ -429,6 +429,7 @@ server_message_handler (DBusConnection *connection,
 			reply = dbus_message_new_error (message, "org.freedesktop.Hal.SyntaxError", "Syntax Error");
 			dbus_connection_send (connection, reply, NULL);
 			dbus_message_unref (reply);
+			dbus_error_free (&error)
 			passed = FALSE;			
 		} else {
 
@@ -535,6 +536,7 @@ main (int argc, char *argv[])
 	if ((server = dbus_server_listen ("unix:tmpdir=hald-test", &error)) == NULL) { 
 		printf ("Cannot create D-BUS server\n");
 		num_tests_failed++;
+		dbus_error_free (&error);
 		goto out;
 	}
 	printf ("server is listening at %s\n", dbus_server_get_address (server));
diff --git a/hald/hald_test_libhal.c b/hald/hald_test_libhal.c
index c6390de..ba495cc 100644
--- a/hald/hald_test_libhal.c
+++ b/hald/hald_test_libhal.c
@@ -75,6 +75,7 @@ send_tests_done (DBusConnection *conn, dbus_bool_t passed)
 		dbus_message_unref (message);
 		fprintf (stderr, "%s %d : Error sending message: %s: %s\n", 
 			 __FILE__, __LINE__, error.name, error.message);
+		dbus_error_free (&error);
 		return;
 	}
 
@@ -112,14 +113,14 @@ check_libhal (const char *server_addr)
 		dbus_error_init (&error);
 		if ((conn = dbus_connection_open (server_addr, &error)) == NULL) {
 			printf ("Error connecting to server: %s\n", error.message);
-			/* TODO: handle */
+			goto fail;
 		}
 
 		dbus_connection_setup_with_g_main (conn, NULL);
 
 		if ((ctx = libhal_ctx_new ()) == NULL) {
 			printf ("Error getting libhal context\n");
-			/* TODO: handle */
+			goto fail;
 		}
 
 		
@@ -364,7 +365,9 @@ check_libhal (const char *server_addr)
 		passed = TRUE;
 		
 	fail:
-
+		if (dbus_error_is_set (&error))
+			dbus_error_free (&error);
+			
 		send_tests_done (conn, passed);
 		exit (1);
 
commit 6901227c2cfcf5da8250c247a36f69566109d682
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 11:26:03 2009 +0200

    ck-tracker.c: fix usage of DBusError
    
    Fixed usage of DBusError:
    - free DBusError before return from a function

diff --git a/hald/ck-tracker.c b/hald/ck-tracker.c
index eb76dbb..5d6513b 100644
--- a/hald/ck-tracker.c
+++ b/hald/ck-tracker.c
@@ -276,6 +276,8 @@ ck_session_get_info (CKTracker *tracker, CKSession *session)
 	ret = TRUE;
 
 error:
+	if (dbus_error_is_set (&error))
+		dbus_error_free (&error);
 	return ret;
 }
 
@@ -344,6 +346,9 @@ ck_tracker_init_get_sessions_for_seat (CKTracker *tracker, CKSeat *seat)
 	ret = TRUE;
 
 error:
+	if (dbus_error_is_set (&error))
+		dbus_error_free (&error);
+
 	return ret;
 }
 
@@ -419,6 +424,9 @@ ck_tracker_init_get_seats_and_sessions (CKTracker *tracker)
 
 	ret = TRUE;
 error:
+	if (dbus_error_is_set (&error))
+		dbus_error_free (&error);
+
 	return ret;
 }
 
commit 1188923241aa045233a0ef5f745e97f70d243a59
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 11:22:57 2009 +0200

    ci-tracker.c: fix usage of DBusError
    
    Fixed usage of DBusError:
    - free DBusError before return from a function

diff --git a/hald/ci-tracker.c b/hald/ci-tracker.c
index 085e0d8..a1354bb 100644
--- a/hald/ci-tracker.c
+++ b/hald/ci-tracker.c
@@ -315,6 +315,7 @@ ci_tracker_get_info (CITracker *cit, const char *system_bus_unique_name)
 		dbus_message_unref (message);
 		if (reply != NULL)
 			dbus_message_unref (reply);
+		dbus_error_free (&error);
 		goto error;
 	}
 	dbus_message_iter_init (reply, &iter);
@@ -341,6 +342,7 @@ ci_tracker_get_info (CITracker *cit, const char *system_bus_unique_name)
                 dbus_message_unref (message);
                 if (reply != NULL)
                         dbus_message_unref (reply);
+		dbus_error_free (&error);
                 goto error;
         } else {
                 /* TODO: verify signature */
@@ -368,6 +370,7 @@ ci_tracker_get_info (CITracker *cit, const char *system_bus_unique_name)
 		if (reply != NULL)
 			dbus_message_unref (reply);
 		/* OK, this is not a catastrophe; just means the caller is not a member of any session.. */
+		dbus_error_free (&error);
 		goto store_caller_info;
 	}
 	dbus_message_iter_init (reply, &iter);
@@ -387,6 +390,7 @@ ci_tracker_get_info (CITracker *cit, const char *system_bus_unique_name)
 		dbus_message_unref (message);
 		if (reply != NULL)
 			dbus_message_unref (reply);
+		dbus_error_free (&error);
 		goto error;
 	}
 	dbus_message_iter_init (reply, &iter);
@@ -406,6 +410,7 @@ ci_tracker_get_info (CITracker *cit, const char *system_bus_unique_name)
 		dbus_message_unref (message);
 		if (reply != NULL)
 			dbus_message_unref (reply);
+		dbus_error_free (&error);
 		goto error;
 	}
 	dbus_message_iter_init (reply, &iter);
commit ece9d2f7024fcfb9535313688bfaab30ac8c3ce6
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 11:18:26 2009 +0200

    hald_runner.c: fix usage of DBusError
    
    Fixed usage of DBusError:
    - free DBusError before return from a function

diff --git a/hald/hald_runner.c b/hald/hald_runner.c
index c8bec82..0f5315f 100644
--- a/hald/hald_runner.c
+++ b/hald/hald_runner.c
@@ -140,6 +140,8 @@ runner_server_message_handler (DBusConnection * connection,
 					break;
 				}
 			}
+		} else {
+			dbus_error_free (&error);
 		}
 	} else if (dbus_message_is_signal (message,
 					   DBUS_INTERFACE_LOCAL,
@@ -255,7 +257,8 @@ hald_runner_start_runner (void)
 	dbus_error_init (&err);
 	runner_server = dbus_server_listen (DBUS_SERVER_ADDRESS, &err);
 	if (runner_server == NULL) {
-		HAL_ERROR (("Cannot create D-BUS server for the runner"));
+		HAL_ERROR (("Cannot create D-BUS server for the runner: %s:%s", err.name, err.message));
+		dbus_error_free (&err);
 		goto error;
 	}
 
@@ -626,9 +629,8 @@ runner_start (HalDevice * device, const gchar * command_line,
 	}
 
 	/* Wait for the reply, should be almost instantanious */
-	reply =
-	    dbus_connection_send_with_reply_and_block (runner_connection,
-						       msg, -1, &error);
+	reply = dbus_connection_send_with_reply_and_block (runner_connection,
+							   msg, -1, &error);
 	if (reply) {
 		gboolean ret =
 		    (dbus_message_get_type (reply) ==
@@ -660,6 +662,7 @@ runner_start (HalDevice * device, const gchar * command_line,
 				}
 			} else {
 				HAL_ERROR (("Error extracting out_pid from runner's Start()"));
+				dbus_error_free (&error);
 			}
 		}
 
@@ -669,10 +672,11 @@ runner_start (HalDevice * device, const gchar * command_line,
 	} else {
 		if (dbus_error_is_set (&error)) {
 			HAL_ERROR (("Error running '%s': %s: %s", command_line, error.name, error.message));
+			dbus_error_free (&error);
 		}
 	}
 
-      error:
+error:
 	dbus_message_unref (msg);
 	return FALSE;
 }
@@ -880,6 +884,7 @@ hald_runner_run_sync (HalDevice * device,
 	if (reply == NULL) {
 		if (dbus_error_is_set (&error)) {
 			HAL_ERROR (("Error running '%s': %s: %s", command_line, error.name, error.message));
+			dbus_error_free (&error);
 		}
 		goto error;
 	}
@@ -927,11 +932,12 @@ hald_runner_kill_device (HalDevice * device)
 
 	/* Wait for the reply, should be almost instantanious */
 	dbus_error_init (&err);
-	reply =
-	    dbus_connection_send_with_reply_and_block (runner_connection,
-						       msg, -1, &err);
+	reply = dbus_connection_send_with_reply_and_block (runner_connection,
+							   msg, -1, &err);
 	if (reply) {
 		dbus_message_unref (reply);
+	} else {
+		dbus_error_free (&err);
 	}
 
 	dbus_message_unref (msg);
@@ -957,6 +963,8 @@ hald_runner_kill_all (void)
 						       msg, -1, &err);
 	if (reply) {
 		dbus_message_unref (reply);
+	} else {
+		dbus_error_free (&err);
 	}
 
 	dbus_message_unref (msg);
commit 46ddaa8c16eb35c8f07ab1ce6522c0002723df57
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Jul 23 11:08:54 2009 +0200

    hald_dbus.c: fix DBusError handling
    
    Fixed DBusError handling in hald_dbus.c:
    - call dbus_error_free() before return form a function
    - removed unused DBusError variables.

diff --git a/hald/hald_dbus.c b/hald/hald_dbus.c
index adc2bc6..eeac31d 100644
--- a/hald/hald_dbus.c
+++ b/hald/hald_dbus.c
@@ -558,8 +558,9 @@ manager_find_device_string_match (DBusConnection * connection,
 				    DBUS_TYPE_STRING, &key,
 				    DBUS_TYPE_STRING, &value,
 				    DBUS_TYPE_INVALID)) {
-		raise_syntax (connection, message,
-			      "Manager.FindDeviceStringMatch");
+		raise_syntax (connection, message, "Manager.FindDeviceStringMatch");
+		dbus_error_free (&error);
+
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -648,8 +649,9 @@ manager_find_device_by_capability (DBusConnection * connection,
 	if (!dbus_message_get_args (message, &error,
 				    DBUS_TYPE_STRING, &capability,
 				    DBUS_TYPE_INVALID)) {
-		raise_syntax (connection, message,
-			      "Manager.FindDeviceByCapability");
+		raise_syntax (connection, message, "Manager.FindDeviceByCapability");
+		dbus_error_free (&error);
+
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -710,6 +712,9 @@ manager_device_exists (DBusConnection * connection, DBusMessage * message)
 				    DBUS_TYPE_STRING, &udi,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "Manager.DeviceExists");
+		
+		dbus_error_free (&error);
+
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -1442,6 +1447,7 @@ device_get_property (DBusConnection * connection, DBusMessage * message)
 				    DBUS_TYPE_STRING, &key,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "GetProperty");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -1576,6 +1582,7 @@ device_get_property_type (DBusConnection * connection,
 				    DBUS_TYPE_STRING, &key,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "GetPropertyType");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -1785,6 +1792,7 @@ device_add_capability (DBusConnection * connection, DBusMessage * message, dbus_
 				    DBUS_TYPE_STRING, &capability,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "AddCapability");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -1834,6 +1842,7 @@ device_string_list_append_prepend (DBusConnection * connection, DBusMessage * me
 				    DBUS_TYPE_STRING, &value,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, do_prepend ? "StringListPrepend" : "StringListAppend");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -1888,6 +1897,7 @@ device_string_list_remove (DBusConnection * connection, DBusMessage * message)
 				    DBUS_TYPE_STRING, &value,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "StringListRemove");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -1959,6 +1969,7 @@ device_remove_property (DBusConnection * connection, DBusMessage * message, dbus
 				    DBUS_TYPE_STRING, &key,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "RemoveProperty");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2024,6 +2035,7 @@ device_property_exists (DBusConnection * connection, DBusMessage * message)
 				    DBUS_TYPE_STRING, &key,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "RemoveProperty");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2090,6 +2102,7 @@ device_query_capability (DBusConnection * connection,
 				    DBUS_TYPE_STRING, &capability,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "QueryCapability");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2150,6 +2163,7 @@ device_acquire_interface_lock (DBusConnection *connection, DBusMessage *message,
 				    DBUS_TYPE_BOOLEAN, &exclusive,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "AqcuireInterfaceLock");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2206,6 +2220,7 @@ device_release_interface_lock (DBusConnection *connection, DBusMessage *message,
 				    DBUS_TYPE_STRING, &interface_name,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "ReleaseInterfaceLock");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2267,6 +2282,7 @@ device_is_caller_locked_out (DBusConnection *connection, DBusMessage *message, d
 				    DBUS_TYPE_STRING, &caller_sysbus_name,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "IsCallerLockedOut");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2295,7 +2311,6 @@ device_is_caller_privileged (DBusConnection *connection, DBusMessage *message, d
 	const char *udi;
 	HalDevice *d;
 	DBusMessage *reply;
-	DBusError error;
 	const char *sender;
 	char *action;
 	char *caller_sysbus_name;
@@ -2323,7 +2338,6 @@ device_is_caller_privileged (DBusConnection *connection, DBusMessage *message, d
 		return DBUS_HANDLER_RESULT_HANDLED;
         }
 
-	dbus_error_init (&error);
         dbus_message_iter_init (message, &iter);
         dbus_message_iter_get_basic (&iter, &action);
         dbus_message_iter_next (&iter);
@@ -2429,6 +2443,7 @@ device_is_locked_by_others (DBusConnection *connection, DBusMessage *message, db
 				    DBUS_TYPE_STRING, &interface_name,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "IsLockedByOthers");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2492,6 +2507,7 @@ device_acquire_global_interface_lock (DBusConnection *connection, DBusMessage *m
 				    DBUS_TYPE_BOOLEAN, &exclusive,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "AqcuireGlobalInterfaceLock");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2554,6 +2570,7 @@ device_release_global_interface_lock (DBusConnection *connection, DBusMessage *m
 				    DBUS_TYPE_STRING, &interface_name,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "ReleaseGlobalInterfaceLock");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2678,6 +2695,7 @@ device_lock (DBusConnection * connection,
 				    DBUS_TYPE_STRING, &reason,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "Lock");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -2754,6 +2772,7 @@ device_unlock (DBusConnection *connection,
 	if (!dbus_message_get_args (message, &error,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "Unlock");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -3202,6 +3221,7 @@ device_emit_condition (DBusConnection * connection, DBusMessage * message, dbus_
 				    DBUS_TYPE_STRING, &condition_details,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "EmitCondition");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -3272,6 +3292,7 @@ device_claim_interface (DBusConnection * connection, DBusMessage * message, dbus
 				    DBUS_TYPE_STRING, &introspection_xml,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "ClaimInterface");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -3341,6 +3362,7 @@ addon_is_ready (DBusConnection * connection, DBusMessage * message, dbus_bool_t
 	if (!dbus_message_get_args (message, &error,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "AddonIsReady");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -3438,7 +3460,6 @@ reply_from_singleton_device_changed (DBusPendingCall *pending_call,
 static void
 singleton_signal_device_changed (DBusConnection *connection, HalDevice *device, gboolean added)
 {
-	DBusError error;
 	DBusMessage *message;
 	DBusMessageIter iter, iter_dict;
 	DBusPendingCall *pending_call;
@@ -3471,7 +3492,6 @@ singleton_signal_device_changed (DBusConnection *connection, HalDevice *device,
 	dbus_message_iter_close_container (&iter, &iter_dict);
 
 	HAL_DEBUG (("%s about to send message to connection %p", G_STRFUNC, connection));
-	dbus_error_init (&error);
 
 	if (dbus_connection_send_with_reply (connection,
 					     message,
@@ -3642,6 +3662,7 @@ singleton_addon_is_ready (DBusConnection * connection, DBusMessage * message, db
 				    DBUS_TYPE_STRING, &command_line,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "SingletonAddonIsReady");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -3692,14 +3713,11 @@ manager_new_device (DBusConnection * connection, DBusMessage * message, dbus_boo
 {
 	DBusMessage *reply;
 	DBusMessageIter iter;
-	DBusError error;
 	HalDevice *d;
 	gchar *udi;
 	int i;
 	struct timeval tv;
 
-	dbus_error_init (&error);
-
 	if (!local_interface && !access_check_message_caller_is_root_or_hal (ci_tracker, message)) {
 		raise_permission_denied (connection, message, "NewDevice: not privileged");
 		return DBUS_HANDLER_RESULT_HANDLED;
@@ -3777,6 +3795,7 @@ manager_remove (DBusConnection * connection, DBusMessage * message, dbus_bool_t
 				    DBUS_TYPE_STRING, &udi,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "Remove");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -3879,6 +3898,7 @@ manager_commit_to_gdl (DBusConnection * connection, DBusMessage * message, dbus_
 				    DBUS_TYPE_STRING, &udi0,
 				    DBUS_TYPE_INVALID)) {
 		raise_syntax (connection, message, "CommitToGdl");
+		dbus_error_free (&error);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
@@ -5414,7 +5434,8 @@ hald_dbus_local_server_init (void)
 	 */
 	dbus_error_init (&error);
 	if ((local_server = dbus_server_listen (HALD_DBUS_ADDRESS, &error)) == NULL) { 
-		HAL_ERROR (("Cannot create D-BUS server"));
+		HAL_ERROR (("Cannot create D-BUS server:  %s: %s", error.name, error.message));
+		dbus_error_free (&error);
 		goto out;
 	}
 	local_server_address = dbus_server_get_address (local_server);
@@ -5785,6 +5806,7 @@ hald_dbus_init_preprobe (void)
 	dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
 	if (dbus_connection == NULL) {
 		HAL_ERROR (("dbus_bus_get(): %s", dbus_error.message));
+		dbus_error_free (&dbus_error);
 		goto out;
 	}
 
@@ -5881,8 +5903,8 @@ hald_dbus_init (void)
 	dbus_error_init (&dbus_error);
 	dbus_bus_request_name (dbus_connection, "org.freedesktop.Hal", 0, &dbus_error);
 	if (dbus_error_is_set (&dbus_error)) {
-		HAL_ERROR (("dbus_bus_request_name(): %s",
-			    dbus_error.message));
+		HAL_ERROR (("dbus_bus_request_name(): %s", dbus_error.message));
+		dbus_error_free(&dbus_error);
 		return FALSE;
 	}
 
commit a9b34ec74e946c2b9a2cbd6a6d33ee0de7a95011
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Sat Jul 18 14:54:06 2009 +0200

    fix code doc for resolve_udiprop_path()
    
    Fixed code doc for resolve_udiprop_path() from commit
    1c508f890ff209aedbb33f45cb6ed8bb2ae93491

diff --git a/hald/device_info.c b/hald/device_info.c
index af689fd..b755018 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -202,9 +202,8 @@ out:
  *  @param  source_udi          UDI of source device
  *  @param  path                The given path
  *  @param  udi_result          Where to store the resulting UDI
- *  @param  udi_result_size     Size of UDI string
  *  @param  prop_result         Where to store the resulting property name
- *  @param  prop_result_size    Size of property string
+ *  @param  scratch		 
  *  @return                     TRUE if and only if the path resolved.
  */
 static gboolean
commit 9c6f93d2d92455a06fd0c528f11e02074d6c82c4
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Sat Jul 18 11:18:53 2009 +0200

    hide more MBR, bootstrap and other partitions from desktop
    
    Hide more MBR, bootstrap and other partitions from desktop.
    Info taken from DeviceKit-disk/udev.

diff --git a/fdi/policy/10osvendor/20-storage-methods.fdi b/fdi/policy/10osvendor/20-storage-methods.fdi
index 9a2223f..1978e97 100644
--- a/fdi/policy/10osvendor/20-storage-methods.fdi
+++ b/fdi/policy/10osvendor/20-storage-methods.fdi
@@ -92,6 +92,11 @@
           <merge key="volume.ignore" type="bool">true</merge>
 	</match>
       </match>
+      <match key="volume.partition.scheme" string="apm">
+	<match key="volume.partition.type" string_outof="Apple_Bootstrap">
+          <merge key="volume.ignore" type="bool">true</merge>
+        </match>
+      </match>
 
       <!-- EFI firmware partitions -->
       <match key="volume.fstype" string="vfat">
@@ -126,6 +131,24 @@
 	</match>
       </match>
 
+      <!-- ignore the following MBR partition types (EFI, hidden, etc.) 
+	   see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html 
+      -->
+      <match key="volume.partition.scheme" string="mbr">
+	<match key="volume.partition.type" string_outof="0x00;0x11;0x14;0x16;0x17;0x1b;0x1c;0x1e;0x27;0x3d;0x84;0x8d;0x90;0x91;0x92;0x93;0x97;0x98;0x9a;0x9b;0xbb;0xc2;0xc3;0xdd;0xef">
+	  <merge key="volume.ignore" type="bool">true</merge>
+        </match>
+      </match>
+
+      <!-- special GUID-identified partition types
+           see http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
+      -->
+      <match key="volume.partition.scheme" string="gpt">
+	<match key="volume.partition.type" string_outof="C12A7328-F81F-11D2-BA4B-00A0C93EC93B;21686148-6449-6E6F-744E-656564454649">
+	  <merge key="volume.ignore" type="bool">true</merge>
+        </match>
+      </match>
+
       <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Volume</append>
 
       <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Mount</append>
commit 368b690c5f32725077948b215ed7c9de4ac9d0a3
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Sat Jul 18 11:03:22 2009 +0200

    add IBM Ebus to SPEC
    
    Added IBM Ebus to SPEC.

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 0c09069..711ef3f 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -1748,6 +1748,41 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
       </informaltable>
     </sect2>
 
+    <sect2 id="device-properties-ibmebus">
+      <title>ibmebus namespace</title>
+      <para>
+	Devices on the BM Ebus are represented by device objects where 
+	<literal>info.subsystem</literal> equals <literal>ibmebus</literal>. 
+	The following properties are available for such device objects.
+      </para>
+      <informaltable>
+        <tgroup cols="2">
+          <thead>
+            <row>
+              <entry>Key (type)</entry>
+              <entry>Values</entry>
+              <entry>Mandatory</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>ibmebus.devspec</literal> (string)</entry>
+              <entry>example: /lhea at 23c00100/ethernet at 23e0010 </entry>
+              <entry>Yes</entry>
+              <entry>The IBM Ebus device spec.</entry>
+            </row>
+            <row>
+              <entry><literal>ibmebus.type</literal> (string)</entry>
+              <entry>example: </entry>
+              <entry>Yes</entry>
+              <entry>The type of IBM Ebus device</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </sect2>
+
     <sect2 id="device-properties-ide">
       <title>
         ide namespace
@@ -2961,7 +2996,7 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
     </sect2>
 
     <sect2 id="device-properties-ssb">
-      <title>xen namespace</title>
+      <title>ssb namespace</title>
       <para>
 	Devices on the Sonics Silicon Backplane (SSB) bus are represented by 
 	device objects where <literal>info.subsystem</literal> equals 
commit ff2cfa39bd4fa0d995ff755940cb2f125de6a1fb
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Sat Jul 18 10:37:53 2009 +0200

    cleanup: don't set udi manually if hal_device_set_udi() was used
    
    Cleaned up: Don't call
    
      hal_device_property_set_string (d, "info.udi", udi);
    
    if
    
      hal_device_set_udi (d, udi);
    
    was called before. hal_device_set_udi() already set info.udi for
    the device.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 2f5829e..d8c543d 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -793,7 +793,6 @@ ibmebus_compute_udi (HalDevice *d)
 			      "/org/freedesktop/Hal/devices/ibmebus%s",
 			      hal_device_property_get_string (d, "ibmebus.devspec"));
 	hal_device_set_udi (d, udi);
-	hal_device_property_set_string (d, "info.udi", udi);
 	return TRUE;
 }
 
@@ -1413,7 +1412,6 @@ memstick_compute_udi (HalDevice *d)
 			      "%s_memstick_card",
 			      hal_device_property_get_string (d, "info.parent"));
 	hal_device_set_udi (d, udi);
-	hal_device_property_set_string (d, "info.udi", udi);
 	return TRUE;
 
 }
@@ -1460,7 +1458,6 @@ memstick_host_compute_udi (HalDevice *d)
 			      "%s_memstick_host",
 			      hal_device_property_get_string (d, "info.parent"));
 	hal_device_set_udi (d, udi);
-	hal_device_property_set_string (d, "info.udi", udi);
 	return TRUE;
 }
 
@@ -3606,7 +3603,6 @@ ssb_compute_udi (HalDevice *d)
 			      "/org/freedesktop/Hal/devices/ssb_%s",
 			      hal_device_property_get_string (d, "ssb.bus_id"));
 	hal_device_set_udi (d, udi);
-	hal_device_property_set_string (d, "info.udi", udi);
 	return TRUE;
 }
 
commit 17a517e6e67f4e97a34ba105858b8b6c5c395d75
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Sat Jul 18 10:35:37 2009 +0200

    add SSB bus to SPEC
    
    Added SSB bus to SPEC.

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 6941354..0c09069 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2960,6 +2960,36 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
       </informaltable>
     </sect2>
 
+    <sect2 id="device-properties-ssb">
+      <title>xen namespace</title>
+      <para>
+	Devices on the Sonics Silicon Backplane (SSB) bus are represented by 
+	device objects where <literal>info.subsystem</literal> equals 
+	<literal>virtio</literal>. The following properties are available for 
+	such device objects.
+      </para>
+      <informaltable>
+        <tgroup cols="2">
+          <thead>
+            <row>
+              <entry>Key (type)</entry>
+              <entry>Values</entry>
+              <entry>Mandatory</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>ssb.bus_id</literal> (string)</entry>
+              <entry>example: </entry>
+              <entry>Yes</entry>
+              <entry>The SSB Bus ID of the device</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </sect2>
+
     <sect2 id="device-properties-usb">
       <title>
         usb_device namespace
commit 315145bacad24a125e4be12a46150e7a6e30ab92
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Sat Jul 18 10:02:43 2009 +0200

    move ssb bus code to the correct place
    
    Moved ssb bus code to the correct place to have device handler
    code in alphabetical order.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 81a9ffe..2f5829e 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -850,43 +850,6 @@ ide_compute_udi (HalDevice *d)
 /*--------------------------------------------------------------------------------------------------------------*/
 
 static HalDevice *
-ssb_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
-{
-	HalDevice *d;
-
-	d = hal_device_new ();
-	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
-	hal_device_property_set_string (d, "linux.sysfs_path_device", sysfs_path);
-	hal_device_property_set_string (d, "info.bus", "ssb");
-	if (parent_dev != NULL) {
-		hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
-	} else {
-		hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
-	}
-
-	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
-
-	hal_device_property_set_string (d, "ssb.bus_id",
-					hal_util_get_last_element (sysfs_path));
-	return d;
-}
-
-static gboolean
-ssb_compute_udi (HalDevice *d)
-{
-	gchar udi[256];
-
-	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
-			      "/org/freedesktop/Hal/devices/ssb_%s",
-			      hal_device_property_get_string (d, "ssb.bus_id"));
-	hal_device_set_udi (d, udi);
-	hal_device_property_set_string (d, "info.udi", udi);
-	return TRUE;
-}
-
-/*--------------------------------------------------------------------------------------------------------------*/
-
-static HalDevice *
 ieee1394_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
 {
 	HalDevice *d;
@@ -3613,6 +3576,43 @@ sound_compute_udi (HalDevice *d)
 /*--------------------------------------------------------------------------------------------------------------*/
 
 static HalDevice *
+ssb_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
+{
+	HalDevice *d;
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "linux.sysfs_path_device", sysfs_path);
+	hal_device_property_set_string (d, "info.bus", "ssb");
+	if (parent_dev != NULL) {
+		hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+	} else {
+		hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
+	}
+
+	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
+
+	hal_device_property_set_string (d, "ssb.bus_id",
+					hal_util_get_last_element (sysfs_path));
+	return d;
+}
+
+static gboolean
+ssb_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "/org/freedesktop/Hal/devices/ssb_%s",
+			      hal_device_property_get_string (d, "ssb.bus_id"));
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+	return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
 tape_add (const gchar *sysfs_path, const gchar *device_file, 
 	  HalDevice *parent_dev, const gchar *parent_path)
 {
@@ -4320,13 +4320,6 @@ static DevHandler dev_handler_bluetooth =
 	.remove       = dev_remove
 };
 
-static DevHandler dev_handler_ssb = {
-	.subsystem   = "ssb",
-	.add         = ssb_add,
-	.compute_udi = ssb_compute_udi,
-	.remove      = dev_remove
-};
-
 /* s390 specific busses */
 static DevHandler dev_handler_ccw = {
 	.subsystem   = "ccw",
@@ -4598,6 +4591,13 @@ static DevHandler dev_handler_sound =
 	.remove       = dev_remove
 };
 
+static DevHandler dev_handler_ssb = {
+	.subsystem   = "ssb",
+	.add         = ssb_add,
+	.compute_udi = ssb_compute_udi,
+	.remove      = dev_remove
+};
+
 static DevHandler dev_handler_tape =
 {
 	.subsystem    = "tape",
commit 682168ee421dbaa467f2b8cd1f15b38767d5d7d4
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Sat Jul 18 09:58:17 2009 +0200

    fixed commit 36d076bf26350e022731cb7c2c9f4e840dd25e37
    
    Fixed commit 36d076bf26350e022731cb7c2c9f4e840dd25e37.
    Don't use xen.bus_id for udi of a ssd device, the property
    don't exist there.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 5ebde5a..81a9ffe 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -878,7 +878,7 @@ ssb_compute_udi (HalDevice *d)
 
 	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
 			      "/org/freedesktop/Hal/devices/ssb_%s",
-			      hal_device_property_get_string (d, "xen.bus_id"));
+			      hal_device_property_get_string (d, "ssb.bus_id"));
 	hal_device_set_udi (d, udi);
 	hal_device_property_set_string (d, "info.udi", udi);
 	return TRUE;


More information about the hal-commit mailing list