Whamcloud - gitweb
LU-7734 lnet: configuration fixes
[fs/lustre-release.git] / lnet / utils / cyaml / cyaml.c
index a713566..de8804b 100644 (file)
@@ -687,19 +687,23 @@ static bool find_obj_iter(struct cYAML *node, void *usr_data, void **out)
 
 struct cYAML *cYAML_get_object_item(struct cYAML *parent, const char *name)
 {
-       struct cYAML *node;
+       struct cYAML *node = parent, *found = NULL;
 
-       if (parent == NULL || parent->cy_child == NULL || name == NULL)
+       if (!node || !name)
                return NULL;
 
-       node = parent->cy_child;
-
-       while (node != NULL &&
-               strcmp(node->cy_string, name) != 0) {
-               node = node->cy_next;
+       if (node->cy_string) {
+               if (strcmp(node->cy_string, name) == 0)
+                       return node;
        }
 
-       return node;
+       if (node->cy_child)
+               found = cYAML_get_object_item(node->cy_child, name);
+
+       if (!found && node->cy_next)
+               found = cYAML_get_object_item(node->cy_next, name);
+
+       return found;
 }
 
 struct cYAML *cYAML_get_next_seq_item(struct cYAML *seq, struct cYAML **itm)