data tree BUGFIX nodes may have when in their schema parent
Fixes sysrepo/sysrepo#2386
diff --git a/src/tree_data.c b/src/tree_data.c
index 4a8d5e9..c4e3013 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1905,10 +1905,10 @@
if (!(iter->flags & LYS_PRESENCE) && lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
/* create default NP container */
LY_CHECK_RET(lyd_create_inner(iter, &node));
- node->flags = LYD_DEFAULT | (lysc_node_when(node->schema) ? LYD_WHEN_TRUE : 0);
+ node->flags = LYD_DEFAULT | (lysc_has_when(iter) ? LYD_WHEN_TRUE : 0);
lyd_insert_node(parent, first, node);
- if (lysc_node_when(iter) && node_when) {
+ if (lysc_has_when(iter) && node_when) {
/* remember to resolve when */
LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
}
@@ -1935,10 +1935,10 @@
} else if (ret) {
return ret;
}
- node->flags = LYD_DEFAULT | (lysc_node_when(node->schema) ? LYD_WHEN_TRUE : 0);
+ node->flags = LYD_DEFAULT | (lysc_has_when(iter) ? LYD_WHEN_TRUE : 0);
lyd_insert_node(parent, first, node);
- if (lysc_node_when(iter) && node_when) {
+ if (lysc_has_when(iter) && node_when) {
/* remember to resolve when */
LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
}
@@ -1963,10 +1963,10 @@
} else if (ret) {
return ret;
}
- node->flags = LYD_DEFAULT | (lysc_node_when(node->schema) ? LYD_WHEN_TRUE : 0);
+ node->flags = LYD_DEFAULT | (lysc_has_when(iter) ? LYD_WHEN_TRUE : 0);
lyd_insert_node(parent, first, node);
- if (lysc_node_when(iter) && node_when) {
+ if (lysc_has_when(iter) && node_when) {
/* remember to resolve when */
LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
}
diff --git a/src/validation.c b/src/validation.c
index 22f6c7c..75ada9e 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -1342,7 +1342,7 @@
LY_CHECK_RET(lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, NULL, NULL, impl_opts, diff));
}
- if (lysc_node_when(node->schema)) {
+ if (lysc_has_when(node->schema)) {
/* when evaluation */
LY_CHECK_RET(ly_set_add(node_when, (void *)node, 1, NULL));
}