mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
simplify block of codes
Using new function 'virTypedParameterArrayClear' to simplify block of codes. * daemon/remote.c, src/remote/remote_driver.c: simplify codes. Signed-off-by: Alex Jia <ajia@redhat.com>
This commit is contained in:
parent
c3c2cc6534
commit
bfdbae0694
@ -848,11 +848,7 @@ remoteDeserializeTypedParameters(remote_typed_param *args_params_val,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
int j;
|
virTypedParameterArrayClear(params, i);
|
||||||
for (j = 0; j < i; ++j) {
|
|
||||||
if (params[j].type == VIR_TYPED_PARAM_STRING)
|
|
||||||
VIR_FREE(params[j].value.s);
|
|
||||||
}
|
|
||||||
VIR_FREE(params);
|
VIR_FREE(params);
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "intprops.h"
|
#include "intprops.h"
|
||||||
|
#include "virtypedparam.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_REMOTE
|
#define VIR_FROM_THIS VIR_FROM_REMOTE
|
||||||
|
|
||||||
@ -1417,12 +1418,8 @@ remoteDeserializeTypedParameters(remote_typed_param *ret_params_val,
|
|||||||
rv = 0;
|
rv = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (rv < 0) {
|
if (rv < 0)
|
||||||
int j;
|
virTypedParameterArrayClear(params, i);
|
||||||
for (j = 0; j < i; j++)
|
|
||||||
if (params[j].type == VIR_TYPED_PARAM_STRING)
|
|
||||||
VIR_FREE(params[j].value.s);
|
|
||||||
}
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2384,15 +2381,9 @@ static int remoteDomainGetCPUStats(virDomainPtr domain,
|
|||||||
|
|
||||||
rv = ret.nparams;
|
rv = ret.nparams;
|
||||||
cleanup:
|
cleanup:
|
||||||
if (rv < 0) {
|
if (rv < 0)
|
||||||
int max = nparams * ncpus;
|
virTypedParameterArrayClear(params, nparams * ncpus);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < max; i++) {
|
|
||||||
if (params[i].type == VIR_TYPED_PARAM_STRING)
|
|
||||||
VIR_FREE(params[i].value.s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xdr_free ((xdrproc_t) xdr_remote_domain_get_cpu_stats_ret,
|
xdr_free ((xdrproc_t) xdr_remote_domain_get_cpu_stats_ret,
|
||||||
(char *) &ret);
|
(char *) &ret);
|
||||||
done:
|
done:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user