validation NEW duplicate instances
Also trees structure removed, some
refactoring included.
diff --git a/tools/lint/commands.c b/tools/lint/commands.c
index 67c0e53..b397950 100644
--- a/tools/lint/commands.c
+++ b/tools/lint/commands.c
@@ -545,7 +545,7 @@
}
static int
-parse_data(char *filepath, int *options, const struct lyd_node **trees, const char *rpc_act_file,
+parse_data(char *filepath, int *options, const struct lyd_node *tree, const char *rpc_act_file,
struct lyd_node **result)
{
LYD_FORMAT informat = LYD_UNKNOWN;
@@ -696,8 +696,8 @@
int options = 0, printopt = 0;
char **argv = NULL, *ptr;
const char *out_path = NULL;
- struct lyd_node *data = NULL, *val_tree = NULL;
- const struct lyd_node **trees = NULL;
+ struct lyd_node *data = NULL;
+ struct lyd_node *tree = NULL;
LYD_FORMAT outformat = LYD_UNKNOWN;
FILE *output = stdout;
static struct option long_options[] = {
@@ -829,7 +829,7 @@
goto cleanup;
}
- if (parse_data(argv[optind], &options, trees, argv[optind + 1], &data)) {
+ if (parse_data(argv[optind], &options, tree, argv[optind + 1], &data)) {
goto cleanup;
}
@@ -855,7 +855,6 @@
fclose(output);
}
- lyd_trees_free(trees, 1);
lyd_free_all(data);
return ret;
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 60ecfe1..99e7ce2 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -319,8 +319,7 @@
struct lyxml_elem *iter, *elem;
struct *subroot, *next, *node;
#endif
- struct lyd_node *oper = NULL;
- const struct lyd_node **trees = NULL;
+ struct lyd_node *tree = NULL;
struct dataitem {
const char *filename;
struct lyd_node *tree;
@@ -797,12 +796,11 @@
fprintf(stderr, "yanglint error: The operational data are expected in XML or JSON format.\n");
goto cleanup;
}
- oper = lyd_parse_path(ctx, oper_file, informat_d, LYD_OPT_PARSE_ONLY);
- if (!oper) {
+ tree = lyd_parse_path(ctx, oper_file, informat_d, LYD_OPT_PARSE_ONLY);
+ if (!tree) {
fprintf(stderr, "yanglint error: Failed to parse the operational datastore file for RPC/Notification validation.\n");
goto cleanup;
}
- trees = lyd_trees_new(1, oper);
}
for (data_item = data, data_prev = NULL; data_item; data_prev = data_item, data_item = data_item->next) {
@@ -1101,7 +1099,6 @@
lyd_free_all(data->tree);
free(data);
}
- lyd_trees_free(trees, 1);
ly_ctx_destroy(ctx, NULL);
return ret;