2011/7/27 Osier Yang <jyang(a)redhat.com>:
Hello, there
Per bug
https://bugzilla.redhat.com/show_bug.cgi?id=725322, should
we change the remoteDomainSet* functions into "skipgen", and fix the
leaks like below? (NB, new VIR_FREE statements)
Why not fix the generator instead?
static int
remoteDomainSetBlkioParameters(virDomainPtr dom,
virTypedParameterPtr params,
int nparams,
unsigned int flags)
{
int rv = -1;
int i;
struct private_data *priv = dom->conn->privateData;
remote_domain_set_blkio_parameters_args args;
remote_domain_set_blkio_parameters_args args;
remoteDriverLock(priv);
make_nonnull_domain(&args.dom, dom);
args.flags = flags;
if (remoteSerializeTypedParameters(params,
nparams,
&args.params.params_val,
&args.params.params_len) < 0) {
for (i = 0; i < nparams; i++) {
VIR_FREE(args.params.params_val[i].field);
}
VIR_FREE(args.params.params_val);
This loop should not be needed as remoteSerializeTypedParameters
cleans up in the error case.
xdr_free((xdrproc_t)xdr_remote_domain_set_blkio_parameters_args,
(char
*)&args);
goto done;
}
if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_BLKIO_PARAMETERS,
(xdrproc_t)xdr_remote_domain_set_blkio_parameters_args, (char *)&args,
(xdrproc_t)xdr_void, (char *)NULL) == -1) {
goto done;
}
rv = 0;
done:
if (args.params.params_val) {
for (i = 0; i < nparams; i++) {
VIR_FREE(args.params.params_val[i].field);
}
VIR_FREE(args.params.params_val);
}
remoteDriverUnlock(priv);
return rv;
}
This can be fixed in the generator, but why no use xdr_free here
instead of open coding the free loop?
--
Matthias Bolte
http://photron.blogspot.com