From 794a17c2bb4b6afd775abcff5db8d044613c49ff Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 28 Sep 2023 17:31:14 +0200 Subject: [PATCH] Valgrind fixes --- CHANGELOG.md | 32 +++++++++++++++++--------------- lib/src/clixon_json_parse.h | 1 + lib/src/clixon_json_parse.y | 7 +++++-- test/README.md | 2 ++ test/valgrind-clixon.supp | 7 +++++++ 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be0ebff3..4e5be53e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,12 +44,29 @@ ## 6.4.0 Expected: October 2023 +Clixon 6.4.0 features mainly bugfixes and improvements of existing functionality, such as CLI output pipes. + ### API changes on existing protocol/config features Users may have to change how they access the system * New `clixon-autocli@2023-09-01.yang` revision * Added argument to alias extension +### Minor features + +* CLI show compare example function: + * Improved diff algorithm for XML and TEXT/curly, replaced UNIX diff with structural in-mem algorithm +* JSON: Added unicode BMP support for unicode strings as part of fixing (https://github.com/clicon/clixon/issues/453) +* Example cli pipe grep command quotes vertical bar for OR function +* Added: [Feature request: node's alias for CLI](https://github.com/clicon/clixon/issues/434) + * Note: "Skip" is for all nodes, but "Alias" is only for leafs +* New command-line option for dumping configuration options for all clixon applications after load + * Syntax is `-C ` + * Example: `clixon_backend -1C json` +* Removed sending restconf config inline using -R when CLICON_BACKEND_RESTCONF_PROCESS=true + * Define RESTCONF_INLINE to revert +* Clarified clixon_cli command-line: `clixon_cli [options] [commands] [-- extra-options]` + ### C/CLI-API changes on existing features Developers may need to change their code @@ -74,21 +91,6 @@ Developers may need to change their code * CLI pipe function: added arg to `pipe_tail_fn()` -### Minor features - -* CLI show compare example function: - * Improved diff algorithm for XML and TEXT/curly, replaced UNIX diff with structural in-mem algorithm -* JSON: Added unicode BMP support for unicode strings as part of fixing (https://github.com/clicon/clixon/issues/453) -* Example cli pipe grep command quotes vertical bar for OR function -* Added: [Feature request: node's alias for CLI](https://github.com/clicon/clixon/issues/434) - * Note: "Skip" is for all nodes, but "Alias" is only for leafs -* New command-line option for dumping configuration options for all clixon applications after load - * Syntax is `-C ` - * Example: `clixon_backend -1C json` -* Removed sending restconf config inline using -R when CLICON_BACKEND_RESTCONF_PROCESS=true - * Define RESTCONF_INLINE to revert -* Clarified clixon_cli command-line: `clixon_cli [options] [commands] [-- extra-options]` - ### Corrected Bugs * Fixed: ["show compare" and "show compare | display cli" differs #23](https://github.com/clicon/clixon-controller/issues/23) diff --git a/lib/src/clixon_json_parse.h b/lib/src/clixon_json_parse.h index 47199b86..839ccec4 100644 --- a/lib/src/clixon_json_parse.h +++ b/lib/src/clixon_json_parse.h @@ -48,6 +48,7 @@ struct clixon_json_yacc { cxobj *jy_current; /* cxobj active element (changes with parse context) */ cxobj **jy_xvec; /* Vector of created top-level nodes (to know which are created) */ int jy_xlen; /* Length of jy_xvec */ + cbuf *jy_cbuf_str; /* cbuf used for strings, if error needs to be deallocated */ }; typedef struct clixon_json_yacc clixon_json_yacc; diff --git a/lib/src/clixon_json_parse.y b/lib/src/clixon_json_parse.y index 8e815069..0170e2ea 100644 --- a/lib/src/clixon_json_parse.y +++ b/lib/src/clixon_json_parse.y @@ -156,6 +156,8 @@ clixon_json_parseerror(void *_jy, _JY->jy_linenum , s, clixon_json_parsetext); + if (_JY->jy_cbuf_str) + cbuf_free(_JY->jy_cbuf_str); return; } @@ -282,7 +284,7 @@ value : J_TRUE { json_current_body(_JY, "true"); _PARSE_DEBUG("va | object { _PARSE_DEBUG("value->object"); } | array { _PARSE_DEBUG("value->array"); } | number { json_current_body(_JY, $1); free($1); _PARSE_DEBUG("value->number");} - | string { json_current_body(_JY, cbuf_get($1)); cbuf_free($1); _PARSE_DEBUG("value->string");} + | string { json_current_body(_JY, cbuf_get($1)); cbuf_free($1); _JY->jy_cbuf_str = NULL; _PARSE_DEBUG("value->string");} ; @@ -294,7 +296,7 @@ objlist : pair { _PARSE_DEBUG("objlist->pair");} | objlist ',' pair { _PARSE_DEBUG("objlist->objlist , pair");} ; -pair : string { json_current_new(_JY, cbuf_get($1));cbuf_free($1);} ':' +pair : string { json_current_new(_JY, cbuf_get($1));cbuf_free($1); _JY->jy_cbuf_str = NULL;} ':' value { json_current_pop(_JY);}{ _PARSE_DEBUG("pair->string : value");} ; @@ -320,6 +322,7 @@ ustring : ustring J_STRING | J_STRING { cbuf *cb = cbuf_new(); + _JY->jy_cbuf_str = cb; cbuf_append_str(cb,$1); $$=cb; } diff --git a/test/README.md b/test/README.md index 8ba1210d..eeb7cece 100644 --- a/test/README.md +++ b/test/README.md @@ -98,6 +98,8 @@ The `mem.sh` runs memory checks using valgrind. Start it with no arguments to te mem.sh restconf backend # Only backend and cli ``` +Valgrind uses a suppression file `valgrind-clixon.supp` to filter dlopen functions + ## Run pattern of tests The above scripts work with the `pattern` variable to limit the scope of which tests run, eg: diff --git a/test/valgrind-clixon.supp b/test/valgrind-clixon.supp index 58be549a..a36720b4 100644 --- a/test/valgrind-clixon.supp +++ b/test/valgrind-clixon.supp @@ -29,6 +29,13 @@ fun:* fun:_dl_check_map_versions } +{ + supp4.1 + Memcheck:Leak + match-leak-kinds: reachable + fun:* + fun:_dl_check_map_versions +} { supp5 Memcheck:Leak