hal: Branch 'master' - 2 commits

Artem Kachitchkine artem at kemper.freedesktop.org
Thu Oct 12 13:35:01 PDT 2006


 tools/hal-device.c             |   10 +++++++---
 tools/hal_find_by_capability.c |    8 ++++++--
 tools/hal_find_by_property.c   |    8 ++++++--
 tools/hal_get_property.c       |    8 ++++++--
 tools/hal_set_property.c       |    8 ++++++--
 tools/lshal.c                  |   11 ++++++-----
 6 files changed, 37 insertions(+), 16 deletions(-)

New commits:
diff-tree d1ae80ff0d035ef059f276db20a3cb9c0e0d7360 (from parents)
Merge: c2053bf825cd9d81949d63ad83790a68310bb808 f46e98cc95db3c5256caef3a5b3022b35e8fb7f9
Author: Artem Kachitchkine <artem.kachitchkin at sun.com>
Date:   Thu Oct 12 13:34:40 2006 -0700

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

diff-tree c2053bf825cd9d81949d63ad83790a68310bb808 (from 02e3526e5b84ba1981bc6df31a152557d01b890a)
Author: Artem Kachitchkine <artem.kachitchkin at sun.com>
Date:   Thu Oct 12 10:03:08 2006 -0700

    do not let tools coredump if HAL is not running
    
    Make HAL tools actually fail with a useful message
    in case HAL not running on a system.

diff --git a/tools/hal-device.c b/tools/hal-device.c
index a37d2d6..3bbecd4 100644
--- a/tools/hal-device.c
+++ b/tools/hal-device.c
@@ -136,12 +136,16 @@ int main(int argc, char **argv)
 		return 2;
 	}
 
-	// fprintf(stderr, "connected to: %s\n", dbus_bus_get_unique_name(conn));
+	/* fprintf(stderr, "connected to: %s\n", dbus_bus_get_unique_name(conn)); */
 	if (!(hal_ctx = libhal_ctx_new())) return 3;
 	if (!libhal_ctx_set_dbus_connection(hal_ctx, conn)) return 4;
 	if (!libhal_ctx_init(hal_ctx, &error)) {
-		fprintf(stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set(&error)) {
+			fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
+			LIBHAL_FREE_DBUS_ERROR (&error);
+		}
+		fprintf (stderr, "Could not initialise connection to hald.\n"
+				 "Normally this means the HAL daemon (hald) is not running or not ready.\n");
 		return 5;
 	}
 
diff --git a/tools/hal_find_by_capability.c b/tools/hal_find_by_capability.c
index 20a7666..8433003 100644
--- a/tools/hal_find_by_capability.c
+++ b/tools/hal_find_by_capability.c
@@ -147,8 +147,12 @@ main (int argc, char *argv[])
 		return 1;
 	}
 	if (!libhal_ctx_init (hal_ctx, &error)) {
-		fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set(&error)) {
+			fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
+			LIBHAL_FREE_DBUS_ERROR (&error);
+		}
+		fprintf (stderr, "Could not initialise connection to hald.\n"
+				 "Normally this means the HAL daemon (hald) is not running or not ready.\n");
 		return 1;
 	}
 
diff --git a/tools/hal_find_by_property.c b/tools/hal_find_by_property.c
index f9344fd..09b1b55 100644
--- a/tools/hal_find_by_property.c
+++ b/tools/hal_find_by_property.c
@@ -154,8 +154,12 @@ main (int argc, char *argv[])
 		return 1;
 	}
 	if (!libhal_ctx_init (hal_ctx, &error)) {
-		fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set(&error)) {
+			fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
+			LIBHAL_FREE_DBUS_ERROR (&error);
+		}
+		fprintf (stderr, "Could not initialise connection to hald.\n"
+				 "Normally this means the HAL daemon (hald) is not running or not ready.\n");
 		return 1;
 	}
 
diff --git a/tools/hal_get_property.c b/tools/hal_get_property.c
index c2ec717..5145916 100644
--- a/tools/hal_get_property.c
+++ b/tools/hal_get_property.c
@@ -163,8 +163,12 @@ main (int argc, char *argv[])
 		return 1;
 	}
 	if (!libhal_ctx_init (hal_ctx, &error)) {
-		fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set(&error)) {
+			fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
+			LIBHAL_FREE_DBUS_ERROR (&error);
+		}
+		fprintf (stderr, "Could not initialise connection to hald.\n"
+				 "Normally this means the HAL daemon (hald) is not running or not ready.\n");
 		return 1;
 	}
 
diff --git a/tools/hal_set_property.c b/tools/hal_set_property.c
index eaeb7fc..78f24ee 100644
--- a/tools/hal_set_property.c
+++ b/tools/hal_set_property.c
@@ -230,8 +230,12 @@ main (int argc, char *argv[])
 		return 1;
 	}
 	if (!libhal_ctx_init (hal_ctx, &error)) {
-		fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set(&error)) {
+			fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
+			LIBHAL_FREE_DBUS_ERROR (&error);
+		}
+		fprintf (stderr, "Could not initialise connection to hald.\n"
+				 "Normally this means the HAL daemon (hald) is not running or not ready.\n");
 		return 1;
 	}
 
diff --git a/tools/lshal.c b/tools/lshal.c
index cb4fd15..c072858 100644
--- a/tools/lshal.c
+++ b/tools/lshal.c
@@ -682,11 +682,12 @@ main (int argc, char *argv[])
 		return 1;
 	}
 	if (!libhal_ctx_init (hal_ctx, &error)) {
-		fprintf (stderr, "error: libhal_ctx_init: %s: %s\n",
-			 error.name, error.message);
-		fprintf (stderr, "Could not initialise connection to hald. \n "
-				 "Normally this mean the HAL daemon (hald) is not running or not ready.\n");
-		LIBHAL_FREE_DBUS_ERROR (&error);
+		if (dbus_error_is_set(&error)) {
+			fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message);
+			LIBHAL_FREE_DBUS_ERROR (&error);
+		}
+		fprintf (stderr, "Could not initialise connection to hald.\n"
+				 "Normally this means the HAL daemon (hald) is not running or not ready.\n");
 		return 1;
 	}
 


More information about the hal-commit mailing list