validation REFACTOR unify mod unres set names
diff --git a/src/in.c b/src/in.c
index e4320f9..279c54d 100644
--- a/src/in.c
+++ b/src/in.c
@@ -370,9 +370,9 @@
void
lyd_ctx_free(struct lyd_ctx *lydctx)
{
- ly_set_erase(&lydctx->unres_node_type, NULL);
- ly_set_erase(&lydctx->unres_meta_type, NULL);
- ly_set_erase(&lydctx->when_check, NULL);
+ ly_set_erase(&lydctx->node_types, NULL);
+ ly_set_erase(&lydctx->meta_types, NULL);
+ ly_set_erase(&lydctx->node_when, NULL);
}
LY_ERR
@@ -425,7 +425,7 @@
LY_CHECK_RET(lyd_create_term(schema, value, value_len, dynamic, format, prefix_data, hints, &incomplete, node));
if (incomplete && !(lydctx->parse_options & LYD_PARSE_ONLY)) {
- LY_CHECK_RET(ly_set_add(&lydctx->unres_node_type, *node, 1, NULL));
+ LY_CHECK_RET(ly_set_add(&lydctx->node_types, *node, 1, NULL));
}
return LY_SUCCESS;
}
@@ -447,7 +447,7 @@
hints, 0, &incomplete));
if (incomplete && !(lydctx->parse_options & LYD_PARSE_ONLY)) {
- LY_CHECK_RET(ly_set_add(&lydctx->unres_meta_type, *meta, 1, NULL));
+ LY_CHECK_RET(ly_set_add(&lydctx->meta_types, *meta, 1, NULL));
}
if (first) {
diff --git a/src/parser_internal.h b/src/parser_internal.h
index b8208f6..b2b4cc2 100644
--- a/src/parser_internal.h
+++ b/src/parser_internal.h
@@ -38,9 +38,9 @@
uint32_t path_len; /**< used bytes in the path buffer */
#define LYD_PARSER_BUFSIZE 4078
char path[LYD_PARSER_BUFSIZE]; /**< buffer for the generated path */
- struct ly_set unres_node_type; /**< set of nodes validated with LY_EINCOMPLETE result */
- struct ly_set unres_meta_type; /**< set of metadata validated with LY_EINCOMPLETE result */
- struct ly_set when_check; /**< set of nodes with "when" conditions */
+ struct ly_set node_types; /**< set of nodes validated with LY_EINCOMPLETE result */
+ struct ly_set meta_types; /**< set of metadata validated with LY_EINCOMPLETE result */
+ struct ly_set node_when; /**< set of nodes with "when" conditions */
struct lyd_node *op_node; /**< if an RPC/action/notification is being parsed, store the pointer to it */
/* callbacks */
diff --git a/src/tree_data.c b/src/tree_data.c
index c743446..a95a8cb 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -350,12 +350,12 @@
LY_CHECK_GOTO(ret = lyd_validate_new(first2, NULL, mod, NULL), cleanup);
/* add all top-level defaults for this module */
- ret = lyd_new_implicit_r(NULL, first2, NULL, mod, &lydctx->unres_node_type, &lydctx->when_check,
+ ret = lyd_new_implicit_r(NULL, first2, NULL, mod, &lydctx->node_types, &lydctx->node_when,
(validate_options & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, NULL);
LY_CHECK_GOTO(ret, cleanup);
/* finish incompletely validated terminal values/attributes and when conditions */
- ret = lyd_validate_unres(tree, &lydctx->when_check, &lydctx->unres_node_type, &lydctx->unres_meta_type, NULL);
+ ret = lyd_validate_unres(tree, &lydctx->node_when, &lydctx->node_types, &lydctx->meta_types, NULL);
LY_CHECK_GOTO(ret, cleanup);
/* perform final validation that assumes the data tree is final */
diff --git a/src/validation.c b/src/validation.c
index c59f012..b970622 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -1245,16 +1245,16 @@
* @brief Validate the whole data subtree.
*
* @param[in] root Subtree root.
- * @param[in,out] type_check Set for unres node types.
- * @param[in,out] type_meta_check Set for unres metadata types.
- * @param[in,out] when_check Set for nodes with when conditions.
+ * @param[in,out] node_types Set for unres node types.
+ * @param[in,out] meta_types Set for unres metadata types.
+ * @param[in,out] node_when Set for nodes with when conditions.
* @param[in] val_opts Validation options, see @ref datavalidationoptions.
* @param[in,out] diff Validation diff.
* @return LY_ERR value.
*/
static LY_ERR
-lyd_validate_subtree(struct lyd_node *root, struct ly_set *type_check, struct ly_set *type_meta_check,
- struct ly_set *when_check, uint32_t val_opts, struct lyd_node **diff)
+lyd_validate_subtree(struct lyd_node *root, struct ly_set *node_types, struct ly_set *meta_types,
+ struct ly_set *node_when, uint32_t val_opts, struct lyd_node **diff)
{
const struct lyd_meta *meta;
struct lyd_node *node;
@@ -1263,13 +1263,13 @@
LY_LIST_FOR(node->meta, meta) {
if (((struct lyext_metadata *)meta->annotation->data)->type->plugin->validate) {
/* metadata type resolution */
- LY_CHECK_RET(ly_set_add(type_meta_check, (void *)meta, 1, NULL));
+ LY_CHECK_RET(ly_set_add(meta_types, (void *)meta, 1, NULL));
}
}
if ((node->schema->nodetype & LYD_NODE_TERM) && ((struct lysc_node_leaf *)node->schema)->type->plugin->validate) {
/* node type resolution */
- LY_CHECK_RET(ly_set_add(type_check, (void *)node, 1, NULL));
+ LY_CHECK_RET(ly_set_add(node_types, (void *)node, 1, NULL));
} else if (node->schema->nodetype & LYD_NODE_INNER) {
/* new node validation, autodelete */
LY_CHECK_RET(lyd_validate_new(lyd_node_children_p((struct lyd_node *)node), node->schema, NULL, diff));
@@ -1281,7 +1281,7 @@
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));
+ LY_CHECK_RET(ly_set_add(node_when, (void *)node, 1, NULL));
}
LYD_TREE_DFS_END(root, node);
@@ -1308,7 +1308,7 @@
LY_ERR ret = LY_SUCCESS;
struct lyd_node *first, *next, **first2;
const struct lys_module *mod;
- struct ly_set type_check = {0}, type_meta_check = {0}, when_check = {0};
+ struct ly_set node_types = {0}, meta_types = {0}, node_when = {0};
uint32_t i = 0;
LY_CHECK_ARG_RET(NULL, tree, *tree || ctx || module, LY_EINVAL);
@@ -1344,12 +1344,12 @@
/* process nested nodes */
LY_LIST_FOR(*first2, first) {
- ret = lyd_validate_subtree(first, &type_check, &type_meta_check, &when_check, val_opts, diff);
+ ret = lyd_validate_subtree(iter, &node_types, &meta_types, &node_when, val_opts, diff);
LY_CHECK_GOTO(ret, cleanup);
}
/* finish incompletely validated terminal values/attributes and when conditions */
- ret = lyd_validate_unres(tree, &when_check, &type_check, &type_meta_check, diff);
+ ret = lyd_validate_unres(tree, &node_when, &node_types, &meta_types, diff);
LY_CHECK_GOTO(ret, cleanup);
/* perform final validation that assumes the data tree is final */
@@ -1358,9 +1358,9 @@
}
cleanup:
- ly_set_erase(&type_check, NULL);
- ly_set_erase(&type_meta_check, NULL);
- ly_set_erase(&when_check, NULL);
+ ly_set_erase(&node_types, NULL);
+ ly_set_erase(&meta_types, NULL);
+ ly_set_erase(&node_when, NULL);
return ret;
}