Skip to content

Commit

Permalink
schema compile BUGFIX handle disabled actions/notifs in augments
Browse files Browse the repository at this point in the history
Fixes #1403
  • Loading branch information
michalvasko committed Feb 3, 2021
1 parent a99b357 commit 012807e
Showing 1 changed file with 38 additions and 16 deletions.
54 changes: 38 additions & 16 deletions src/schema_compile_amend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1782,17 +1782,28 @@ lys_compile_augment(struct lysc_ctx *ctx, struct lysp_node_augment *aug_p, struc

/* compile actions into the target */
LY_LIST_FOR((struct lysp_node *)aug_p->actions, pnode) {
LY_CHECK_GOTO(ret = lys_compile_node(ctx, pnode, target, 0, NULL), cleanup);
}
LY_CHECK_GOTO(ret = lys_compile_node(ctx, pnode, target, 0, &child_set), cleanup);

if (aug_p->when) {
/* inherit when */
struct lysc_node *iter;
/* eval if-features again for the rest of this node processing */
LY_CHECK_GOTO(ret = lys_eval_iffeatures(ctx->ctx, pnode->iffeatures, &enabled), cleanup);
if (!enabled) {
ctx->options |= LYS_COMPILE_DISABLED;
}

LY_LIST_FOR((struct lysc_node *)*actions, iter) {
ret = lys_compile_when(ctx, aug_p->when, aug_p->flags, lysc_data_node(target), iter, &when_shared);
LY_CHECK_GOTO(ret, cleanup);
/* since the augment node is not present in the compiled tree, we need to pass some of its
* statements to all its children */
for (i = 0; i < child_set.count; ++i) {
node = child_set.snodes[i];
if (aug_p->when) {
/* pass augment's when to all the actions */
ret = lys_compile_when(ctx, aug_p->when, aug_p->flags, lysc_data_node(target), node, &when_shared);
LY_CHECK_GOTO(ret, cleanup);
}
}
ly_set_erase(&child_set, NULL);

/* restore options */
ctx->options = opt_prev;
}
}
if (aug_p->notifs) {
Expand All @@ -1806,17 +1817,28 @@ lys_compile_augment(struct lysc_ctx *ctx, struct lysp_node_augment *aug_p, struc

/* compile notifications into the target */
LY_LIST_FOR((struct lysp_node *)aug_p->notifs, pnode) {
LY_CHECK_GOTO(ret = lys_compile_node(ctx, pnode, target, 0, NULL), cleanup);
}
LY_CHECK_GOTO(ret = lys_compile_node(ctx, pnode, target, 0, &child_set), cleanup);

if (aug_p->when) {
/* inherit when */
struct lysc_node *iter;
/* eval if-features again for the rest of this node processing */
LY_CHECK_GOTO(ret = lys_eval_iffeatures(ctx->ctx, pnode->iffeatures, &enabled), cleanup);
if (!enabled) {
ctx->options |= LYS_COMPILE_DISABLED;
}

LY_LIST_FOR((struct lysc_node *)*notifs, iter) {
ret = lys_compile_when(ctx, aug_p->when, aug_p->flags, lysc_data_node(target), iter, &when_shared);
LY_CHECK_GOTO(ret, cleanup);
/* since the augment node is not present in the compiled tree, we need to pass some of its
* statements to all its children */
for (i = 0; i < child_set.count; ++i) {
node = child_set.snodes[i];
if (aug_p->when) {
/* pass augment's when to all the actions */
ret = lys_compile_when(ctx, aug_p->when, aug_p->flags, lysc_data_node(target), node, &when_shared);
LY_CHECK_GOTO(ret, cleanup);
}
}
ly_set_erase(&child_set, NULL);

/* restore options */
ctx->options = opt_prev;
}
}

Expand Down

0 comments on commit 012807e

Please sign in to comment.