schema BUGFIX do not cast extension instance to lysc_node
lysc_update_path() needs only the parent's module, so it is not
necessary to provide the parent node (lysc_node), the function only
needs the module from the parent structure whatever it is (possibly
an extension instance).
diff --git a/src/plugins_exts.h b/src/plugins_exts.h
index 9ad46a2..bad8eb2 100644
--- a/src/plugins_exts.h
+++ b/src/plugins_exts.h
@@ -164,11 +164,11 @@
* @brief Update path in the compile context, which is used for logging where the compilation failed.
*
* @param[in] ctx Compile context with the path.
- * @param[in] parent Parent of the current node to check difference with the currently processed module (taken from @p ctx).
+ * @param[in] parent_module Module of the current node's parent to check difference with the currently processed module (taken from @p ctx).
* @param[in] name Name of the node to update path with. If NULL, the last segment is removed. If the format is `{keyword}`, the following
* call updates the segment to the form `{keyword='name'}` (to remove this compound segment, 2 calls with NULL @p name must be used).
*/
-void lysc_update_path(struct lysc_ctx *ctx, struct lysc_node *parent, const char *name);
+void lysc_update_path(struct lysc_ctx *ctx, struct lys_module *parent_module, const char *name);
/** @} extensionscompile */
diff --git a/src/schema_compile.c b/src/schema_compile.c
index 3317c4f..b2a9a9e 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -99,7 +99,7 @@
ext->parent = parent;
ext->parent_type = parent_type;
- lysc_update_path(ctx, ext->parent_type == LYEXT_PAR_NODE ? (struct lysc_node *)ext->parent : NULL, "{extension}");
+ lysc_update_path(ctx, ext->parent_type == LYEXT_PAR_NODE ? ((struct lysc_node *)ext->parent)->module : NULL, "{extension}");
lysc_update_path(ctx, NULL, ext_p->name);
/* parse the prefix */
@@ -178,7 +178,7 @@
if (ext->def->plugin && ext->def->plugin->compile) {
if (ext->argument) {
- lysc_update_path(ctx, (struct lysc_node *)ext, ext->argument);
+ lysc_update_path(ctx, ext->module, ext->argument);
}
ret = ext->def->plugin->compile(ctx, ext_p, ext);
if (ret == LY_ENOT) {
@@ -250,7 +250,7 @@
}
void
-lysc_update_path(struct lysc_ctx *ctx, struct lysc_node *parent, const char *name)
+lysc_update_path(struct lysc_ctx *ctx, struct lys_module *parent_module, const char *name)
{
int len;
uint8_t nextlevel = 0; /* 0 - no starttag, 1 - '/' starttag, 2 - '=' starttag + '}' endtag */
@@ -277,7 +277,7 @@
ctx->path[ctx->path_len] = '\0';
} else {
if (ctx->path_len > 1) {
- if (!parent && (ctx->path[ctx->path_len - 1] == '}') && (ctx->path[ctx->path_len - 2] != '\'')) {
+ if (!parent_module && (ctx->path[ctx->path_len - 1] == '}') && (ctx->path[ctx->path_len - 2] != '\'')) {
/* extension of the special tag */
nextlevel = 2;
--ctx->path_len;
@@ -288,7 +288,7 @@
} /* else the path is just initiated with '/', so do not add additional slash in case of top-level nodes */
if (nextlevel != 2) {
- if ((parent && (parent->module == ctx->cur_mod)) || (!parent && (ctx->path_len > 1) && (name[0] == '{'))) {
+ if ((parent_module && (parent_module == ctx->cur_mod)) || (!parent_module && (ctx->path_len > 1) && (name[0] == '{'))) {
/* module not changed, print the name unprefixed */
len = snprintf(&ctx->path[ctx->path_len], LYSC_CTX_BUFSIZE - ctx->path_len, "%s%s", nextlevel ? "/" : "", name);
} else {
@@ -1258,7 +1258,7 @@
for (u = orig_count; u < LY_ARRAY_COUNT(llist->dflts); ++u) {
for (v = 0; v < u; ++v) {
if (!llist->dflts[u]->realtype->plugin->compare(llist->dflts[u], llist->dflts[v])) {
- lysc_update_path(ctx, llist->parent, llist->name);
+ lysc_update_path(ctx, llist->parent ? llist->parent->module : NULL, llist->name);
LOGVAL(ctx->ctx, LYVE_SEMANTICS, "Configuration leaf-list has multiple defaults of the same value \"%s\".",
llist->dflts[u]->canonical);
lysc_update_path(ctx, NULL, NULL);
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index 1b0676c..b224376 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -2465,7 +2465,7 @@
};
/* input */
- lysc_update_path(ctx, &action->node, "input");
+ lysc_update_path(ctx, action->module, "input");
if (action_p->input.nodetype == LYS_UNKNOWN) {
input = &implicit_input;
} else {
@@ -2476,7 +2476,7 @@
LY_CHECK_GOTO(ret, done);
/* output */
- lysc_update_path(ctx, &action->node, "output");
+ lysc_update_path(ctx, action->module, "output");
if (action_p->output.nodetype == LYS_UNKNOWN) {
output = &implicit_output;
} else {
@@ -3030,7 +3030,7 @@
return LY_EVALID;
}
- lysc_update_path(ctx, &list->node, key->name);
+ lysc_update_path(ctx, list->module, key->name);
/* key must have the same config flag as the list itself */
if ((list->flags & LYS_CONFIG_MASK) != (key->flags & LYS_CONFIG_MASK)) {
LOGVAL(ctx->ctx, LYVE_SEMANTICS, "Key of the configuration list must not be status leaf.");
@@ -3725,7 +3725,7 @@
LY_ERR (*node_compile_spec)(struct lysc_ctx *, struct lysp_node *, struct lysc_node *);
if (pnode->nodetype != LYS_USES) {
- lysc_update_path(ctx, parent, pnode->name);
+ lysc_update_path(ctx, parent ? parent->module : NULL, pnode->name);
} else {
lysc_update_path(ctx, NULL, "{uses}");
lysc_update_path(ctx, NULL, pnode->name);