@@ -1506,7 +1506,7 @@ lyd_create_attr(struct lyd_node *parent, struct lyd_attr **attr, const struct ly
15061506}
15071507
15081508ly_bool
1509- lyd_compare_schema_equal (const struct lysc_node * schema1 , const struct lysc_node * schema2 )
1509+ lyd_compare_schema_equal (const struct lysc_node * schema1 , const struct lysc_node * schema2 , ly_bool cmp_parents )
15101510{
15111511 if (!schema1 && !schema2 ) {
15121512 return 1 ;
@@ -1518,15 +1518,24 @@ lyd_compare_schema_equal(const struct lysc_node *schema1, const struct lysc_node
15181518 return (schema1 == schema2 ) ? 1 : 0 ;
15191519 }
15201520
1521- if (schema1 -> nodetype != schema2 -> nodetype ) {
1522- return 0 ;
1523- }
1521+ do {
1522+ if (schema1 -> nodetype != schema2 -> nodetype ) {
1523+ return 0 ;
1524+ }
15241525
1525- if (strcmp (schema1 -> name , schema2 -> name )) {
1526- return 0 ;
1527- }
1526+ if (strcmp (schema1 -> name , schema2 -> name )) {
1527+ return 0 ;
1528+ }
1529+
1530+ if (strcmp (schema1 -> module -> name , schema2 -> module -> name )) {
1531+ return 0 ;
1532+ }
1533+
1534+ schema1 = schema1 -> parent ;
1535+ schema2 = schema2 -> parent ;
1536+ } while (cmp_parents && schema1 && schema2 );
15281537
1529- if (strcmp (schema1 -> module -> name , schema2 -> module -> name )) {
1538+ if ((schema1 && ! schema2 ) || (! schema1 && schema2 )) {
15301539 return 0 ;
15311540 }
15321541
@@ -1552,7 +1561,7 @@ lyd_compare_schema_parents_equal(const struct lyd_node *node1, const struct lyd_
15521561 for (parent1 = node1 -> schema -> parent , parent2 = node2 -> schema -> parent ;
15531562 parent1 && parent2 ;
15541563 parent1 = parent1 -> parent , parent2 = parent2 -> parent ) {
1555- if (!lyd_compare_schema_equal (parent1 , parent2 )) {
1564+ if (!lyd_compare_schema_equal (parent1 , parent2 , 0 )) {
15561565 return 0 ;
15571566 }
15581567 }
@@ -1669,7 +1678,7 @@ lyd_compare_single_schema(const struct lyd_node *node1, const struct lyd_node *n
16691678 }
16701679 } else {
16711680 /* different contexts */
1672- if (!lyd_compare_schema_equal (node1 -> schema , node2 -> schema )) {
1681+ if (!lyd_compare_schema_equal (node1 -> schema , node2 -> schema , 0 )) {
16731682 return LY_ENOT ;
16741683 }
16751684 if (!parental_schemas_checked ) {
@@ -2369,7 +2378,7 @@ lyd_dup_get_local_parent(const struct lyd_node *node, const struct ly_ctx **trg_
23692378 iter = parent ;
23702379 repeat = 0 ;
23712380 } else if (parent && (LYD_CTX (parent ) != LYD_CTX (orig_parent )) &&
2372- lyd_compare_schema_equal (parent -> schema , orig_parent -> schema ) &&
2381+ lyd_compare_schema_equal (parent -> schema , orig_parent -> schema , 0 ) &&
23732382 lyd_compare_schema_parents_equal (parent , orig_parent )) {
23742383 iter = parent ;
23752384 repeat = 0 ;
@@ -3186,7 +3195,7 @@ lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *t
31863195 }
31873196
31883197 if ((siblings -> schema && target -> schema &&
3189- !lyd_compare_schema_equal (lysc_data_parent (siblings -> schema ), lysc_data_parent (target -> schema )))) {
3198+ !lyd_compare_schema_equal (lysc_data_parent (siblings -> schema ), lysc_data_parent (target -> schema ), 1 ))) {
31903199 /* schema mismatch */
31913200 if (match ) {
31923201 * match = NULL ;
@@ -3205,7 +3214,7 @@ lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *t
32053214 /* we must search the instances from beginning to find the first matching one */
32063215 found = 0 ;
32073216 for (lyd_find_sibling_val (siblings , target -> schema , NULL , 0 , & iter );
3208- iter && lyd_compare_schema_equal (iter -> schema , target -> schema );
3217+ iter && lyd_compare_schema_equal (iter -> schema , target -> schema , 0 );
32093218 iter = iter -> next ) {
32103219 if (!lyd_compare_single (target , iter , LYD_COMPARE_FULL_RECURSION )) {
32113220 found = 1 ;
0 commit comments