Skip to content

Commit f1aa47d

Browse files
committed
resolve BUGFIX check leafref if-features after making modules implemented
Fixes #361
1 parent be136f6 commit f1aa47d

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/resolve.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6158,6 +6158,7 @@ check_leafref_features(struct lys_type *type)
61586158
{
61596159
struct lys_node *iter;
61606160
struct ly_set *src_parents, *trg_parents, *features;
6161+
struct lys_node_augment *aug;
61616162
unsigned int i, j, size, x;
61626163
int ret = EXIT_SUCCESS;
61636164

@@ -6172,13 +6173,29 @@ check_leafref_features(struct lys_type *type)
61726173
if (iter->nodetype & (LYS_INPUT | LYS_OUTPUT)) {
61736174
continue;
61746175
}
6176+
if (iter->parent && (iter->parent->nodetype == LYS_AUGMENT) && lys_node_module(iter->parent)->implemented) {
6177+
aug = (struct lys_node_augment *)iter->parent;
6178+
if ((aug->flags & LYS_NOTAPPLIED) || !aug->target) {
6179+
/* unresolved augment, wait until it's resolved */
6180+
ret = EXIT_FAILURE;
6181+
goto cleanup;
6182+
}
6183+
}
61756184
ly_set_add(src_parents, iter, LY_SET_OPT_USEASLIST);
61766185
}
61776186
/* get parents chain of target */
61786187
for (iter = (struct lys_node *)type->info.lref.target; iter; iter = lys_parent(iter)) {
61796188
if (iter->nodetype & (LYS_INPUT | LYS_OUTPUT)) {
61806189
continue;
61816190
}
6191+
if (iter->parent && (iter->parent->nodetype == LYS_AUGMENT) && lys_node_module(iter->parent)->implemented) {
6192+
aug = (struct lys_node_augment *)iter->parent;
6193+
if ((aug->flags & LYS_NOTAPPLIED) || !aug->target) {
6194+
/* unresolved augment, wait until it's resolved */
6195+
ret = EXIT_FAILURE;
6196+
goto cleanup;
6197+
}
6198+
}
61826199
ly_set_add(trg_parents, iter, LY_SET_OPT_USEASLIST);
61836200
}
61846201

@@ -6324,11 +6341,6 @@ resolve_unres_schema_item(struct lys_module *mod, void *item, enum UNRES_ITEM ty
63246341
rc = resolve_schema_leafref(stype->info.lref.path, node, (const struct lys_node **)&stype->info.lref.target);
63256342
if (!rc) {
63266343
assert(stype->info.lref.target);
6327-
/* check if leafref and its target are under a common if-features */
6328-
rc = check_leafref_features(stype);
6329-
if (rc) {
6330-
break;
6331-
}
63326344

63336345
if (lys_node_module(node)->implemented) {
63346346
/* make all the modules on the path implemented, print verbose messages */
@@ -6362,6 +6374,9 @@ resolve_unres_schema_item(struct lys_module *mod, void *item, enum UNRES_ITEM ty
63626374
break;
63636375
}
63646376
}
6377+
6378+
/* check if leafref and its target are under common if-features */
6379+
rc = check_leafref_features(stype);
63656380
}
63666381

63676382
break;

src/tree_schema.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4050,7 +4050,7 @@ remove_aug(struct lys_node_augment *augment)
40504050
{
40514051
struct lys_node *last, *elem;
40524052

4053-
if (augment->flags & LYS_NOTAPPLIED) {
4053+
if ((augment->flags & LYS_NOTAPPLIED) || !augment->target) {
40544054
/* skip already not applied augment */
40554055
return;
40564056
}

0 commit comments

Comments
 (0)