summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2009-01-29 08:34:16 +0000
committerRichard Hughes <richard@hughsie.com>2009-01-29 08:34:16 +0000
commit82fdfef5942446638c831a0a8381c018376545c7 (patch)
tree0c134b9f35a9fa7297c0b35dce09c742d295d931
parent33b54318f73012e24220456216794dd3ff39fc93 (diff)
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.
-rw-r--r--tools/hal-device.c9
1 files changed, 8 insertions, 1 deletions
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;
}