Docs update, externalized cvec_concat_cb, example mem-leak

This commit is contained in:
Olof hagsand 2023-08-15 20:20:44 +02:00
parent e4a7fe0b49
commit fc73493881
7 changed files with 11 additions and 6 deletions

View file

@ -64,7 +64,7 @@ In some cases, Clixon uses three-value returns as follows:
- `0` Invalid - `0` Invalid
- `-1` Fatal error - `-1` Fatal error
### Return values ### Return values and goto:s
Clixon uses goto:s only to get a single point of exit functions as follows: Clixon uses goto:s only to get a single point of exit functions as follows:
``` ```
@ -80,7 +80,7 @@ Clixon uses goto:s only to get a single point of exit functions as follows:
Notes: Notes:
1. Use only a single return statement in a function 1. Use only a single return statement in a function
2. Do not use of goto:s in other ways 2. Do not use goto:s in other ways
### Comments ### Comments

View file

@ -402,7 +402,7 @@ cli_dbxml(clicon_handle h,
clicon_err(OE_UNIX, errno, "cbuf_new"); clicon_err(OE_UNIX, errno, "cbuf_new");
goto done; goto done;
} }
/* Concatenate all argv strings to a sinle string */ /* Concatenate all argv strings to a single string */
if (cvec_concat_cb(argv, api_path_fmt_cb) < 0) if (cvec_concat_cb(argv, api_path_fmt_cb) < 0)
goto done; goto done;
api_path_fmt = cbuf_get(api_path_fmt_cb); api_path_fmt = cbuf_get(api_path_fmt_cb);
@ -1670,7 +1670,9 @@ cvec_concat_cb(cvec *cvv,
} }
/* Append a api_path_fmt from sub-parts */ /* Append a api_path_fmt from sub-parts */
for (i=argc-1; i>=0; i--){ for (i=argc-1; i>=0; i--){
cprintf(cb, "%s", cv_string_get(cvec_i(cvv, i))); cv = cvec_i(cvv, i);
str = cv_string_get(cv);
cprintf(cb, "%s", str);
} }
retval = 0; retval = 0;
done: done:

View file

@ -43,7 +43,6 @@ void cli_signal_block(clicon_handle h);
void cli_signal_unblock(clicon_handle h); void cli_signal_unblock(clicon_handle h);
int mtpoint_paths(yang_stmt *yspec0, char *mtpoint, char *api_path_fmt1, char **api_path_fmt01); int mtpoint_paths(yang_stmt *yspec0, char *mtpoint, char *api_path_fmt1, char **api_path_fmt01);
cvec *cvec_append(cvec *cvv0, cvec *cvv1); cvec *cvec_append(cvec *cvv0, cvec *cvv1);
int cvec_concat_cb(cvec *cvv, cbuf *cb);
/* If you do not find a function here it may be in clixon_cli_api.h which is /* If you do not find a function here it may be in clixon_cli_api.h which is
the external API */ the external API */

View file

@ -111,6 +111,7 @@ int cli_unlock(clicon_handle h, cvec *cvv, cvec *argv);
int cli_copy_config(clicon_handle h, cvec *cvv, cvec *argv); int cli_copy_config(clicon_handle h, cvec *cvv, cvec *argv);
int cli_help(clicon_handle h, cvec *vars, cvec *argv); int cli_help(clicon_handle h, cvec *vars, cvec *argv);
cvec *cvec_append(cvec *cvv0, cvec *cvv1); cvec *cvec_append(cvec *cvv0, cvec *cvv1);
int cvec_concat_cb(cvec *cvv, cbuf *cb);
int cli_process_control(clicon_handle h, cvec *vars, cvec *argv); int cli_process_control(clicon_handle h, cvec *vars, cvec *argv);
/* In cli_show.c */ /* In cli_show.c */

View file

@ -163,7 +163,7 @@ What to think about when doing a new release.
* Ensure all extended tests run OK: valgrind, vagrant, afl * Ensure all extended tests run OK: valgrind, vagrant, afl
* Review CHANGELOG, write one-liner * Review CHANGELOG, write one-liner
* Draft a new release and review generated release notes and use info to update CHANGELOG * Draft a new release and review generated release notes and use info to update CHANGELOG
* Review README.md wording about latest release * Review README.md
* New yang/clicon/clixon-config@XXX.yang revision? * New yang/clicon/clixon-config@XXX.yang revision?
* In configure.ac, for minor releases change CLIXON_VERSION in configure.ac to eg: (minor should have been bumped): * In configure.ac, for minor releases change CLIXON_VERSION in configure.ac to eg: (minor should have been bumped):
``` ```

View file

@ -1369,6 +1369,8 @@ example_daemon(clicon_handle h)
} }
retval = 0; retval = 0;
done: done:
if (xerr)
xml_free(xerr);
if (fp) if (fp)
fclose(fp); fclose(fp);
return retval; return retval;

View file

@ -554,6 +554,7 @@ xmltree2cbuf(cbuf *cb,
* Therefore checking for empty XML must be done by a calling function which knows wether the * Therefore checking for empty XML must be done by a calling function which knows wether the
* the XML represents a full document or not. * the XML represents a full document or not.
* @note may be called recursively, some yang-bind (eg rpc) semantic checks may trigger error message * @note may be called recursively, some yang-bind (eg rpc) semantic checks may trigger error message
* @note yang-binding over schema mount-points do not work, you need to make a separate bind call
*/ */
static int static int
_xml_parse(const char *str, _xml_parse(const char *str,