Fixed memory leaks at -V

This commit is contained in:
Olof hagsand 2024-02-18 22:42:12 +01:00
parent 8f2601bfdf
commit 9bc60abe2e
6 changed files with 11 additions and 7 deletions

View file

@ -846,7 +846,7 @@ main(int argc,
if (print_version){ if (print_version){
if (clixon_plugin_version_all(h, stdout) < 0) if (clixon_plugin_version_all(h, stdout) < 0)
goto done; goto done;
exit(0); goto ok;
} }
/* Load Yang modules /* Load Yang modules
* 1. Load a yang module as a specific absolute filename */ * 1. Load a yang module as a specific absolute filename */

View file

@ -786,7 +786,8 @@ main(int argc,
if (print_version){ if (print_version){
if (clixon_plugin_version_all(h, stdout) < 0) if (clixon_plugin_version_all(h, stdout) < 0)
goto done; goto done;
exit(0); retval = 0;
goto done;
} }
/* Add (hardcoded) netconf features in case ietf-netconf loaded here /* Add (hardcoded) netconf features in case ietf-netconf loaded here
* Otherwise it is loaded in netconf_module_load below * Otherwise it is loaded in netconf_module_load below

View file

@ -876,7 +876,7 @@ main(int argc,
if (print_version){ if (print_version){
if (clixon_plugin_version_all(h, stdout) < 0) if (clixon_plugin_version_all(h, stdout) < 0)
goto done; goto done;
exit(0); goto ok;
} }
/* Load Yang modules /* Load Yang modules
* 1. Load a yang module as a specific absolute filename */ * 1. Load a yang module as a specific absolute filename */

View file

@ -503,7 +503,7 @@ main(int argc,
if (print_version){ if (print_version){
if (clixon_plugin_version_all(h, stdout) < 0) if (clixon_plugin_version_all(h, stdout) < 0)
goto done; goto done;
exit(0); goto ok;
} }
/* Create a pseudo-plugin to create extension callback to set the ietf-routing /* Create a pseudo-plugin to create extension callback to set the ietf-routing
* yang-data extension for api-root top-level restconf function. * yang-data extension for api-root top-level restconf function.

View file

@ -961,7 +961,7 @@ restconf_clixon_init(clixon_handle h,
if (print_version){ if (print_version){
if (clixon_plugin_version_all(h, stdout) < 0) if (clixon_plugin_version_all(h, stdout) < 0)
goto done; goto done;
exit(0); goto ok;
} }
/* Create a pseudo-plugin to create extension callback to set the ietf-routing /* Create a pseudo-plugin to create extension callback to set the ietf-routing
* yang-data extension for api-root top-level restconf function. * yang-data extension for api-root top-level restconf function.
@ -1068,6 +1068,7 @@ restconf_clixon_init(clixon_handle h,
if (ret == 0) if (ret == 0)
goto fail; goto fail;
} }
ok:
retval = 1; retval = 1;
done: done:
if (xerr) if (xerr)

View file

@ -358,6 +358,7 @@ main(int argc,
int zap = 0; int zap = 0;
int config_dump = 0; int config_dump = 0;
enum format_enum config_dump_format = FORMAT_XML; enum format_enum config_dump_format = FORMAT_XML;
int print_version = 0;
/* Create handle */ /* Create handle */
if ((h = clixon_handle_init()) == NULL) if ((h = clixon_handle_init()) == NULL)
@ -382,7 +383,7 @@ main(int argc,
break; break;
case 'V': /* version */ case 'V': /* version */
cligen_output(stdout, "Clixon version: %s\n", CLIXON_VERSION_STRING); cligen_output(stdout, "Clixon version: %s\n", CLIXON_VERSION_STRING);
exit(0); print_version++; /* plugins may also print versions w ca-version callback */
break; break;
case 'D' : { /* debug */ case 'D' : { /* debug */
int d = 0; int d = 0;
@ -408,7 +409,8 @@ main(int argc,
goto done; goto done;
break; break;
} }
if (print_version)
goto ok;
/* /*
* Logs, error and debug to stderr or syslog, set debug level * Logs, error and debug to stderr or syslog, set debug level
*/ */