diff --git a/daemon/remote.c b/daemon/remote.c index e1d208c59109f3829c3baeb676ab3bfa2f563531..ad4c767d7c554cef241d0353eaee23fa5a4ab977 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -759,7 +759,7 @@ cleanup: if (val) { for (i = 0; i < nparams; i++) { VIR_FREE(val[i].field); - if (params[i].type == VIR_TYPED_PARAM_STRING) + if (val[i].value.type == VIR_TYPED_PARAM_STRING) VIR_FREE(val[i].value.remote_typed_param_value_u.s); } VIR_FREE(val); @@ -898,9 +898,10 @@ remoteDispatchDomainGetSchedulerParameters(virNetServerPtr server ATTRIBUTE_UNUS cleanup: if (rv < 0) virNetMessageSaveError(rerr); + virTypedParameterArrayClear(params, nparams); + VIR_FREE(params); if (dom) virDomainFree(dom); - VIR_FREE(params); return rv; no_memory: @@ -953,9 +954,10 @@ remoteDispatchDomainGetSchedulerParametersFlags(virNetServerPtr server ATTRIBUTE cleanup: if (rv < 0) virNetMessageSaveError(rerr); + virTypedParameterArrayClear(params, nparams); + VIR_FREE(params); if (dom) virDomainFree(dom); - VIR_FREE(params); return rv; no_memory: @@ -1092,7 +1094,6 @@ remoteDispatchDomainBlockStatsFlags(virNetServerPtr server ATTRIBUTE_UNUSED, { virTypedParameterPtr params = NULL; virDomainPtr dom = NULL; - int i; const char *path = args->path; int nparams = args->nparams; unsigned int flags; @@ -1140,17 +1141,12 @@ success: rv = 0; cleanup: - if (rv < 0) { + if (rv < 0) virNetMessageSaveError(rerr); - if (ret->params.params_val) { - for (i = 0; i < nparams; i++) - VIR_FREE(ret->params.params_val[i].field); - VIR_FREE(ret->params.params_val); - } - } + virTypedParameterArrayClear(params, nparams); + VIR_FREE(params); if (dom) virDomainFree(dom); - VIR_FREE(params); return rv; } @@ -1623,9 +1619,10 @@ success: cleanup: if (rv < 0) virNetMessageSaveError(rerr); + virTypedParameterArrayClear(params, nparams); + VIR_FREE(params); if (dom) virDomainFree(dom); - VIR_FREE(params); return rv; } diff --git a/src/rpc/genprotocol.pl b/src/rpc/genprotocol.pl index 7af1b3bd124e44d4d60790d8bda6d0b98470a9ee..48383255d982067ae36099fbcee72feb54c84c4f 100755 --- a/src/rpc/genprotocol.pl +++ b/src/rpc/genprotocol.pl @@ -67,12 +67,12 @@ while () { # Note: The body of the function is in @function. # Remove decl of buf, if buf isn't used in the function. - my @uses = grep /\bbuf\b/, @function; - @function = grep !/\bbuf\b/, @function if @uses == 1; + my @uses = grep /[^.>]\bbuf\b/, @function; + @function = grep !/[^.>]\bbuf\b/, @function if @uses == 1; # Remove decl of i, if i isn't used in the function. - @uses = grep /\bi\b/, @function; - @function = grep !/\bi\b/, @function if @uses == 1; + @uses = grep /[^.>]\bi\b/, @function; + @function = grep !/[^.>]\bi\b/, @function if @uses == 1; # (char **)&objp->... gives: # warning: dereferencing type-punned pointer will break