Skip to content

Commit e14d2eb

Browse files
committed
yanglint BUGFIX validating data even no input data file specified
In non-interactive mode, when no output format specified (only validation required) and no data input file given (schema validation required), the data tree was anyway validated which could fail if the provided schemas to validate contain mandatory status data
1 parent 5190a05 commit e14d2eb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/lint/main_ni.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ main_ni(int argc, char* argv[])
179179
struct dataitem *next;
180180
} *data = NULL, *data_item;
181181
struct ly_set *mods = NULL;
182-
struct lyd_node *root = NULL, *node, *next, *subroot;
182+
struct lyd_node *root = NULL, *node = NULL, *next, *subroot;
183183
struct lyxml_elem *xml = NULL;
184184

185185
opterr = 0;
@@ -434,7 +434,7 @@ main_ni(int argc, char* argv[])
434434
for (u = 0; u < mods->number; u++) {
435435
lys_print_file(out, (struct lys_module *)mods->set.g[u], outformat_s, NULL);
436436
}
437-
} else {
437+
} else if (data) {
438438
ly_errno = 0;
439439
if (!options_parser) {
440440
/* LYD_OPT_DATA - status data fro ietf-yang-library are needed */
@@ -501,7 +501,7 @@ main_ni(int argc, char* argv[])
501501
}
502502
}
503503
/* validate the data */
504-
if (outformat_d || root) {
504+
if (data) {
505505
/* do not trust the input, invalidate all the data first */
506506
LY_TREE_FOR(root, subroot) {
507507
LY_TREE_DFS_BEGIN(subroot, next, node) {

0 commit comments

Comments
 (0)