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/tree_data.c b/src/tree_data.c
index ba12500..8eee401 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -136,9 +136,9 @@
} else if (rc && err) {
if (ctx) {
/* log only in case the ctx was provided as input parameter */
- LOG_LOCSET(ctx, NULL, NULL, err->path, NULL);
+ LOG_LOCSET(NULL, NULL, err->path, NULL);
LOGVAL(ctx, err->vecode, err->msg);
- LOG_LOCBACK(ctx, 0, 0, 1, 0);
+ LOG_LOCBACK(0, 0, 1, 0);
}
ly_err_free(err);
}
@@ -181,9 +181,9 @@
if (rc) {
if (err) {
if (ctx) {
- LOG_LOCSET(ctx, NULL, (const struct lyd_node *)node, NULL, NULL);
+ LOG_LOCSET(NULL, (const struct lyd_node *)node, NULL, NULL);
LOGVAL(ctx, err->vecode, err->msg);
- LOG_LOCBACK(ctx, 0, 1, 0, 0);
+ LOG_LOCBACK(0, 1, 0, 0);
}
ly_err_free(err);
}
@@ -219,9 +219,9 @@
type = ((struct lysc_node_leaf *)node->schema)->type;
/* store the value */
- LOG_LOCSET(ctx, node->schema, (const struct lyd_node *)node, NULL, NULL);
+ LOG_LOCSET(node->schema, (const struct lyd_node *)node, NULL, NULL);
ret = lyd_value_store(ctx, &val, type, value, value_len, NULL, LY_PREF_JSON, NULL, LYD_HINT_DATA, node->schema, NULL);
- LOG_LOCBACK(ctx, 1, 1, 0, 0);
+ LOG_LOCBACK(1, 1, 0, 0);
LY_CHECK_RET(ret);
/* compare values */
@@ -538,10 +538,10 @@
term->prev = (struct lyd_node *)term;
term->flags = LYD_NEW;
- LOG_LOCSET(schema->module->ctx, schema, NULL, NULL, NULL);
+ LOG_LOCSET(schema, NULL, NULL, NULL);
ret = lyd_value_store(schema->module->ctx, &term->value, ((struct lysc_node_leaf *)term->schema)->type, value,
value_len, dynamic, format, prefix_data, hints, schema, incomplete);
- LOG_LOCBACK(schema->module->ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
LY_CHECK_ERR_RET(ret, free(term), ret);
lyd_hash((struct lyd_node *)term);
@@ -617,7 +617,7 @@
/* create list */
LY_CHECK_GOTO(ret = lyd_create_inner(schema, &list), cleanup);
- LOG_LOCSET(schema->module->ctx, NULL, list, NULL, NULL);
+ LOG_LOCSET(NULL, list, NULL, NULL);
/* create and insert all the keys */
LY_ARRAY_FOR(predicates, u) {
@@ -633,7 +633,7 @@
list = NULL;
cleanup:
- LOG_LOCBACK(schema->module->ctx, 0, 1, 0, 0);
+ LOG_LOCBACK(0, 1, 0, 0);
lyd_free_tree(list);
return ret;
}
@@ -647,7 +647,7 @@
enum ly_path_pred_type pred_type = 0;
struct ly_path_predicate *predicates = NULL;
- LOG_LOCSET(schema->module->ctx, schema, NULL, NULL, NULL);
+ LOG_LOCSET(schema, NULL, NULL, NULL);
/* parse keys */
LY_CHECK_GOTO(ret = ly_path_parse_predicate(schema->module->ctx, NULL, keys, keys_len, LY_PATH_PREFIX_OPTIONAL,
@@ -661,7 +661,7 @@
LY_CHECK_GOTO(ret = lyd_create_list(schema, predicates, node), cleanup);
cleanup:
- LOG_LOCBACK(schema->module->ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
lyxp_expr_free(schema->module->ctx, expr);
ly_path_predicates_free(schema->module->ctx, pred_type, predicates);
return ret;
@@ -1163,10 +1163,10 @@
type = ((struct lysc_node_leaf *)term->schema)->type;
/* parse the new value */
- LOG_LOCSET(LYD_CTX(term), term->schema, term, NULL, NULL);
+ LOG_LOCSET(term->schema, term, NULL, NULL);
ret = lyd_value_store(LYD_CTX(term), &val, type, val_str, strlen(val_str), NULL, LY_PREF_JSON, NULL, LYD_HINT_DATA,
term->schema, NULL);
- LOG_LOCBACK(LYD_CTX(term), term->schema ? 1 : 0, 1, 0, 0);
+ LOG_LOCBACK(term->schema ? 1 : 0, 1, 0, 0);
LY_CHECK_GOTO(ret, cleanup);
/* compare original and new value */
@@ -1306,10 +1306,10 @@
schema = p[LY_ARRAY_COUNT(p) - 1].node;
if ((schema->nodetype == LYS_LIST) && (p[LY_ARRAY_COUNT(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE) &&
!(options & LYD_NEW_PATH_OPAQ)) {
- LOG_LOCSET(ctx, schema, NULL, NULL, NULL);
+ LOG_LOCSET(schema, NULL, NULL, NULL);
LOGVAL(ctx, LYVE_XPATH, "Predicate missing for %s \"%s\" in path \"%s\".",
lys_nodetype2str(schema->nodetype), schema->name, path);
- LOG_LOCBACK(ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
ret = LY_EINVAL;
goto cleanup;
} else if ((schema->nodetype == LYS_LEAFLIST) && (p[LY_ARRAY_COUNT(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE)) {
@@ -1340,9 +1340,9 @@
if (ret == LY_SUCCESS) {
/* the node exists, are we supposed to update it or is it just a default? */
if (!(options & LYD_NEW_PATH_UPDATE) && !(node->flags & LYD_DEFAULT)) {
- LOG_LOCSET(ctx, NULL, node, NULL, NULL);
+ LOG_LOCSET(NULL, node, NULL, NULL);
LOGVAL(ctx, LYVE_REFERENCE, "Path \"%s\" already exists", path);
- LOG_LOCBACK(ctx, 0, 1, 0, 0);
+ LOG_LOCBACK(0, 1, 0, 0);
ret = LY_EEXIST;
goto cleanup;
}
@@ -2260,7 +2260,7 @@
assert((parent || meta) && mod);
- LOG_LOCSET(mod->ctx, parent ? parent->schema : NULL, parent, NULL, NULL);
+ LOG_LOCSET(parent ? parent->schema : NULL, parent, NULL, NULL);
LY_ARRAY_FOR(mod->compiled->exts, u) {
if ((mod->compiled->exts[u].def->plugin == lyext_plugins_internal[LYEXT_PLUGIN_INTERNAL_ANNOTATION].plugin) &&
@@ -2301,7 +2301,7 @@
}
cleanup:
- LOG_LOCBACK(mod->ctx, (parent && parent->schema) ? 1 : 0, parent ? 1 : 0, 0, 0);
+ LOG_LOCBACK((parent && parent->schema) ? 1 : 0, parent ? 1 : 0, 0, 0);
return ret;
}