Skip to content

Commit b456cf6

Browse files
committed
printing of extension fixed
1 parent 8cb8545 commit b456cf6

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

tools/lint/cmd_data.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ cmd_data_opt(struct yl_opt *yo, const char *cmdline, char ***posv, int *posc)
263263
return 1;
264264
}
265265
break;
266-
case 'k': /* --ext-id */
266+
case 'k': /* --ext-inst */
267267
if (parse_ext_string(optarg, yo)) {
268268
YLMSG_E("Invalid name of extension instance.");
269269
return 1;
@@ -642,37 +642,37 @@ parse_input_by_type(struct ly_ctx *ctx, enum lyd_type type, struct cmdline_file
642642
* @param[in] ctx libyang context with schema.
643643
* @param[in] yo context for yanglint.
644644
* @param[in] input_f Data input file.
645+
* @param[out] tree Extension data tree.
645646
* @param[in] oper_tree operational data tree.
646647
* @return LY_ERR value.
647648
*/
648649
static LY_ERR
649-
parse_extension_instance(struct ly_ctx *ctx, struct yl_opt *yo, struct cmdline_file *input_f, struct lyd_node *oper_tree)
650+
parse_extension_instance(struct ly_ctx *ctx, struct yl_opt *yo, struct cmdline_file *input_f, struct lyd_node **tree, struct lyd_node *oper_tree)
650651
{
651652

652653
LY_ERR ret = LY_SUCCESS;
653-
struct lyd_node *tree;
654+
struct lyd_node *tree_copy;
654655

655656
if (find_extension(ctx, yo)) {
656657
YLMSG_E("Extension '%s:%s:%s' not found in module.", yo->mod_name, yo->name, yo->argument);
657658
return LY_ENOTFOUND;
658659
}
659660

660-
if ((ret = lyd_parse_ext_data(yo->ext, NULL, input_f->in, input_f->format, LYD_PARSE_ONLY, 0, &tree))) {
661+
if ((ret = lyd_parse_ext_data(yo->ext, NULL, input_f->in, input_f->format, LYD_PARSE_ONLY, 0, tree))) {
661662
YLMSG_E("Parsing of extension data failed.")
662663
return ret;
663664
}
664-
if (oper_tree) {
665-
lyd_insert_sibling(tree, oper_tree, &tree);
666-
}
667665

668-
ret = lyd_validate_all(&tree, ctx, yo->data_validate_options, NULL);
666+
lyd_dup_siblings(*tree, NULL, LYD_DUP_RECURSIVE, &tree_copy);
669667

670-
if (yo->data_out_format) {
671-
lyd_print_all(yo->out, tree, yo->data_out_format, yo->data_print_options);
668+
if (oper_tree) {
669+
lyd_insert_sibling(tree_copy, oper_tree, &tree_copy);
672670
}
673671

672+
ret = lyd_validate_all(&tree_copy, ctx, yo->data_validate_options, NULL);
673+
674674
if (!yo->data_operational.in) {
675-
lyd_free_all(tree);
675+
lyd_free_all(tree_copy);
676676
}
677677

678678
yo->data_ext = 0;
@@ -700,7 +700,7 @@ cmd_data_process(struct ly_ctx *ctx, struct yl_opt *yo)
700700
struct cmdline_file *input_f = (struct cmdline_file *)yo->data_inputs.objs[u];
701701

702702
if (yo->data_ext) {
703-
ret = parse_extension_instance(ctx, yo, input_f, oper_tree);
703+
ret = parse_extension_instance(ctx, yo, input_f, &tree, oper_tree);
704704
} else {
705705
ret = parse_input_by_type(ctx, yo->data_type, input_f, yo->data_parse_options, yo->data_validate_options, &tree, &op, &yo->reply_rpc);
706706
}

tools/lint/main_ni.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ fill_context(int argc, char *argv[], struct yl_opt *yo, struct ly_ctx **ctx)
694694
return -1;
695695
}
696696
break;
697-
case 'k': /* --ext-id */
697+
case 'k': /* --ext-inst */
698698
if (parse_ext_string(optarg, yo)) {
699699
YLMSG_E("Invalid name of extension instance.");
700700
return -1;

0 commit comments

Comments
 (0)