diff --git a/apps/restconf/restconf_err.c b/apps/restconf/restconf_err.c
index 3525e6f9..28f55196 100644
--- a/apps/restconf/restconf_err.c
+++ b/apps/restconf/restconf_err.c
@@ -128,6 +128,8 @@ restconf_not_acceptable(clixon_handle h,
goto done;
retval = 0;
done:
+ if (xerr)
+ xml_free(xerr);
return retval;
}
diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c
index 3c399cda..e7ce5236 100644
--- a/lib/src/clixon_netconf_lib.c
+++ b/lib/src/clixon_netconf_lib.c
@@ -1202,20 +1202,24 @@ netconf_operation_not_supported_xml(cxobj **xret,
int retval =-1;
cxobj *xerr;
char *encstr = NULL;
+ cxobj *x = NULL;
if (xret == NULL){
clixon_err(OE_NETCONF, EINVAL, "xret is NULL");
goto done;
}
if (*xret == NULL){
- if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
+ if ((x = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
goto done;
}
- else if (xml_name_set(*xret, "rpc-reply") < 0)
+ else {
+ x = *xret;
+ if (xml_name_set(x, "rpc-reply") < 0)
+ goto done;
+ }
+ if (xml_add_attr(x, "xmlns", NETCONF_BASE_NAMESPACE, NULL, NULL) == NULL)
goto done;
- if (xml_add_attr(*xret, "xmlns", NETCONF_BASE_NAMESPACE, NULL, NULL) == NULL)
- goto done;
- if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
+ if ((xerr = xml_new("rpc-error", x, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s"
"operation-not-supported"
@@ -1225,12 +1229,17 @@ netconf_operation_not_supported_xml(cxobj **xret,
if (message){
if (xml_chardata_encode(&encstr, 0, "%s", message) < 0)
goto done;
- if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s",
- encstr) < 0)
- goto done;
+ if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s",
+ encstr) < 0)
+ goto done;
}
+ if (x != *xret)
+ *xret = x;
+ x = NULL;
retval = 0;
done:
+ if (x && x != *xret)
+ xml_free(x);
if (encstr)
free(encstr);
return retval;
diff --git a/lib/src/clixon_plugin.c b/lib/src/clixon_plugin.c
index 1d0f8114..68cb46b1 100644
--- a/lib/src/clixon_plugin.c
+++ b/lib/src/clixon_plugin.c
@@ -1533,7 +1533,6 @@ upgrade_callback_call(clixon_handle h,
{
int retval = -1;
upgrade_callback_t *uc;
- int nr = 0; /* How many callbacks */
int ret;
plugin_module_struct *ms = plugin_module_struct_get(h);
@@ -1564,7 +1563,6 @@ upgrade_callback_call(clixon_handle h,
}
goto fail;
}
- nr++;
}
uc = NEXTQ(upgrade_callback_t *, uc);
} while (uc != ms->ms_upgrade_callbacks);
diff --git a/lib/src/clixon_validate_minmax.c b/lib/src/clixon_validate_minmax.c
index 55d582bc..396575d6 100644
--- a/lib/src/clixon_validate_minmax.c
+++ b/lib/src/clixon_validate_minmax.c
@@ -912,7 +912,6 @@ xml_yang_validate_unique(cxobj *xt,
yang_stmt *y;
yang_stmt *yprev = NULL;
enum rfc_6020 keyw;
- int nr = 0;
int ret;
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL){
@@ -922,10 +921,8 @@ xml_yang_validate_unique(cxobj *xt,
if (keyw == Y_LIST || keyw == Y_LEAF_LIST){
/* equal: just continue*/
if (y == yprev){
- nr++;
continue;
}
- nr=1;
/* new list check */
switch (keyw){
case Y_LIST:
diff --git a/test/lib.sh b/test/lib.sh
index a08d02b0..4a1b76c2 100755
--- a/test/lib.sh
+++ b/test/lib.sh
@@ -596,6 +596,7 @@ function start_restconf(){
if [ $? -ne 0 ]; then
err1 "expected 0" "$?"
fi
+ RCPID=$!
}
# Stop restconf daemon before test
@@ -609,10 +610,12 @@ function stop_restconf_pre(){
# 2) Dont use -u $WWWUSER since clixon_restconf may drop privileges.
# 3) After fork, it seems to take some time before name is right
function stop_restconf(){
- sudo pkill -f clixon_restconf
- if [ $valgrindtest -eq 3 ]; then
+ if [ $valgrindtest -eq 3 ]; then
+ sudo kill ${RCPID}
sleep 1
checkvalgrind
+ else
+ sudo pkill -f clixon_restconf
fi
}
diff --git a/test/mem.sh b/test/mem.sh
index 0778357e..df74fdf8 100755
--- a/test/mem.sh
+++ b/test/mem.sh
@@ -13,7 +13,6 @@ function memonce(){
valgrindfile=$(mktemp)
echo "valgrindfile:$valgrindfile"
-
clixon_backend=
clixon_restconf=
clixon_cli=
@@ -30,9 +29,10 @@ function memonce(){
;;
'restconf')
valgrindtest=3 # This means restconf valgrind test
+ sudo chown root $valgrindfile
+ sudo chmod 777 $valgrindfile
: ${DEMWAIT:=15} # valgrind backend needs some time to get up
clixon_restconf="/usr/bin/valgrind --num-callers=50 --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_restconf"
-
;;
'cli')
valgrindtest=1