aboutsummaryrefslogtreecommitdiff
blob: 60cf881b96f15112b281a3ed7eb8146e8c6cf4a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From 0d526db56322d39707afadcd1f4a5133b724287a Mon Sep 17 00:00:00 2001
From: Richard Hughes <richard@hughsie.com>
Date: Thu, 29 Jan 2009 08:34:16 +0000
Subject: [PATCH 45/48] 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 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tools/hal-device.c b/tools/hal-device.c
index e8bf348..38458a5 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;
 }
 
 
-- 
1.6.1.2