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/path.c b/src/path.c
index df3abc3..b62ce58 100644
--- a/src/path.c
+++ b/src/path.c
@@ -54,7 +54,7 @@
const char *name;
size_t name_len;
- LOG_LOCSET(ctx, cur_node, NULL, NULL, NULL);
+ LOG_LOCSET(cur_node, NULL, NULL, NULL);
if (!lyxp_next_token(NULL, exp, tok_idx, LYXP_TOKEN_BRACK1)) {
/* '[' */
@@ -218,12 +218,12 @@
}
cleanup:
- LOG_LOCBACK(ctx, cur_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
ly_set_free(set, NULL);
return ret;
token_error:
- LOG_LOCBACK(ctx, cur_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
ly_set_free(set, NULL);
return LY_EVALID;
}
@@ -243,7 +243,7 @@
(prefix == LY_PATH_PREFIX_STRICT_INHERIT));
assert((pred == LY_PATH_PRED_KEYS) || (pred == LY_PATH_PRED_SIMPLE) || (pred == LY_PATH_PRED_LEAFREF));
- LOG_LOCSET(ctx, ctx_node, NULL, NULL, NULL);
+ LOG_LOCSET(ctx_node, NULL, NULL, NULL);
/* parse as a generic XPath expression */
LY_CHECK_GOTO(ret = lyxp_expr_parse(ctx, str_path, path_len, 1, &exp), error);
@@ -327,12 +327,12 @@
*expr = exp;
- LOG_LOCBACK(ctx, ctx_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(ctx_node ? 1 : 0, 0, 0, 0);
return LY_SUCCESS;
error:
lyxp_expr_free(ctx, exp);
- LOG_LOCBACK(ctx, ctx_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(ctx_node ? 1 : 0, 0, 0, 0);
return ret;
}
@@ -347,7 +347,7 @@
assert((prefix == LY_PATH_PREFIX_OPTIONAL) || (prefix == LY_PATH_PREFIX_MANDATORY));
assert((pred == LY_PATH_PRED_KEYS) || (pred == LY_PATH_PRED_SIMPLE) || (pred == LY_PATH_PRED_LEAFREF));
- LOG_LOCSET(ctx, cur_node, NULL, NULL, NULL);
+ LOG_LOCSET(cur_node, NULL, NULL, NULL);
/* parse as a generic XPath expression */
LY_CHECK_GOTO(ret = lyxp_expr_parse(ctx, str_path, path_len, 0, &exp), error);
@@ -365,12 +365,12 @@
*expr = exp;
- LOG_LOCBACK(ctx, cur_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
return LY_SUCCESS;
error:
lyxp_expr_free(ctx, exp);
- LOG_LOCBACK(ctx, cur_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
return ret;
}
@@ -416,7 +416,7 @@
if (pref) {
ret = LY_EVALID;
- LOG_LOCSET(ctx, cur_node, NULL, NULL, NULL);
+ LOG_LOCSET(cur_node, NULL, NULL, NULL);
*mod = ly_resolve_prefix(ctx, pref, len, format, prefix_data);
if (!*mod) {
@@ -431,7 +431,7 @@
LY_CHECK_GOTO(ret = lys_set_implemented_r((struct lys_module *)*mod, NULL, unres), error);
}
- LOG_LOCBACK(ctx, cur_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
} else {
switch (format) {
case LY_PREF_SCHEMA:
@@ -467,7 +467,7 @@
return LY_SUCCESS;
error:
- LOG_LOCBACK(ctx, cur_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
return LY_EVALID;
}
@@ -485,7 +485,7 @@
assert(ctx && ctx_node);
- LOG_LOCSET(ctx, cur_node, NULL, NULL, NULL);
+ LOG_LOCSET(cur_node, NULL, NULL, NULL);
*pred_type = 0;
@@ -538,11 +538,11 @@
/* Literal */
assert(expr->tokens[*tok_idx] == LYXP_TOKEN_LITERAL);
- LOG_LOCSET(ctx, key, NULL, NULL, NULL);
+ LOG_LOCSET(key, NULL, NULL, NULL);
ret = lyd_value_store(ctx, &p->value, ((struct lysc_node_leaf *)key)->type,
expr->expr + expr->tok_pos[*tok_idx] + 1, expr->tok_len[*tok_idx] - 2, NULL, format, prefix_data,
LYD_HINT_DATA, key, NULL);
- LOG_LOCBACK(ctx, key ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(key ? 1 : 0, 0, 0, 0);
LY_CHECK_GOTO(ret, cleanup);
++(*tok_idx);
@@ -590,11 +590,11 @@
assert(expr->tokens[*tok_idx] == LYXP_TOKEN_LITERAL);
/* store the value */
- LOG_LOCSET(ctx, ctx_node, NULL, NULL, NULL);
+ LOG_LOCSET(ctx_node, NULL, NULL, NULL);
ret = lyd_value_store(ctx, &p->value, ((struct lysc_node_leaflist *)ctx_node)->type,
expr->expr + expr->tok_pos[*tok_idx] + 1, expr->tok_len[*tok_idx] - 2, NULL, format, prefix_data,
LYD_HINT_DATA, ctx_node, NULL);
- LOG_LOCBACK(ctx, ctx_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(ctx_node ? 1 : 0, 0, 0, 0);
LY_CHECK_GOTO(ret, cleanup);
++(*tok_idx);
@@ -632,7 +632,7 @@
}
cleanup:
- LOG_LOCBACK(ctx, cur_node ? 1 : 0, 0, 0, 0);
+ LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
return ret;
}
@@ -660,7 +660,7 @@
size_t name_len;
struct ly_ctx *ctx = cur_node->module->ctx;
- LOG_LOCSET(ctx, cur_node, NULL, NULL, NULL);
+ LOG_LOCSET(cur_node, NULL, NULL, NULL);
if (lyxp_next_token(NULL, expr, tok_idx, LYXP_TOKEN_BRACK1)) {
/* '[', no predicate */
@@ -775,7 +775,7 @@
} while (!lyxp_next_token(NULL, expr, tok_idx, LYXP_TOKEN_BRACK1));
cleanup:
- LOG_LOCBACK(ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
return ret;
}
@@ -806,7 +806,7 @@
/* remember original context node */
cur_node = ctx_node;
- LOG_LOCINIT(ctx, cur_node, NULL, NULL, NULL);
+ LOG_LOCINIT(cur_node, NULL, NULL, NULL);
if (oper == LY_PATH_OPER_OUTPUT) {
getnext_opts = LYS_GETNEXT_OUTPUT;
@@ -903,7 +903,7 @@
ly_path_free(ctx, *path);
*path = NULL;
}
- LOG_LOCBACK(ctx, 1, 0, 0, 0);
+ LOG_LOCBACK(1, 0, 0, 0);
return ret;
}