hal: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Mon Oct 9 17:33:56 PDT 2006


 hald/device.c      |    7 +++++--
 hald/device_info.c |   22 +++++++++++-----------
 2 files changed, 16 insertions(+), 13 deletions(-)

New commits:
diff-tree 5daaab35fb0917cdfc6f8a480e214ab76f564b56 (from 5742b5dbee411fb2df32053791dfc6ec0383bc94)
Author: David Zeuthen <davidz at redhat.com>
Date:   Mon Oct 9 20:32:58 2006 -0400

    switch device_info.c to use strlist iterator

diff --git a/hald/device.c b/hald/device.c
index 97005e1..2c77cef 100644
--- a/hald/device.c
+++ b/hald/device.c
@@ -349,8 +349,11 @@ gboolean
 hal_device_property_strlist_iter_is_valid (HalDeviceStrListIter *iter)
 {
 	g_return_val_if_fail (iter != NULL, FALSE);
-	g_return_val_if_fail (iter->i != NULL, FALSE);
-	return TRUE;
+	if (iter->i == NULL) {
+		return FALSE;
+	} else {
+		return TRUE;
+	}
 }
 
 char **
diff --git a/hald/device_info.c b/hald/device_info.c
index 1ccaa45..78ba7cf 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -579,12 +579,12 @@ handle_match (ParsingContext * pc, const
 			}
 		} else if (hal_device_property_get_type (d, prop_to_check) == HAL_PROPERTY_TYPE_STRLIST && 
 			   needle != NULL) {
-			guint i;
-			guint num_elems;
+			HalDeviceStrListIter iter;
 
-			num_elems = hal_device_property_get_strlist_length (d, prop_to_check);
-			for (i = 0; i < num_elems; i++) {
-				const char *str = hal_device_property_get_strlist_elem (d, prop_to_check, i);
+			for (hal_device_property_strlist_iter_init (d, prop_to_check, &iter);
+			     hal_device_property_strlist_iter_is_valid (&iter);
+			     hal_device_property_strlist_iter_next (&iter)) {
+				const char *str = hal_device_property_strlist_iter_get_value (&iter);
 				if (strcmp (str, needle) == 0) {
 					contains = TRUE;
 					break;
@@ -617,12 +617,12 @@ handle_match (ParsingContext * pc, const
 			}
 		} else if (hal_device_property_get_type (d, prop_to_check) == HAL_PROPERTY_TYPE_STRLIST && 
 			   needle != NULL) {
-			guint i;
-			guint num_elems;
-			
-			num_elems = hal_device_property_get_strlist_length (d, prop_to_check);
-			for (i = 0; i < num_elems; i++) {
-				const char *str = hal_device_property_get_strlist_elem (d, prop_to_check, i);
+			HalDeviceStrListIter iter;
+
+			for (hal_device_property_strlist_iter_init (d, prop_to_check, &iter);
+			     hal_device_property_strlist_iter_is_valid (&iter);
+			     hal_device_property_strlist_iter_next (&iter)) {
+				const char *str = hal_device_property_strlist_iter_get_value (&iter);
 				if (g_ascii_strcasecmp (str, needle) == 0) {
 					contains_ncase = TRUE;
 					break;


More information about the hal-commit mailing list