hal: Branch 'origin'

David Zeuthen david at kemper.freedesktop.org
Mon Feb 19 23:33:47 PST 2007


 tools/hal-storage-closetray.c |    8 ++++++--
 tools/hal-storage-eject.c     |    8 ++++++--
 tools/hal-storage-mount.c     |   16 ++++++++++++----
 tools/hal-storage-unmount.c   |    8 ++++++--
 4 files changed, 30 insertions(+), 10 deletions(-)

New commits:
diff-tree a7b41e73c214fa95a8ca2ab1805de5558251f599 (from e94e5d6bbe489a1269d0e2a5152a1a1f167c7674)
Author: David Zeuthen <davidz at redhat.com>
Date:   Mon Feb 19 03:27:03 2007 -0500

    clean up some dangerous use of the LIBHAL_FREE_DBUS_ERROR macro
    
    The problem is that it prints out to stderr and it broke this code
    
     if (libhal_device_get_property_bool (hal_ctx, udi, "volume.ignore", &error) ||
         dbus_error_is_set (&error)) {
             LIBHAL_FREE_DBUS_ERROR (&error);
             permission_denied_volume_ignore (device);
     }
    
    when volume.ignore was set to true.

diff --git a/tools/hal-storage-closetray.c b/tools/hal-storage-closetray.c
index 5e335a3..2d8f5de 100644
--- a/tools/hal-storage-closetray.c
+++ b/tools/hal-storage-closetray.c
@@ -102,7 +102,9 @@ main (int argc, char *argv[])
 	dbus_error_init (&error);
 	if ((hal_ctx = libhal_ctx_init_direct (&error)) == NULL) {
 		printf ("Cannot connect to hald\n");
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set (&error)) {
+			dbus_error_free (&error);
+		}
 		usage ();
 	}
 
@@ -110,7 +112,9 @@ main (int argc, char *argv[])
 	system_bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
 	if (system_bus == NULL) {
 		printf ("Cannot connect to the system bus\n");
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set (&error)) {
+			dbus_error_free (&error);
+		}
 		usage ();
 	}
 #ifdef HAVE_POLKIT
diff --git a/tools/hal-storage-eject.c b/tools/hal-storage-eject.c
index 65248f3..0364c5f 100644
--- a/tools/hal-storage-eject.c
+++ b/tools/hal-storage-eject.c
@@ -109,7 +109,9 @@ main (int argc, char *argv[])
 	dbus_error_init (&error);
 	if ((hal_ctx = libhal_ctx_init_direct (&error)) == NULL) {
 		printf ("Cannot connect to hald\n");
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set (&error)) {
+			dbus_error_free (&error);
+		}
 		usage ();
 	}
 
@@ -117,7 +119,9 @@ main (int argc, char *argv[])
 	system_bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
 	if (system_bus == NULL) {
 		printf ("Cannot connect to the system bus\n");
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set (&error)) {
+			dbus_error_free (&error);
+		}
 		usage ();
 	}
 #ifdef HAVE_POLKIT
diff --git a/tools/hal-storage-mount.c b/tools/hal-storage-mount.c
index a69cdb3..8a0131e 100644
--- a/tools/hal-storage-mount.c
+++ b/tools/hal-storage-mount.c
@@ -270,7 +270,9 @@ volume_findby (LibHalContext *hal_ctx, c
 	dbus_error_init (&error);
 	if ((hal_udis = libhal_manager_find_device_string_match (hal_ctx, property, 
 								 value, &num_hal_udis, &error)) == NULL) {
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set (&error)) {
+			dbus_error_free (&error);
+		}
 		goto out;
 	}
 	for (i = 0; i < num_hal_udis; i++) {
@@ -491,7 +493,9 @@ handle_mount (LibHalContext *hal_ctx, 
 		dbus_error_init (&error);
 		if (libhal_device_get_property_bool (hal_ctx, udi, "volume.ignore", &error) || 
 		    dbus_error_is_set (&error)) {
-			LIBHAL_FREE_DBUS_ERROR (&error);
+			if (dbus_error_is_set (&error)) {
+				dbus_error_free (&error);
+			}
 			permission_denied_volume_ignore (device);
 		}
 
@@ -1015,7 +1019,9 @@ main (int argc, char *argv[])
 	dbus_error_init (&error);
 	if ((hal_ctx = libhal_ctx_init_direct (&error)) == NULL) {
 		printf ("Cannot connect to hald\n");
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set (&error)) {
+			dbus_error_free (&error);
+		}
 		usage ();
 	}
 
@@ -1023,7 +1029,9 @@ main (int argc, char *argv[])
 	system_bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
 	if (system_bus == NULL) {
 		printf ("Cannot connect to the system bus\n");
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set (&error)) {
+			dbus_error_free (&error);
+		}
 		usage ();
 	}
 #ifdef HAVE_POLKIT
diff --git a/tools/hal-storage-unmount.c b/tools/hal-storage-unmount.c
index d1239f7..9476033 100644
--- a/tools/hal-storage-unmount.c
+++ b/tools/hal-storage-unmount.c
@@ -112,7 +112,9 @@ main (int argc, char *argv[])
 	dbus_error_init (&error);
 	if ((hal_ctx = libhal_ctx_init_direct (&error)) == NULL) {
 		printf ("Cannot connect to hald\n");
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set (&error)) {
+			dbus_error_free (&error);
+		}
 		usage ();
 	}
 
@@ -120,7 +122,9 @@ main (int argc, char *argv[])
 	system_bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
 	if (system_bus == NULL) {
 		printf ("Cannot connect to the system bus\n");
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set (&error)) {
+			dbus_error_free (&error);
+		}
 		usage ();
 	}
 #ifdef HAVE_POLKIT


More information about the hal-commit mailing list