From 82fdfef5942446638c831a0a8381c018376545c7 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 29 Jan 2009 08:34:16 +0000 Subject: set the retval of hal-device correctly on error At the moment hal-device always returns success. Only return success if a device was matched. --- tools/hal-device.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/hal-device.c b/tools/hal-device.c index e8bf3480..38458a5f 100644 --- a/tools/hal-device.c +++ b/tools/hal-device.c @@ -189,6 +189,7 @@ int dump_devices(LibHalContext *hal_ctx, char *arg) { int i; int num_devices; + int retval; char **device_names; DBusError error; char *udi = NULL; @@ -222,6 +223,9 @@ int dump_devices(LibHalContext *hal_ctx, char *arg) num_devices = 1; } + /* if _any_ device matches, we return success */ + retval = 1; + for(i = 0; i < num_devices; i++) { LibHalPropertySet *props; LibHalPropertySetIterator it; @@ -233,6 +237,9 @@ int dump_devices(LibHalContext *hal_ctx, char *arg) continue; } + /* we got some properties */ + retval = 0; + if (!udi) printf("%d: ", i); printf("udi = '%s'\n", device_names[i]); @@ -298,7 +305,7 @@ int dump_devices(LibHalContext *hal_ctx, char *arg) libhal_free_string_array(device_names); dbus_error_free(&error); - return 0; + return retval; } -- cgit v1.2.3