schema parsers BUGFIX instantiating lists from groupings
Do not set config flags for the grouping and inherit it inside it,
the config flag always depends on where the grouping is instantiated.
Then, when no config flag is set, skip some checkings for config
compatibility between parent and its children. The checks are done
later when the grouping is instantiated and config flags are set
correctly.
Similarly, do not check for list's keys in grouping, since it can be
added even by augment only to the finally instantiated grouping and
the list definition inside the grouping will be always without the key
(that's a terribly designed schema, but it can be defined and avoiding
these tests in grouping can save some time)
Fixes #132
Fixes sysrepo/sysrepo#487
diff --git a/src/parser_yang.c b/src/parser_yang.c
index a9f6a26..c719fe9 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -687,6 +687,7 @@
yang_read_key(struct lys_module *module, struct lys_node_list *list, struct unres_schema *unres)
{
char *exp, *value;
+ struct lys_node *node;
exp = value = (char *) list->keys;
list->keys_size = 0;
@@ -697,20 +698,18 @@
}
}
list->keys_size++;
+
+ list->keys_str = lydict_insert_zc(module->ctx, exp);
list->keys = calloc(list->keys_size, sizeof *list->keys);
if (!list->keys) {
LOGMEM;
- goto error;
+ return EXIT_FAILURE;
}
- if (unres_schema_add_str(module, unres, list, UNRES_LIST_KEYS, exp) == -1) {
- goto error;
+ for (node = list->parent; node && node->nodetype != LYS_GROUPING; node = lys_parent(node));
+ if (!node && unres_schema_add_node(module, unres, list, UNRES_LIST_KEYS, NULL) == -1) {
+ return EXIT_FAILURE;
}
- free(exp);
return EXIT_SUCCESS;
-
-error:
- free(exp);
- return EXIT_FAILURE;
}
int