Fixed: [Autocli: error when empty YANG group and grouping-treeref=true](https://github.com/clicon/clixon/issues/579)
This commit is contained in:
parent
21476c1399
commit
3332dfef20
4 changed files with 44 additions and 22 deletions
|
|
@ -38,6 +38,7 @@ Developers may need to change their code
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
|
||||||
|
* Fixed: [Autocli: error when empty YANG group and grouping-treeref=true](https://github.com/clicon/clixon/issues/579)
|
||||||
* Fixed: [Mem error when more multiple uses on top level with multiple statements in grouping](https://github.com/clicon/clixon/issues/583)
|
* Fixed: [Mem error when more multiple uses on top level with multiple statements in grouping](https://github.com/clicon/clixon/issues/583)
|
||||||
* Fixed: [Change CLICON_NETCONF_DUPLICATE_ALLOW to remove duplicates](https://github.com/clicon/clixon-controller/issues/160)
|
* Fixed: [Change CLICON_NETCONF_DUPLICATE_ALLOW to remove duplicates](https://github.com/clicon/clixon-controller/issues/160)
|
||||||
* Fixed: Segv in canonical xpath transform
|
* Fixed: Segv in canonical xpath transform
|
||||||
|
|
|
||||||
|
|
@ -1611,6 +1611,29 @@ yang2cli_post(clixon_handle h,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Helper function: add parsetree header and add parsetree
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
ph_add_set(cligen_handle h,
|
||||||
|
char *treename,
|
||||||
|
parse_tree *pt)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
pt_head *ph;
|
||||||
|
|
||||||
|
if ((ph = cligen_ph_add(h, treename)) == NULL){
|
||||||
|
clixon_err(OE_UNIX, 0, "cligen_ph_add");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (cligen_ph_parsetree_set(ph, pt) < 0){
|
||||||
|
clixon_err(OE_UNIX, 0, "cligen_ph_parsetree_set");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
retval = 0;
|
||||||
|
done:
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Generate clispec for all modules in a grouping
|
/*! Generate clispec for all modules in a grouping
|
||||||
*
|
*
|
||||||
* Called in cli main function for top-level yangs. But may also be called dynamically for
|
* Called in cli main function for top-level yangs. But may also be called dynamically for
|
||||||
|
|
@ -1625,7 +1648,7 @@ yang2cli_post(clixon_handle h,
|
||||||
* @see yang2cli_yspec and yang2cli_stmt for original
|
* @see yang2cli_yspec and yang2cli_stmt for original
|
||||||
* XXX merge with yang2cli_yspec
|
* XXX merge with yang2cli_yspec
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
yang2cli_grouping(clixon_handle h,
|
yang2cli_grouping(clixon_handle h,
|
||||||
yang_stmt *ys,
|
yang_stmt *ys,
|
||||||
char *treename)
|
char *treename)
|
||||||
|
|
@ -1634,7 +1657,6 @@ yang2cli_grouping(clixon_handle h,
|
||||||
parse_tree *pt0 = NULL;
|
parse_tree *pt0 = NULL;
|
||||||
parse_tree *pt = NULL;
|
parse_tree *pt = NULL;
|
||||||
yang_stmt *yc;
|
yang_stmt *yc;
|
||||||
pt_head *ph;
|
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
int treeref_state = 0;
|
int treeref_state = 0;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
|
|
@ -1668,8 +1690,13 @@ yang2cli_grouping(clixon_handle h,
|
||||||
if (yang2cli_stmt(h, yc, 1, cb) < 0)
|
if (yang2cli_stmt(h, yc, 1, cb) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (cbuf_len(cb) == 0)
|
if (cbuf_len(cb) == 0){
|
||||||
goto empty;
|
/* Create empty tree */
|
||||||
|
if (ph_add_set(cli_cligen(h), treename, pt0) < 0)
|
||||||
|
goto done;
|
||||||
|
pt0 = NULL;
|
||||||
|
goto ok;
|
||||||
|
}
|
||||||
/* Note Tie-break of same top-level symbol: prefix is NYI
|
/* Note Tie-break of same top-level symbol: prefix is NYI
|
||||||
* Needs to move cligen_parse_str() call here instead of later
|
* Needs to move cligen_parse_str() call here instead of later
|
||||||
*/
|
*/
|
||||||
|
|
@ -1726,15 +1753,10 @@ yang2cli_grouping(clixon_handle h,
|
||||||
if (cligen_expandv_str2fn(pt0, (expandv_str2fn_t*)clixon_str2fn, NULL) < 0)
|
if (cligen_expandv_str2fn(pt0, (expandv_str2fn_t*)clixon_str2fn, NULL) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Append cligen tree and name it */
|
/* Append cligen tree and name it */
|
||||||
if ((ph = cligen_ph_add(cli_cligen(h), treename)) == NULL){
|
if (ph_add_set(cli_cligen(h), treename, pt0) < 0)
|
||||||
clixon_err(OE_UNIX, 0, "cligen_ph_add");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
if (cligen_ph_parsetree_set(ph, pt0) < 0){
|
|
||||||
clixon_err(OE_UNIX, 0, "cligen_ph_parsetree_set");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
pt0 = NULL;
|
pt0 = NULL;
|
||||||
|
ok:
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
if (pt)
|
if (pt)
|
||||||
|
|
@ -1769,7 +1791,6 @@ yang2cli_yspec(clixon_handle h,
|
||||||
parse_tree *pt0 = NULL;
|
parse_tree *pt0 = NULL;
|
||||||
parse_tree *pt = NULL;
|
parse_tree *pt = NULL;
|
||||||
yang_stmt *ymod;
|
yang_stmt *ymod;
|
||||||
pt_head *ph;
|
|
||||||
int enable;
|
int enable;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
|
|
@ -1858,14 +1879,8 @@ yang2cli_yspec(clixon_handle h,
|
||||||
if (cligen_expandv_str2fn(pt0, (expandv_str2fn_t*)clixon_str2fn, NULL) < 0)
|
if (cligen_expandv_str2fn(pt0, (expandv_str2fn_t*)clixon_str2fn, NULL) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Append cligen tree and name it */
|
/* Append cligen tree and name it */
|
||||||
if ((ph = cligen_ph_add(cli_cligen(h), treename)) == NULL){
|
if (ph_add_set(cli_cligen(h), treename, pt0) < 0)
|
||||||
clixon_err(OE_UNIX, 0, "cligen_ph_add");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
if (cligen_ph_parsetree_set(ph, pt0) < 0){
|
|
||||||
clixon_err(OE_UNIX, 0, "cligen_ph_parsetree_set");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
pt0 = NULL;
|
pt0 = NULL;
|
||||||
#if 0
|
#if 0
|
||||||
if (clicon_data_int_get(h, "autocli-print-debug") == 1){
|
if (clicon_data_int_get(h, "autocli-print-debug") == 1){
|
||||||
|
|
@ -1956,8 +1971,10 @@ yang2cli_grouping_wrap(cligen_handle ch,
|
||||||
goto ok;
|
goto ok;
|
||||||
if ((ret = yang2cli_grouping(h, ygrouping, name)) < 0)
|
if ((ret = yang2cli_grouping(h, ygrouping, name)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0) /* tree empty */
|
if (ret == 0){ /* tree empty */
|
||||||
goto ok;
|
clixon_err(OE_UNIX, 0, "Tree empty %s", name);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
*namep = strdup(name);
|
*namep = strdup(name);
|
||||||
ok:
|
ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@
|
||||||
*/
|
*/
|
||||||
int yang2cli_cmd_encode(cbuf *cb, const char *delim, char *tag, char *domain, char *spec, char *modname, char *id);
|
int yang2cli_cmd_encode(cbuf *cb, const char *delim, char *tag, char *domain, char *spec, char *modname, char *id);
|
||||||
int yang2cli_cmd_decode(char *cmd, const char *delim, char **tag, char **domain, char **spec, char **modname, char **id);
|
int yang2cli_cmd_decode(char *cmd, const char *delim, char **tag, char **domain, char **spec, char **modname, char **id);
|
||||||
int yang2cli_grouping(clixon_handle h, yang_stmt *ys, char *treename);
|
|
||||||
int yang2cli_yspec(clixon_handle h, yang_stmt *yspec, char *treename);
|
int yang2cli_yspec(clixon_handle h, yang_stmt *yspec, char *treename);
|
||||||
int yang2cli_grouping_wrap(cligen_handle ch, char *name, cvec *cvt, void *arg, char **namep);
|
int yang2cli_grouping_wrap(cligen_handle ch, char *name, cvec *cvt, void *arg, char **namep);
|
||||||
int yang2cli_init(clixon_handle h);
|
int yang2cli_init(clixon_handle h);
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,10 @@ module example {
|
||||||
type string;
|
type string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
grouping pg5 {
|
||||||
|
description "Empty, see https://github.com/clicon/clixon/issues/579";
|
||||||
|
action reset;
|
||||||
|
}
|
||||||
container table{
|
container table{
|
||||||
list parameter{
|
list parameter{
|
||||||
key name;
|
key name;
|
||||||
|
|
@ -119,6 +123,7 @@ module example {
|
||||||
}
|
}
|
||||||
uses pg1;
|
uses pg1;
|
||||||
uses ext:pg2;
|
uses ext:pg2;
|
||||||
|
uses pg5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uses pg1;
|
uses pg1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue