Skip to content

Commit 55663c2

Browse files
committed
yanglint BUGFIX correct additional parameter for lyd_validate
For the case of validating empty data tree, lyd_validate() need pointer to context as an additional parameter
1 parent fa3989c commit 55663c2

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

tools/lint/commands.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ parse_data(const char *filepath, int options, struct lyd_node *val_tree, const c
334334
struct lyxml_elem *xml = NULL;
335335
const struct lys_node *rpc_act = NULL;
336336
struct lyd_node *data = NULL, *root, *next, *iter;
337+
void *lydval_arg = NULL;
337338

338339
/* detect input format according to file suffix */
339340
len = strlen(filepath);
@@ -366,18 +367,23 @@ parse_data(const char *filepath, int options, struct lyd_node *val_tree, const c
366367
if (!strcmp(xml->name, "data")) {
367368
fprintf(stdout, "Parsing %s as complete datastore.\n", filepath);
368369
options = (options & ~LYD_OPT_TYPEMASK);
370+
lydval_arg = ctx;
369371
} else if (!strcmp(xml->name, "config")) {
370372
fprintf(stdout, "Parsing %s as config data.\n", filepath);
371373
options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_CONFIG;
374+
lydval_arg = ctx;
372375
} else if (!strcmp(xml->name, "get-reply")) {
373376
fprintf(stdout, "Parsing %s as <get> reply data.\n", filepath);
374377
options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_GET;
378+
lydval_arg = ctx;
375379
} else if (!strcmp(xml->name, "get-config-reply")) {
376380
fprintf(stdout, "Parsing %s as <get-config> reply data.\n", filepath);
377381
options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_GETCONFIG;
382+
lydval_arg = ctx;
378383
} else if (!strcmp(xml->name, "edit-config")) {
379384
fprintf(stdout, "Parsing %s as <edit-config> data.\n", filepath);
380385
options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_EDIT;
386+
lydval_arg = ctx;
381387
} else if (!strcmp(xml->name, "rpc")) {
382388
fprintf(stdout, "Parsing %s as <rpc> data.\n", filepath);
383389
options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_RPC;
@@ -470,7 +476,7 @@ parse_data(const char *filepath, int options, struct lyd_node *val_tree, const c
470476
}
471477

472478
/* validate the result */
473-
if (lyd_validate(&data, options, NULL)) {
479+
if (lyd_validate(&data, options, lydval_arg)) {
474480
fprintf(stderr, "Failed to parse data.\n");
475481
lyd_free_withsiblings(data);
476482
return EXIT_FAILURE;

tools/lint/main_ni.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ main_ni(int argc, char* argv[])
509509
LY_TREE_DFS_END(subroot, next, node)
510510
}
511511
}
512-
if (lyd_validate(&root, options_parser, NULL)) {
512+
if (lyd_validate(&root, options_parser, ctx)) {
513513
goto cleanup;
514514
}
515515
}

0 commit comments

Comments
 (0)