memleaks, cli-generate leafref

This commit is contained in:
Olof hagsand 2017-06-06 22:09:37 +02:00
parent 07fe90b4c4
commit 91f91fe526
7 changed files with 70 additions and 14 deletions

View file

@ -155,6 +155,7 @@ static int
backend_plugin_unload(clicon_handle h,
struct plugin *plg)
{
int retval=-1;
char *error;
/* Call exit function is it exists */
@ -165,12 +166,14 @@ backend_plugin_unload(clicon_handle h,
if (dlclose(plg->p_handle) != 0) {
error = (char*)dlerror();
clicon_err(OE_UNIX, 0, "dlclose: %s", error?error:"Unknown error");
return -1;
goto done;
/* Just report */
}
else
clicon_debug(1, "Plugin '%s' unloaded.", plg->p_name);
return 0;
retval = 0;
done:
return retval;
}
@ -357,6 +360,7 @@ backend_plugin_load_dir(clicon_handle h,
goto quit;
if (plugin_append(new) < 0)
goto quit;
free(new);
}
/* Now load the rest. Note plugins is the global variable */
@ -371,6 +375,7 @@ backend_plugin_load_dir(clicon_handle h,
/* Append to 'plugins' */
if (plugin_append(new) < 0)
goto quit;
free(new);
}
/* All good. */

View file

@ -275,9 +275,24 @@ yang2cli_var_sub(clicon_handle h,
if (helptext)
cprintf(cb0, "(\"%s\")", helptext);
if (completion){
if (cli_expand_var_generate(h, ys, cvtype, cb0,
options, fraction_digits) < 0)
goto done;
if (type && (strcmp(type, "leafref") == 0)){
yang_stmt *ypath;
if ((ypath = yang_find((yang_node*)ytype, Y_PATH, NULL)) == NULL){
clicon_err(OE_XML, 0, "leafref should have path sub");
goto done;
}
clicon_debug(1, "%s ypath:%s\n", __FUNCTION__, ypath->ys_argument);
cprintf(cb0, "|<%s:%s", ys->ys_argument,
cv_type2str(cvtype));
cprintf(cb0, " %s(\"candidate\",\"%s\")>",
GENERATE_EXPAND_XMLDB,
ypath->ys_argument);
}
else
if (cli_expand_var_generate(h, ys, cvtype, cb0,
options, fraction_digits) < 0)
goto done;
if (helptext)
cprintf(cb0, "(\"%s\")", helptext);
cprintf(cb0, ")");