Skip to content

Commit

Permalink
schema tree BUGFIX do not check features while still resolving schema
Browse files Browse the repository at this point in the history
Fixes #723
  • Loading branch information
michalvasko committed Mar 8, 2019
1 parent 28c2558 commit 32fb499
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -3941,7 +3941,8 @@ resolve_schema_leafref_predicate(const char *path, const struct lys_node *contex
} else {
trg_mod = lys_node_module(parent);
}
rc = lys_getnext_data(trg_mod, context_node, source, sour_len, LYS_LEAF | LYS_LEAFLIST, &src_node);
rc = lys_getnext_data(trg_mod, context_node, source, sour_len, LYS_LEAF | LYS_LEAFLIST, LYS_GETNEXT_NOSTATECHECK,
&src_node);
if (rc) {
LOGVAL(ctx, LYE_NORESOLV, LY_VLOG_LYS, parent, "leafref predicate", path-parsed);
return 0;
Expand Down Expand Up @@ -3984,7 +3985,8 @@ resolve_schema_leafref_predicate(const char *path, const struct lys_node *contex
} else {
trg_mod = lys_node_module(parent);
}
rc = lys_getnext_data(trg_mod, dst_node, dest, dest_len, LYS_CONTAINER | LYS_LIST | LYS_LEAF, &dst_node);
rc = lys_getnext_data(trg_mod, dst_node, dest, dest_len, LYS_CONTAINER | LYS_LIST | LYS_LEAF,
LYS_GETNEXT_NOSTATECHECK, &dst_node);
if (rc) {
LOGVAL(ctx, LYE_NORESOLV, LY_VLOG_LYS, parent, "leafref predicate", path_key_expr);
return 0;
Expand Down Expand Up @@ -6065,7 +6067,7 @@ resolve_list_keys(struct lys_node_list *list, const char *keys_str)
}

rc = lys_getnext_data(lys_node_module((struct lys_node *)list), (struct lys_node *)list, keys_str, len, LYS_LEAF,
(const struct lys_node **)&list->keys[i]);
LYS_GETNEXT_NOSTATECHECK, (const struct lys_node **)&list->keys[i]);
if (rc) {
LOGVAL(ctx, LYE_INRESOLV, LY_VLOG_LYS, list, "list key", keys_str);
return EXIT_FAILURE;
Expand Down
16 changes: 8 additions & 8 deletions src/tree_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ lyd_new(struct lyd_node *parent, const struct lys_module *module, const char *na
}

if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_CONTAINER | LYS_LIST | LYS_NOTIF
| LYS_RPC | LYS_ACTION, &snode) || !snode) {
| LYS_RPC | LYS_ACTION, 0, &snode) || !snode) {
LOGERR(siblings->module->ctx, LY_EINVAL, "Failed to find \"%s\" as a sibling to \"%s:%s\".",
name, lys_node_module(siblings)->name, siblings->name);
return NULL;
Expand Down Expand Up @@ -1265,7 +1265,7 @@ lyd_new_leaf(struct lyd_node *parent, const struct lys_module *module, const cha
return NULL;
}

if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_LEAFLIST | LYS_LEAF, &snode) || !snode) {
if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_LEAFLIST | LYS_LEAF, 0, &snode) || !snode) {
LOGERR(siblings->module->ctx, LY_EINVAL, "Failed to find \"%s\" as a sibling to \"%s:%s\".",
name, lys_node_module(siblings)->name, siblings->name);
return NULL;
Expand Down Expand Up @@ -1513,7 +1513,7 @@ lyd_new_anydata(struct lyd_node *parent, const struct lys_module *module, const
return NULL;
}

if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_ANYDATA, &snode) || !snode) {
if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_ANYDATA, 0, &snode) || !snode) {
LOGERR(siblings->module->ctx, LY_EINVAL, "Failed to find \"%s\" as a sibling to \"%s:%s\".",
name, lys_node_module(siblings)->name, siblings->name);
return NULL;
Expand All @@ -1538,7 +1538,7 @@ lyd_new_yangdata(const struct lys_module *module, const char *name_template, con
return NULL;
}

if (lys_getnext_data(module, schema, name, strlen(name), LYS_CONTAINER, &snode) || !snode) {
if (lys_getnext_data(module, schema, name, strlen(name), LYS_CONTAINER, 0, &snode) || !snode) {
LOGERR(module->ctx, LY_EINVAL, "Failed to find \"%s\" as a container child of \"%s:%s\".",
name, module->name, schema->name);
return NULL;
Expand All @@ -1564,7 +1564,7 @@ lyd_new_output(struct lyd_node *parent, const struct lys_module *module, const c
}

if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_CONTAINER | LYS_LIST | LYS_NOTIF
| LYS_RPC | LYS_ACTION, &snode) || !snode) {
| LYS_RPC | LYS_ACTION, 0, &snode) || !snode) {
LOGERR(siblings->module->ctx, LY_EINVAL, "Failed to find \"%s\" as a sibling to \"%s:%s\".",
name, lys_node_module(siblings)->name, siblings->name);
return NULL;
Expand All @@ -1589,7 +1589,7 @@ lyd_new_output_leaf(struct lyd_node *parent, const struct lys_module *module, co
return NULL;
}

if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_LEAFLIST | LYS_LEAF, &snode) || !snode) {
if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_LEAFLIST | LYS_LEAF, 0, &snode) || !snode) {
LOGERR(siblings->module->ctx, LY_EINVAL, "Failed to find \"%s\" as a sibling to \"%s:%s\".",
name, lys_node_module(siblings)->name, siblings->name);
return NULL;
Expand All @@ -1615,7 +1615,7 @@ lyd_new_output_anydata(struct lyd_node *parent, const struct lys_module *module,
return NULL;
}

if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_ANYDATA, &snode) || !snode) {
if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_ANYDATA, 0, &snode) || !snode) {
LOGERR(siblings->module->ctx, LY_EINVAL, "Failed to find \"%s\" as a sibling to \"%s:%s\".",
name, lys_node_module(siblings)->name, siblings->name);
return NULL;
Expand Down Expand Up @@ -5609,7 +5609,7 @@ lyd_dup_to_ctx(const struct lyd_node *node, int options, struct ly_ctx *ctx)
}
/* we know its parent, so we can start with it */
lys_getnext_data(trg_mod, parent->schema, elem->schema->name, strlen(elem->schema->name),
elem->schema->nodetype, (const struct lys_node **)&schema);
elem->schema->nodetype, 0, (const struct lys_node **)&schema);
} else {
/* we have to search in complete context */
schema = lyd_get_schema_inctx(elem, ctx);
Expand Down
3 changes: 2 additions & 1 deletion src/tree_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,13 @@ int lys_get_sibling(const struct lys_node *siblings, const char *mod_name, int m
* @param[in] name Node name.
* @param[in] nam_len Node \p name length.
* @param[in] type ORed desired type of the node. 0 means any (data node) type.
* @param[in] getnext_opts lys_getnext() options to use.
* @param[out] ret Pointer to the node of the desired type. Can be NULL.
*
* @return EXIT_SUCCESS on success, EXIT_FAILURE on fail.
*/
int lys_getnext_data(const struct lys_module *mod, const struct lys_node *parent, const char *name, int nam_len,
LYS_NODE type, const struct lys_node **ret);
LYS_NODE type, int getnext_opts, const struct lys_node **ret);

int lyd_get_unique_default(const char* unique_expr, struct lyd_node *list, const char **dflt);

Expand Down
4 changes: 2 additions & 2 deletions src/tree_schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ lys_get_sibling(const struct lys_node *siblings, const char *mod_name, int mod_n

int
lys_getnext_data(const struct lys_module *mod, const struct lys_node *parent, const char *name, int nam_len,
LYS_NODE type, const struct lys_node **ret)
LYS_NODE type, int getnext_opts, const struct lys_node **ret)
{
const struct lys_node *node;

Expand All @@ -226,7 +226,7 @@ lys_getnext_data(const struct lys_module *mod, const struct lys_node *parent, co

/* try to find the node */
node = NULL;
while ((node = lys_getnext(node, parent, mod, 0))) {
while ((node = lys_getnext(node, parent, mod, getnext_opts))) {
if (!type || (node->nodetype & type)) {
/* module check */
if (lys_node_module(node) != lys_main_module(mod)) {
Expand Down

0 comments on commit 32fb499

Please sign in to comment.