summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2006-10-09 20:32:58 -0400
committerDavid Zeuthen <davidz@redhat.com>2006-10-09 20:32:58 -0400
commit5daaab35fb0917cdfc6f8a480e214ab76f564b56 (patch)
treee56898fefd57e366bc41bb94836058a278b066a4
parent5742b5dbee411fb2df32053791dfc6ec0383bc94 (diff)
switch device_info.c to use strlist iterator
-rw-r--r--hald/device.c7
-rw-r--r--hald/device_info.c22
2 files changed, 16 insertions, 13 deletions
diff --git a/hald/device.c b/hald/device.c
index 97005e10..2c77cefe 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 1ccaa450..78ba7cf3 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -579,12 +579,12 @@ handle_match (ParsingContext * pc, const char **attr)
}
} 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 char **attr)
}
} 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;