libyang REFACTOR avoid connection between context and log location storage
libyang works strictly with a single context now, so it is not necessary
to connect the log location information with a specific context. It also
clarifies what to do when the context is not available in the function
but still a location information in an error message could be useful.
diff --git a/src/validation.c b/src/validation.c
index 6299dee..20894f8 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -177,7 +177,7 @@
do {
--i;
node = node_when->dnodes[i];
- LOG_LOCSET(LYD_CTX(node), node->schema, node, NULL, NULL);
+ LOG_LOCSET(node->schema, node, NULL, NULL);
/* evaluate all when expressions that affect this node's existence */
ret = lyd_validate_node_when(*tree, node, node->schema, &disabled);
@@ -211,13 +211,13 @@
goto error;
}
- LOG_LOCBACK(LYD_CTX(node), 1, 1, 0, 0);
+ LOG_LOCBACK(1, 1, 0, 0);
} while (i);
return LY_SUCCESS;
error:
- LOG_LOCBACK(LYD_CTX(node), 1, 1, 0, 0);
+ LOG_LOCBACK(1, 1, 0, 0);
return ret;
}
@@ -251,9 +251,9 @@
struct lysc_type *type = ((struct lysc_node_leaf *)node->schema)->type;
/* resolve the value of the node */
- LOG_LOCSET(LYD_CTX(node), node->schema, (struct lyd_node *)node, NULL, NULL);
+ LOG_LOCSET(node->schema, (struct lyd_node *)node, NULL, NULL);
ret = lyd_value_validate_incomplete(LYD_CTX(node), type, &node->value, (struct lyd_node *)node, *tree);
- LOG_LOCBACK(LYD_CTX(node), node->schema ? 1 : 0, 1, 0, 0);
+ LOG_LOCBACK(node->schema ? 1 : 0, 1, 0, 0);
LY_CHECK_RET(ret);
/* remove this node from the set */
@@ -349,7 +349,7 @@
struct lyd_node *match, *to_del;
ly_bool found;
- LOG_LOCSET(choic->module->ctx, (const struct lysc_node *)choic, NULL, NULL, NULL);
+ LOG_LOCSET((const struct lysc_node *)choic, NULL, NULL, NULL);
LY_LIST_FOR((struct lysc_node *)choic->cases, scase) {
found = 0;
@@ -373,7 +373,7 @@
if (old_case) {
/* old data from 2 cases */
LOGVAL(choic->module->ctx, LY_VCODE_DUPCASE, old_case->name, scase->name);
- LOG_LOCBACK(choic->module->ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
return LY_EVALID;
}
@@ -383,7 +383,7 @@
if (new_case) {
/* new data from 2 cases */
LOGVAL(choic->module->ctx, LY_VCODE_DUPCASE, new_case->name, scase->name);
- LOG_LOCBACK(choic->module->ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
return LY_EVALID;
}
@@ -392,7 +392,7 @@
}
}
- LOG_LOCBACK(choic->module->ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
if (old_case && new_case) {
/* auto-delete old case */
@@ -589,7 +589,7 @@
continue;
}
- LOG_LOCSET(LYD_CTX(node), node->schema, node, NULL, NULL);
+ LOG_LOCSET(node->schema, node, NULL, NULL);
if (node->flags & LYD_NEW) {
LY_ERR ret;
@@ -599,7 +599,7 @@
/* then check new node instance duplicities */
ret = lyd_validate_duplicates(*first, node);
- LY_CHECK_ERR_RET(ret, LOG_LOCBACK(LYD_CTX(node), node->schema ? 1 : 0, 1, 0, 0), ret);
+ LY_CHECK_ERR_RET(ret, LOG_LOCBACK(node->schema ? 1 : 0, 1, 0, 0), ret);
/* this node is valid */
node->flags &= ~LYD_NEW;
@@ -610,7 +610,7 @@
lyd_validate_autodel_case_dflt(first, node, mod, &next, diff);
}
- LOG_LOCBACK(LYD_CTX(node), node->schema ? 1 : 0, 1, 0, 0);
+ LOG_LOCBACK(node->schema ? 1 : 0, 1, 0, 0);
}
return LY_SUCCESS;
@@ -751,7 +751,7 @@
}
if (max && (count > max)) {
/* not satisifed */
- LOG_LOCSET(snode->module->ctx, NULL, iter, NULL, NULL);
+ LOG_LOCSET(NULL, iter, NULL, NULL);
invalid_instance = 1;
break;
}
@@ -778,7 +778,7 @@
return LY_SUCCESS;
failure:
- LOG_LOCBACK(snode->module->ctx, 0, invalid_instance, 0, 0);
+ LOG_LOCBACK(0, invalid_instance, 0, 0);
return LY_EVALID;
}
@@ -905,9 +905,9 @@
ptr += strlen(ptr);
}
- LOG_LOCSET(ctx, NULL, second, NULL, NULL);
+ LOG_LOCSET(NULL, second, NULL, NULL);
LOGVAL(ctx, LY_VCODE_NOUNIQ, uniq_str, path1, path2);
- LOG_LOCBACK(ctx, 0, 1, 0, 0);
+ LOG_LOCBACK(0, 1, 0, 0);
free(path1);
free(path2);
@@ -1077,7 +1077,7 @@
continue;
}
- LOG_LOCSET(mod ? mod->mod->ctx : sparent->module->ctx, snode, NULL, NULL, NULL);
+ LOG_LOCSET(snode, NULL, NULL, NULL);
/* check min-elements and max-elements */
if (snode->nodetype == LYS_LIST) {
@@ -1114,13 +1114,13 @@
LY_CHECK_GOTO(ret, error);
}
- LOG_LOCBACK(mod ? mod->mod->ctx : sparent->module->ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
}
return LY_SUCCESS;
error:
- LOG_LOCBACK(mod ? mod->mod->ctx : sparent->module->ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
return ret;
}
@@ -1239,12 +1239,12 @@
break;
}
- LOG_LOCSET(LYD_CTX(first), node->schema, node, NULL, NULL);
+ LOG_LOCSET(node->schema, node, NULL, NULL);
/* opaque data */
if (!node->schema) {
LOGVAL(LYD_CTX(node), LYVE_DATA, "Opaque node \"%s\" found.", ((struct lyd_node_opaq *)node)->name.name);
- LOG_LOCBACK(LYD_CTX(first), 0, 1, 0, 0);
+ LOG_LOCBACK(0, 1, 0, 0);
return LY_EVALID;
}
@@ -1268,7 +1268,7 @@
/* node value was checked by plugins */
- LOG_LOCBACK(LYD_CTX(first), 1, 1, 0, 0);
+ LOG_LOCBACK(1, 1, 0, 0);
}
/* validate schema-based restrictions */
@@ -1295,7 +1295,7 @@
invalid_node:
LOGVAL(LYD_CTX(node), LY_VCODE_INNODE, innode, node->schema->name);
- LOG_LOCBACK(LYD_CTX(first), 1, 1, 0, 0);
+ LOG_LOCBACK(1, 1, 0, 0);
return LY_EVALID;
}
@@ -1554,7 +1554,7 @@
tree = tree_sibling;
}
- LOG_LOCSET(LYD_CTX(op_node), NULL, op_node, NULL, NULL);
+ LOG_LOCSET(NULL, op_node, NULL, NULL);
/* prevalidate whole operation subtree */
LY_CHECK_GOTO(ret = lyd_validate_subtree(op_node, &type_check, &type_meta_check, &when_check,
@@ -1572,7 +1572,7 @@
LY_CHECK_GOTO(ret = lyd_validate_final_r(lyd_child(op_node), op_node, op_node->schema, NULL, 0, op), cleanup);
cleanup:
- LOG_LOCBACK(LYD_CTX(op_node), 0, 1, 0, 0);
+ LOG_LOCBACK(0, 1, 0, 0);
/* restore operation tree */
lyd_unlink_tree(op_subtree);
if (op_parent) {