validation BUGFIX avoid duplicit nodes in unres
It could occur for default values that have their
own unres handling. This one is no longer used and
they are normally validated during subtree validation.
@@ -1030,8 +1030,6 @@ lyd_validate_subtree(struct lyd_node *root, struct ly_set *type_check, struct ly
struct lyd_node *node;
LYD_TREE_DFS_BEGIN(root, node) {
- /* skip added default nodes */
- if ((node->flags & (LYD_DEFAULT | LYD_NEW)) != (LYD_DEFAULT | LYD_NEW)) {
LY_LIST_FOR(node->meta, meta) {
if (((struct lyext_metadata *)meta->annotation->data)->type->plugin->validate) {
/* metadata type resolution */
@@ -1048,15 +1046,13 @@ lyd_validate_subtree(struct lyd_node *root, struct ly_set *type_check, struct ly
/* add nested defaults */
LY_CHECK_RET(lyd_new_implicit_r(node, lyd_node_children_p((struct lyd_node *)node), NULL, NULL, type_check,
- when_check, val_opts & LYD_VALIDATE_NO_STATE ? LYD_IMPLICIT_NO_STATE : 0,
- diff));
+ when_check, val_opts & LYD_VALIDATE_NO_STATE ? LYD_IMPLICIT_NO_STATE : 0, diff));
}
if (!(node->schema->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) && node->schema->when) {
/* when evaluation */
LY_CHECK_RET(ly_set_add(when_check, (void *)node, 1, NULL));
}
- }
LYD_TREE_DFS_END(root, node);
}
@@ -1111,8 +1107,8 @@ lyd_validate(struct lyd_node **tree, const struct lys_module *module, const stru
ret = lyd_validate_new(first2, NULL, mod, diff);
LY_CHECK_GOTO(ret, cleanup);
- /* add all top-level defaults for this module */
- ret = lyd_new_implicit_r(NULL, first2, NULL, mod, &type_check, &when_check, val_opts & LYD_VALIDATE_NO_STATE ?
+ /* add all top-level defaults for this module, do not add into unres sets, will occur in the next step */
+ ret = lyd_new_implicit_r(NULL, first2, NULL, mod, NULL, NULL, val_opts & LYD_VALIDATE_NO_STATE ?
LYD_IMPLICIT_NO_STATE : 0, diff);
LY_CHECK_GOTO(ret, cleanup);
