Currently some, but not all, methods have a call to the
xdr_free function, for the 'ret' variable. This is done
on methods where there are complex structs containing
allocated memory. In other cases the structs contain
allocated memory, but the pointer is stolen, so xdr_free
is not called. In other cases no allocated memory is
present, so xdr_free.
This is hard to reason about, because the definition of
the struct is not visible in the client stubs.
Switch to use g_auto() for the 'ret' variable, which
means 'xdr_free' is always going to be called. Some
places now need to use g_steal_pointer as a result.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/remote/remote_driver.c | 754 +++++++++++--------------------------
1 file changed, 230 insertions(+), 524 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index a4c60be3d7..02a687a700 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -683,7 +683,7 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr conn,
int feature)
{
remote_connect_supports_feature_args args = { feature };
- remote_connect_supports_feature_ret ret = { 0 };
+ g_auto(remote_connect_supports_feature_ret) ret = { 0 };
int rc;
rc = call(conn, priv, 0, REMOTE_PROC_CONNECT_SUPPORTS_FEATURE,
@@ -1386,7 +1386,7 @@ remoteConnectClose(virConnectPtr conn)
static const char *
remoteConnectGetType(virConnectPtr conn)
{
- remote_connect_get_type_ret ret = {0};
+ g_auto(remote_connect_get_type_ret) ret = {0};
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1407,7 +1407,7 @@ remoteConnectGetType(virConnectPtr conn)
static int remoteConnectIsSecure(virConnectPtr conn)
{
struct private_data *priv = conn->privateData;
- remote_connect_is_secure_ret ret = {0};
+ g_auto(remote_connect_is_secure_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
if (call(conn, priv, 0, REMOTE_PROC_CONNECT_IS_SECURE,
@@ -1430,7 +1430,7 @@ static int remoteConnectIsEncrypted(virConnectPtr conn)
{
bool encrypted;
struct private_data *priv = conn->privateData;
- remote_connect_is_secure_ret ret = {0};
+ g_auto(remote_connect_is_secure_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
if (call(conn, priv, 0, REMOTE_PROC_CONNECT_IS_SECURE,
@@ -1457,9 +1457,8 @@ remoteNodeGetCPUStats(virConnectPtr conn,
virNodeCPUStatsPtr params, int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_node_get_cpu_stats_args args = {0};
- remote_node_get_cpu_stats_ret ret = {0};
+ g_auto(remote_node_get_cpu_stats_ret) ret = {0};
size_t i;
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1481,15 +1480,14 @@ remoteNodeGetCPUStats(virConnectPtr conn,
virReportError(VIR_ERR_RPC, "%s",
_("remoteNodeGetCPUStats: "
"returned number of stats exceeds limit"));
- goto cleanup;
+ return -1;
}
/* Handle the case when the caller does not know the number of stats
* and is asking for the number of stats supported
*/
if (*nparams == 0) {
*nparams = ret.nparams;
- rv = 0;
- goto cleanup;
+ return 0;
}
*nparams = ret.params.params_len;
@@ -1500,16 +1498,12 @@ remoteNodeGetCPUStats(virConnectPtr conn,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Stats %s too big for destination"),
ret.params.params_val[i].field);
- goto cleanup;
+ return -1;
}
params[i].value = ret.params.params_val[i].value;
}
- rv = 0;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_node_get_cpu_stats_ret, (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -1519,9 +1513,8 @@ remoteNodeGetMemoryStats(virConnectPtr conn,
int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_node_get_memory_stats_args args = {0};
- remote_node_get_memory_stats_ret ret = {0};
+ g_auto(remote_node_get_memory_stats_ret) ret = {0};
size_t i;
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1541,15 +1534,14 @@ remoteNodeGetMemoryStats(virConnectPtr conn,
virReportError(VIR_ERR_RPC, "%s",
_("remoteNodeGetMemoryStats: "
"returned number of stats exceeds limit"));
- goto cleanup;
+ return -1;
}
/* Handle the case when the caller does not know the number of stats
* and is asking for the number of stats supported
*/
if (*nparams == 0) {
*nparams = ret.nparams;
- rv = 0;
- goto cleanup;
+ return 0;
}
*nparams = ret.params.params_len;
@@ -1560,16 +1552,12 @@ remoteNodeGetMemoryStats(virConnectPtr conn,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Stats %s too big for destination"),
ret.params.params_val[i].field);
- goto cleanup;
+ return -1;
}
params[i].value = ret.params.params_val[i].value;
}
- rv = 0;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_node_get_memory_stats_ret, (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -1579,7 +1567,7 @@ remoteNodeGetCellsFreeMemory(virConnectPtr conn,
int maxCells)
{
remote_node_get_cells_free_memory_args args = {0};
- remote_node_get_cells_free_memory_ret ret = {0};
+ g_auto(remote_node_get_cells_free_memory_ret) ret = {0};
size_t i;
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1602,18 +1590,15 @@ remoteNodeGetCellsFreeMemory(virConnectPtr conn,
for (i = 0; i < ret.cells.cells_len; i++)
freeMems[i] = ret.cells.cells_val[i];
- xdr_free((xdrproc_t) xdr_remote_node_get_cells_free_memory_ret, (char *) &ret);
-
return ret.cells.cells_len;
}
static int
remoteConnectListDomains(virConnectPtr conn, int *ids, int maxids)
{
- int rv = -1;
size_t i;
remote_connect_list_domains_args args = {0};
- remote_connect_list_domains_ret ret = {0};
+ g_auto(remote_connect_list_domains_ret) ret = {0};
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1634,17 +1619,13 @@ remoteConnectListDomains(virConnectPtr conn, int *ids, int
maxids)
virReportError(VIR_ERR_RPC,
_("Too many domains '%d' for limit
'%d'"),
ret.ids.ids_len, maxids);
- goto cleanup;
+ return -1;
}
for (i = 0; i < ret.ids.ids_len; ++i)
ids[i] = ret.ids.ids_val[i];
- rv = ret.ids.ids_len;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_connect_list_domains_ret, (char *) &ret);
- return rv;
+ return ret.ids.ids_len;
}
static int
@@ -1684,9 +1665,8 @@ remoteDomainBlockStatsFlags(virDomainPtr domain,
int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_domain_block_stats_flags_args args = {0};
- remote_domain_block_stats_flags_ret ret = {0};
+ g_auto(remote_domain_block_stats_flags_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1706,7 +1686,7 @@ remoteDomainBlockStatsFlags(virDomainPtr domain,
virReportError(VIR_ERR_RPC, "%s",
_("remoteDomainBlockStatsFlags: "
"returned number of stats exceeds limit"));
- goto cleanup;
+ return -1;
}
/* Handle the case when the caller does not know the number of stats
@@ -1714,8 +1694,7 @@ remoteDomainBlockStatsFlags(virDomainPtr domain,
*/
if (*nparams == 0) {
*nparams = ret.nparams;
- rv = 0;
- goto cleanup;
+ return 0;
}
*nparams = ret.params.params_len;
@@ -1726,14 +1705,9 @@ remoteDomainBlockStatsFlags(virDomainPtr domain,
REMOTE_DOMAIN_BLOCK_STATS_PARAMETERS_MAX,
¶ms,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_block_stats_flags_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -1741,9 +1715,8 @@ remoteDomainGetMemoryParameters(virDomainPtr domain,
virTypedParameterPtr params, int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_domain_get_memory_parameters_args args = {0};
- remote_domain_get_memory_parameters_ret ret = {0};
+ g_auto(remote_domain_get_memory_parameters_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1761,8 +1734,7 @@ remoteDomainGetMemoryParameters(virDomainPtr domain,
*/
if (*nparams == 0) {
*nparams = ret.nparams;
- rv = 0;
- goto cleanup;
+ return 0;
}
if (virTypedParamsDeserialize((struct _virTypedParameterRemote *)
ret.params.params_val,
@@ -1770,14 +1742,9 @@ remoteDomainGetMemoryParameters(virDomainPtr domain,
REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX,
¶ms,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_memory_parameters_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -1785,9 +1752,8 @@ remoteDomainGetNumaParameters(virDomainPtr domain,
virTypedParameterPtr params, int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_domain_get_numa_parameters_args args = {0};
- remote_domain_get_numa_parameters_ret ret = {0};
+ g_auto(remote_domain_get_numa_parameters_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1805,8 +1771,7 @@ remoteDomainGetNumaParameters(virDomainPtr domain,
*/
if (*nparams == 0) {
*nparams = ret.nparams;
- rv = 0;
- goto cleanup;
+ return 0;
}
if (virTypedParamsDeserialize((struct _virTypedParameterRemote *)
ret.params.params_val,
@@ -1814,14 +1779,9 @@ remoteDomainGetNumaParameters(virDomainPtr domain,
REMOTE_DOMAIN_NUMA_PARAMETERS_MAX,
¶ms,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_numa_parameters_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -1830,9 +1790,8 @@ remoteDomainGetLaunchSecurityInfo(virDomainPtr domain,
int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_domain_get_launch_security_info_args args = {0};
- remote_domain_get_launch_security_info_ret ret = {0};
+ g_auto(remote_domain_get_launch_security_info_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1849,14 +1808,9 @@ remoteDomainGetLaunchSecurityInfo(virDomainPtr domain,
REMOTE_DOMAIN_LAUNCH_SECURITY_INFO_PARAMS_MAX,
params,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_launch_security_info_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -1865,9 +1819,8 @@ remoteDomainGetPerfEvents(virDomainPtr domain,
int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_domain_get_perf_events_args args = {0};
- remote_domain_get_perf_events_ret ret = {0};
+ g_auto(remote_domain_get_perf_events_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1884,14 +1837,9 @@ remoteDomainGetPerfEvents(virDomainPtr domain,
REMOTE_DOMAIN_PERF_EVENTS_MAX,
params,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_perf_events_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -1899,9 +1847,8 @@ remoteDomainGetBlkioParameters(virDomainPtr domain,
virTypedParameterPtr params, int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_domain_get_blkio_parameters_args args = {0};
- remote_domain_get_blkio_parameters_ret ret = {0};
+ g_auto(remote_domain_get_blkio_parameters_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1919,8 +1866,7 @@ remoteDomainGetBlkioParameters(virDomainPtr domain,
*/
if (*nparams == 0) {
*nparams = ret.nparams;
- rv = 0;
- goto cleanup;
+ return 0;
}
if (virTypedParamsDeserialize((struct _virTypedParameterRemote *)
ret.params.params_val,
@@ -1928,14 +1874,9 @@ remoteDomainGetBlkioParameters(virDomainPtr domain,
REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX,
¶ms,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_blkio_parameters_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -1945,10 +1886,9 @@ remoteDomainGetVcpuPinInfo(virDomainPtr domain,
int maplen,
unsigned int flags)
{
- int rv = -1;
size_t i;
remote_domain_get_vcpu_pin_info_args args = {0};
- remote_domain_get_vcpu_pin_info_ret ret = {0};
+ g_auto(remote_domain_get_vcpu_pin_info_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -1983,14 +1923,14 @@ remoteDomainGetVcpuPinInfo(virDomainPtr domain,
virReportError(VIR_ERR_RPC,
_("host reports too many vCPUs: %d > %d"),
ret.num, ncpumaps);
- goto cleanup;
+ return -1;
}
if (ret.cpumaps.cpumaps_len > ncpumaps * maplen) {
virReportError(VIR_ERR_RPC,
_("host reports map buffer length exceeds maximum: %d >
%d"),
ret.cpumaps.cpumaps_len, ncpumaps * maplen);
- goto cleanup;
+ return -1;
}
memset(cpumaps, 0, ncpumaps * maplen);
@@ -1998,11 +1938,7 @@ remoteDomainGetVcpuPinInfo(virDomainPtr domain,
for (i = 0; i < ret.cpumaps.cpumaps_len; ++i)
cpumaps[i] = ret.cpumaps.cpumaps_val[i];
- rv = ret.num;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_vcpu_pin_info_ret, (char *) &ret);
- return rv;
+ return ret.num;
}
static int
@@ -2043,10 +1979,9 @@ remoteDomainGetEmulatorPinInfo(virDomainPtr domain,
int maplen,
unsigned int flags)
{
- int rv = -1;
size_t i;
remote_domain_get_emulator_pin_info_args args = {0};
- remote_domain_get_emulator_pin_info_ret ret = {0};
+ g_auto(remote_domain_get_emulator_pin_info_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2073,7 +2008,7 @@ remoteDomainGetEmulatorPinInfo(virDomainPtr domain,
virReportError(VIR_ERR_RPC,
_("host reports map buffer length exceeds maximum: %d >
%d"),
ret.cpumaps.cpumaps_len, maplen);
- goto cleanup;
+ return -1;
}
memset(cpumaps, 0, maplen);
@@ -2081,12 +2016,7 @@ remoteDomainGetEmulatorPinInfo(virDomainPtr domain,
for (i = 0; i < ret.cpumaps.cpumaps_len; ++i)
cpumaps[i] = ret.cpumaps.cpumaps_val[i];
- rv = ret.ret;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_emulator_pin_info_ret,
- (char *) &ret);
- return rv;
+ return ret.ret;
}
static int
@@ -2096,10 +2026,9 @@ remoteDomainGetVcpus(virDomainPtr domain,
unsigned char *cpumaps,
int maplen)
{
- int rv = -1;
size_t i;
remote_domain_get_vcpus_args args = {0};
- remote_domain_get_vcpus_ret ret = {0};
+ g_auto(remote_domain_get_vcpus_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2130,13 +2059,13 @@ remoteDomainGetVcpus(virDomainPtr domain,
virReportError(VIR_ERR_RPC,
_("host reports too many vCPUs: %d > %d"),
ret.info.info_len, maxinfo);
- goto cleanup;
+ return -1;
}
if (ret.cpumaps.cpumaps_len > maxinfo * maplen) {
virReportError(VIR_ERR_RPC,
_("host reports map buffer length exceeds maximum: %d >
%d"),
ret.cpumaps.cpumaps_len, maxinfo * maplen);
- goto cleanup;
+ return -1;
}
memset(info, 0, sizeof(virVcpuInfo) * maxinfo);
@@ -2152,11 +2081,7 @@ remoteDomainGetVcpus(virDomainPtr domain,
for (i = 0; i < ret.cpumaps.cpumaps_len; ++i)
cpumaps[i] = ret.cpumaps.cpumaps_val[i];
- rv = ret.info.info_len;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret);
- return rv;
+ return ret.info.info_len;
}
static int
@@ -2164,11 +2089,10 @@ remoteDomainGetIOThreadInfo(virDomainPtr dom,
virDomainIOThreadInfoPtr **info,
unsigned int flags)
{
- int rv = -1;
size_t i;
struct private_data *priv = dom->conn->privateData;
remote_domain_get_iothread_info_args args = {0};
- remote_domain_get_iothread_info_ret ret = {0};
+ g_auto(remote_domain_get_iothread_info_ret) ret = {0};
remote_domain_iothread_info *src;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2187,7 +2111,7 @@ remoteDomainGetIOThreadInfo(virDomainPtr dom,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Too many IOThreads in info: %d for limit %d"),
ret.info.info_len, REMOTE_IOTHREAD_INFO_MAX);
- goto cleanup;
+ return -1;
}
if (info) {
@@ -2195,8 +2119,7 @@ remoteDomainGetIOThreadInfo(virDomainPtr dom,
if (!ret.info.info_len) {
*info = NULL;
- rv = ret.ret;
- goto cleanup;
+ return ret.ret;
}
info_ret = g_new0(virDomainIOThreadInfoPtr, ret.info.info_len);
@@ -2215,21 +2138,15 @@ remoteDomainGetIOThreadInfo(virDomainPtr dom,
*info = info_ret;
}
- rv = ret.ret;
-
- cleanup:
- xdr_free((xdrproc_t)xdr_remote_domain_get_iothread_info_ret,
- (char *) &ret);
- return rv;
+ return ret.ret;
}
static int
remoteDomainGetSecurityLabel(virDomainPtr domain, virSecurityLabelPtr seclabel)
{
remote_domain_get_security_label_args args = {0};
- remote_domain_get_security_label_ret ret = {0};
+ g_auto(remote_domain_get_security_label_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
- int rv = -1;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_domain(&args.dom, domain);
@@ -2244,26 +2161,21 @@ remoteDomainGetSecurityLabel(virDomainPtr domain,
virSecurityLabelPtr seclabel)
if (virStrcpyStatic(seclabel->label, ret.label.label_val) < 0) {
virReportError(VIR_ERR_RPC, _("security label exceeds maximum:
%zu"),
sizeof(seclabel->label) - 1);
- goto cleanup;
+ return -1;
}
seclabel->enforcing = ret.enforcing;
}
- rv = 0;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_security_label_ret, (char *)&ret);
- return rv;
+ return 0;
}
static int
remoteDomainGetSecurityLabelList(virDomainPtr domain, virSecurityLabelPtr* seclabels)
{
remote_domain_get_security_label_list_args args = {0};
- remote_domain_get_security_label_list_ret ret = {0};
+ g_auto(remote_domain_get_security_label_list_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
size_t i;
- int rv = -1;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_domain(&args.dom, domain);
@@ -2282,16 +2194,12 @@ remoteDomainGetSecurityLabelList(virDomainPtr domain,
virSecurityLabelPtr* secla
virReportError(VIR_ERR_RPC, _("security label exceeds maximum:
%zd"),
sizeof((*seclabels)->label) - 1);
VIR_FREE(*seclabels);
- goto cleanup;
+ return -1;
}
(*seclabels)[i].enforcing = cur->enforcing;
}
}
- rv = ret.ret;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_security_label_list_ret, (char
*)&ret);
- return rv;
+ return ret.ret;
}
static int
@@ -2301,7 +2209,7 @@ remoteDomainGetState(virDomainPtr domain,
unsigned int flags)
{
remote_domain_get_state_args args = {0};
- remote_domain_get_state_ret ret = {0};
+ g_auto(remote_domain_get_state_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2323,9 +2231,8 @@ remoteDomainGetState(virDomainPtr domain,
static int
remoteNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel)
{
- remote_node_get_security_model_ret ret = {0};
+ g_auto(remote_node_get_security_model_ret) ret = {0};
struct private_data *priv = conn->privateData;
- int rv = -1;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
memset(secmodel, 0, sizeof(*secmodel));
@@ -2339,7 +2246,7 @@ remoteNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr
secmodel)
if (virStrcpyStatic(secmodel->model, ret.model.model_val) < 0) {
virReportError(VIR_ERR_RPC, _("security model exceeds maximum:
%zu"),
sizeof(secmodel->model) - 1);
- goto cleanup;
+ return -1;
}
}
@@ -2347,15 +2254,11 @@ remoteNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr
secmodel)
if (virStrcpyStatic(secmodel->doi, ret.doi.doi_val) < 0) {
virReportError(VIR_ERR_RPC, _("security doi exceeds maximum:
%zu"),
sizeof(secmodel->doi) - 1);
- goto cleanup;
+ return -1;
}
}
- rv = 0;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_node_get_security_model_ret, (char *)&ret);
- return rv;
+ return 0;
}
static int
@@ -2366,7 +2269,7 @@ remoteDomainMigratePrepare(virConnectPtr dconn,
unsigned long resource)
{
remote_domain_migrate_prepare_args args = {0};
- remote_domain_migrate_prepare_ret ret = {0};
+ g_auto(remote_domain_migrate_prepare_ret) ret = {0};
struct private_data *priv = dconn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2381,11 +2284,12 @@ remoteDomainMigratePrepare(virConnectPtr dconn,
return -1;
if (ret.cookie.cookie_len > 0) {
- *cookie = ret.cookie.cookie_val; /* Caller frees. */
+ *cookie = g_steal_pointer(&ret.cookie.cookie_val); /* Caller frees. */
*cookielen = ret.cookie.cookie_len;
+ ret.cookie.cookie_len = 0;
}
if (ret.uri_out)
- *uri_out = *ret.uri_out; /* Caller frees. */
+ *uri_out = g_steal_pointer(ret.uri_out); /* Caller frees. */
VIR_FREE(ret.uri_out);
return 0;
@@ -2399,9 +2303,8 @@ remoteDomainMigratePrepare2(virConnectPtr dconn,
unsigned long resource,
const char *dom_xml)
{
- int rv = -1;
remote_domain_migrate_prepare2_args args = {0};
- remote_domain_migrate_prepare2_ret ret = {0};
+ g_auto(remote_domain_migrate_prepare2_ret) ret = {0};
struct private_data *priv = dconn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2420,31 +2323,21 @@ remoteDomainMigratePrepare2(virConnectPtr dconn,
if (!cookie || !cookielen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookie or cookielen"));
- goto error;
+ return -1;
}
- *cookie = ret.cookie.cookie_val; /* Caller frees. */
+ *cookie = g_steal_pointer(&ret.cookie.cookie_val); /* Caller frees. */
*cookielen = ret.cookie.cookie_len;
}
if (ret.uri_out) {
if (!uri_out) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores uri_out"));
- goto error;
+ return -1;
}
- *uri_out = *ret.uri_out; /* Caller frees. */
+ *uri_out = g_steal_pointer(ret.uri_out); /* Caller frees. */
}
- rv = 0;
-
- done:
- VIR_FREE(ret.uri_out);
- return rv;
- error:
- if (ret.cookie.cookie_len)
- VIR_FREE(ret.cookie.cookie_val);
- if (ret.uri_out)
- VIR_FREE(*ret.uri_out);
- goto done;
+ return 0;
}
static int
@@ -2452,7 +2345,7 @@ remoteDomainCreate(virDomainPtr domain)
{
remote_domain_create_args args = {0};
remote_domain_lookup_by_uuid_args args2 = {0};
- remote_domain_lookup_by_uuid_ret ret2 = {0};
+ g_auto(remote_domain_lookup_by_uuid_ret) ret2 = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2474,7 +2367,6 @@ remoteDomainCreate(virDomainPtr domain)
return -1;
domain->id = ret2.dom.id;
- xdr_free((xdrproc_t) &xdr_remote_domain_lookup_by_uuid_ret, (char *) &ret2);
return 0;
}
@@ -2483,7 +2375,7 @@ static char *
remoteDomainGetSchedulerType(virDomainPtr domain, int *nparams)
{
remote_domain_get_scheduler_type_args args = {0};
- remote_domain_get_scheduler_type_ret ret = {0};
+ g_auto(remote_domain_get_scheduler_type_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2497,7 +2389,7 @@ remoteDomainGetSchedulerType(virDomainPtr domain, int *nparams)
if (nparams) *nparams = ret.nparams;
/* Caller frees this. */
- return ret.type;
+ return g_steal_pointer(&ret.type);
}
static int
@@ -2506,9 +2398,8 @@ remoteDomainMemoryStats(virDomainPtr domain,
unsigned int nr_stats,
unsigned int flags)
{
- int rv = -1;
remote_domain_memory_stats_args args = {0};
- remote_domain_memory_stats_ret ret = {0};
+ g_auto(remote_domain_memory_stats_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
size_t i;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2534,10 +2425,7 @@ remoteDomainMemoryStats(virDomainPtr domain,
stats[i].tag = ret.stats.stats_val[i].tag;
stats[i].val = ret.stats.stats_val[i].val;
}
- rv = ret.stats.stats_len;
- xdr_free((xdrproc_t) xdr_remote_domain_memory_stats_ret, (char *) &ret);
-
- return rv;
+ return ret.stats.stats_len;
}
static int
@@ -2548,9 +2436,8 @@ remoteDomainBlockPeek(virDomainPtr domain,
void *buffer,
unsigned int flags)
{
- int rv = -1;
remote_domain_block_peek_args args = {0};
- remote_domain_block_peek_ret ret = {0};
+ g_auto(remote_domain_block_peek_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2577,15 +2464,11 @@ remoteDomainBlockPeek(virDomainPtr domain,
if (ret.buffer.buffer_len != size) {
virReportError(VIR_ERR_RPC, "%s",
_("returned buffer is not same size as requested"));
- goto cleanup;
+ return -1;
}
memcpy(buffer, ret.buffer.buffer_val, size);
- rv = 0;
-
- cleanup:
- VIR_FREE(ret.buffer.buffer_val);
- return rv;
+ return 0;
}
static int
@@ -2595,9 +2478,8 @@ remoteDomainMemoryPeek(virDomainPtr domain,
void *buffer,
unsigned int flags)
{
- int rv = -1;
remote_domain_memory_peek_args args = {0};
- remote_domain_memory_peek_ret ret = {0};
+ g_auto(remote_domain_memory_peek_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2623,16 +2505,11 @@ remoteDomainMemoryPeek(virDomainPtr domain,
if (ret.buffer.buffer_len != size) {
virReportError(VIR_ERR_RPC, "%s",
_("returned buffer is not same size as requested"));
- goto cleanup;
+ return -1;
}
memcpy(buffer, ret.buffer.buffer_val, size);
- rv = 0;
-
- cleanup:
- VIR_FREE(ret.buffer.buffer_val);
-
- return rv;
+ return 0;
}
static int remoteDomainGetBlockJobInfo(virDomainPtr domain,
@@ -2641,7 +2518,7 @@ static int remoteDomainGetBlockJobInfo(virDomainPtr domain,
unsigned int flags)
{
remote_domain_get_block_job_info_args args = {0};
- remote_domain_get_block_job_info_ret ret = {0};
+ g_auto(remote_domain_get_block_job_info_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2673,9 +2550,8 @@ static int remoteDomainGetBlockIoTune(virDomainPtr domain,
int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_domain_get_block_io_tune_args args = {0};
- remote_domain_get_block_io_tune_ret ret = {0};
+ g_auto(remote_domain_get_block_io_tune_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2697,8 +2573,7 @@ static int remoteDomainGetBlockIoTune(virDomainPtr domain,
*/
if (*nparams == 0) {
*nparams = ret.nparams;
- rv = 0;
- goto cleanup;
+ return -1;
}
if (virTypedParamsDeserialize((struct _virTypedParameterRemote *)
ret.params.params_val,
@@ -2706,14 +2581,9 @@ static int remoteDomainGetBlockIoTune(virDomainPtr domain,
REMOTE_DOMAIN_BLOCK_IO_TUNE_PARAMETERS_MAX,
¶ms,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_block_io_tune_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
static int remoteDomainGetCPUStats(virDomainPtr domain,
@@ -2725,8 +2595,7 @@ static int remoteDomainGetCPUStats(virDomainPtr domain,
{
struct private_data *priv = domain->conn->privateData;
remote_domain_get_cpu_stats_args args = {0};
- remote_domain_get_cpu_stats_ret ret = {0};
- int rv = -1;
+ g_auto(remote_domain_get_cpu_stats_ret) ret = {0};
int cpu;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -2763,16 +2632,14 @@ static int remoteDomainGetCPUStats(virDomainPtr domain,
virReportError(VIR_ERR_RPC, "%s",
_("remoteDomainGetCPUStats: "
"returned number of stats exceeds limit"));
- memset(params, 0, sizeof(*params) * nparams * ncpus);
- goto cleanup;
+ return -1;
}
/* Handle the case when the caller does not know the number of stats
* and is asking for the number of stats supported
*/
if (nparams == 0) {
- rv = ret.nparams;
- goto cleanup;
+ return ret.nparams;
}
/* The remote side did not send back any zero entries, so we have
@@ -2789,18 +2656,13 @@ static int remoteDomainGetCPUStats(virDomainPtr domain,
if (virTypedParamsDeserialize((struct _virTypedParameterRemote *) stride,
ret.nparams,
REMOTE_NODE_CPU_STATS_MAX,
- &cpu_params, &tmp) < 0)
- goto cleanup;
+ &cpu_params, &tmp) < 0) {
+ virTypedParamsClear(params, nparams * ncpus);
+ return -1;
+ }
}
- rv = ret.nparams;
- cleanup:
- if (rv < 0)
- virTypedParamsClear(params, nparams * ncpus);
-
- xdr_free((xdrproc_t) xdr_remote_domain_get_cpu_stats_ret,
- (char *) &ret);
- return rv;
+ return ret.nparams;
}
@@ -2814,7 +2676,7 @@ remoteConnectNetworkEventRegisterAny(virConnectPtr conn,
{
struct private_data *priv = conn->privateData;
remote_connect_network_event_register_any_args args = {0};
- remote_connect_network_event_register_any_ret ret = {0};
+ g_auto(remote_connect_network_event_register_any_ret) ret = {0};
int callbackID;
int count;
remote_nonnull_network network;
@@ -2895,7 +2757,7 @@ remoteConnectStoragePoolEventRegisterAny(virConnectPtr conn,
{
struct private_data *priv = conn->privateData;
remote_connect_storage_pool_event_register_any_args args = {0};
- remote_connect_storage_pool_event_register_any_ret ret = {0};
+ g_auto(remote_connect_storage_pool_event_register_any_ret) ret = {0};
int callbackID;
int count;
remote_nonnull_storage_pool storage_pool;
@@ -2978,7 +2840,7 @@ remoteConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
{
struct private_data *priv = conn->privateData;
remote_connect_node_device_event_register_any_args args = {0};
- remote_connect_node_device_event_register_any_ret ret = {0};
+ g_auto(remote_connect_node_device_event_register_any_ret) ret = {0};
int callbackID;
int count;
remote_nonnull_node_device node_device;
@@ -3062,7 +2924,7 @@ remoteConnectSecretEventRegisterAny(virConnectPtr conn,
{
struct private_data *priv = conn->privateData;
remote_connect_secret_event_register_any_args args = {0};
- remote_connect_secret_event_register_any_ret ret = {0};
+ g_auto(remote_connect_secret_event_register_any_ret) ret = {0};
int callbackID;
int count;
remote_nonnull_secret sec;
@@ -3147,7 +3009,7 @@ remoteConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
{
struct private_data *priv = conn->privateData;
qemu_connect_domain_monitor_event_register_args args;
- qemu_connect_domain_monitor_event_register_ret ret = {0};
+ g_auto(qemu_connect_domain_monitor_event_register_ret) ret = {0};
int callbackID;
int count;
remote_nonnull_domain domain;
@@ -3227,9 +3089,8 @@ remoteConnectFindStoragePoolSources(virConnectPtr conn,
const char *srcSpec,
unsigned int flags)
{
- char *rv = NULL;
remote_connect_find_storage_pool_sources_args args = {0};
- remote_connect_find_storage_pool_sources_ret ret = {0};
+ g_auto(remote_connect_find_storage_pool_sources_ret) ret = {0};
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -3242,10 +3103,7 @@ remoteConnectFindStoragePoolSources(virConnectPtr conn,
(xdrproc_t) xdr_remote_connect_find_storage_pool_sources_ret, (char *)
&ret) == -1)
return NULL;
- rv = g_steal_pointer(&ret.xml); /* To stop xdr_free free'ing it */
-
- xdr_free((xdrproc_t) xdr_remote_connect_find_storage_pool_sources_ret, (char *)
&ret);
- return rv;
+ return g_steal_pointer(&ret.xml);
}
/*----------------------------------------------------------------------*/
@@ -3332,7 +3190,7 @@ remoteAuthenticate(virConnectPtr conn, struct private_data *priv,
virConnectAuthPtr auth G_GNUC_UNUSED,
const char *authtype)
{
- struct remote_auth_list_ret ret = {0};
+ g_auto(remote_auth_list_ret) ret = {0};
int err, type = REMOTE_AUTH_NONE;
err = call(conn, priv, 0,
@@ -3962,7 +3820,7 @@ static int
remoteAuthPolkit(virConnectPtr conn, struct private_data *priv,
virConnectAuthPtr auth G_GNUC_UNUSED)
{
- remote_auth_polkit_ret ret = {0};
+ g_auto(remote_auth_polkit_ret) ret = {0};
VIR_DEBUG("Client initialize PolicyKit authentication");
if (call(conn, priv, 0, REMOTE_PROC_AUTH_POLKIT,
@@ -4001,7 +3859,7 @@ remoteConnectDomainEventRegister(virConnectPtr conn,
/* Tell the server when we are the first callback registering */
if (priv->serverEventFilter) {
remote_connect_domain_event_callback_register_any_args args = {0};
- remote_connect_domain_event_callback_register_any_ret ret = {0};
+ g_auto(remote_connect_domain_event_callback_register_any_ret) ret = {0};
args.eventID = VIR_DOMAIN_EVENT_ID_LIFECYCLE;
args.dom = NULL;
@@ -5110,7 +4968,7 @@ remoteSecretGetValue(virSecretPtr secret, size_t *value_size,
unsigned int flags)
{
remote_secret_get_value_args args = {0};
- remote_secret_get_value_ret ret = {0};
+ g_auto(remote_secret_get_value_ret) ret = {0};
struct private_data *priv = secret->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -5123,7 +4981,7 @@ remoteSecretGetValue(virSecretPtr secret, size_t *value_size,
return NULL;
*value_size = ret.value.value_len;
- return (unsigned char *) ret.value.value_val; /* Caller frees. */
+ return (unsigned char *) g_steal_pointer(&ret.value.value_val); /* Caller frees.
*/
}
@@ -5517,7 +5375,7 @@ remoteConnectDomainEventRegisterAny(virConnectPtr conn,
if (count == 1) {
if (priv->serverEventFilter) {
remote_connect_domain_event_callback_register_any_args args = {0};
- remote_connect_domain_event_callback_register_any_ret ret = {0};
+ g_auto(remote_connect_domain_event_callback_register_any_ret) ret = {0};
args.eventID = eventID;
if (dom) {
@@ -5608,9 +5466,8 @@ static int
remoteDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
char **result, unsigned int flags)
{
- int rv = -1;
qemu_domain_monitor_command_args args;
- qemu_domain_monitor_command_ret ret = {0};
+ g_auto(qemu_domain_monitor_command_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -5623,13 +5480,9 @@ remoteDomainQemuMonitorCommand(virDomainPtr domain, const char
*cmd,
(xdrproc_t) xdr_qemu_domain_monitor_command_ret, (char *) &ret) == -1)
return -1;
- *result = g_strdup(ret.result);
-
- rv = 0;
-
- xdr_free((xdrproc_t) xdr_qemu_domain_monitor_command_ret, (char *) &ret);
+ *result = g_steal_pointer(&ret.result);
- return rv;
+ return 0;
}
@@ -5644,7 +5497,7 @@ remoteDomainQemuMonitorCommandWithFiles(virDomainPtr domain,
unsigned int flags)
{
qemu_domain_monitor_command_with_files_args args;
- qemu_domain_monitor_command_with_files_ret ret = {0};
+ g_auto(qemu_domain_monitor_command_with_files_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
size_t rpc_noutfiles = 0;
g_autofree int *rpc_outfiles = NULL;
@@ -5668,9 +5521,7 @@ remoteDomainQemuMonitorCommandWithFiles(virDomainPtr domain,
if (noutfiles)
*noutfiles = rpc_noutfiles;
- *result = g_strdup(ret.result);
-
- xdr_free((xdrproc_t) xdr_qemu_domain_monitor_command_with_files_ret, (char *)
&ret);
+ *result = g_steal_pointer(&ret.result);
if (rpc_outfiles) {
for (i = 0; i < rpc_noutfiles; i++) {
@@ -5691,9 +5542,8 @@ remoteDomainMigrateBegin3(virDomainPtr domain,
const char *dname,
unsigned long resource)
{
- char *rv = NULL;
remote_domain_migrate_begin3_args args = {0};
- remote_domain_migrate_begin3_ret ret = {0};
+ g_auto(remote_domain_migrate_begin3_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -5712,20 +5562,14 @@ remoteDomainMigrateBegin3(virDomainPtr domain,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ return NULL;
}
- *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+ *cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
+ ret.cookie_out.cookie_out_len = 0;
}
- rv = ret.xml; /* caller frees */
-
- done:
- return rv;
-
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- goto done;
+ return g_steal_pointer(&ret.xml); /* caller frees */
}
@@ -5742,9 +5586,8 @@ remoteDomainMigratePrepare3(virConnectPtr dconn,
unsigned long resource,
const char *dom_xml)
{
- int rv = -1;
remote_domain_migrate_prepare3_args args = {0};
- remote_domain_migrate_prepare3_ret ret = {0};
+ g_auto(remote_domain_migrate_prepare3_ret) ret = {0};
struct private_data *priv = dconn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -5765,30 +5608,22 @@ remoteDomainMigratePrepare3(virConnectPtr dconn,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ return -1;
}
- *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+ *cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
+ ret.cookie_out.cookie_out_len = 0;
}
if (ret.uri_out) {
if (!uri_out) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores uri_out"));
- goto error;
+ return -1;
}
- *uri_out = *ret.uri_out; /* Caller frees. */
+ *uri_out = g_steal_pointer(ret.uri_out); /* Caller frees. */
}
- rv = 0;
-
- done:
- VIR_FREE(ret.uri_out);
- return rv;
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- if (ret.uri_out)
- VIR_FREE(*ret.uri_out);
- goto done;
+ return 0;
}
@@ -5806,7 +5641,7 @@ remoteDomainMigratePrepareTunnel3(virConnectPtr dconn,
{
struct private_data *priv = dconn->privateData;
remote_domain_migrate_prepare_tunnel3_args args = {0};
- remote_domain_migrate_prepare_tunnel3_ret ret = {0};
+ g_auto(remote_domain_migrate_prepare_tunnel3_ret) ret = {0};
virNetClientStream *netst;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -5844,17 +5679,14 @@ remoteDomainMigratePrepareTunnel3(virConnectPtr dconn,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ return -1;
}
- *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+ *cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
+ ret.cookie_out.cookie_out_len = 0;
}
return 0;
-
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- return -1;
}
@@ -5872,7 +5704,7 @@ remoteDomainMigratePerform3(virDomainPtr dom,
unsigned long resource)
{
remote_domain_migrate_perform3_args args = {0};
- remote_domain_migrate_perform3_ret ret = {0};
+ g_auto(remote_domain_migrate_perform3_ret) ret = {0};
struct private_data *priv = dom->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -5896,17 +5728,14 @@ remoteDomainMigratePerform3(virDomainPtr dom,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ return -1;
}
- *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+ *cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
+ ret.cookie_out.cookie_out_len = 0;
}
return 0;
-
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- return -1;
}
@@ -5923,9 +5752,8 @@ remoteDomainMigrateFinish3(virConnectPtr dconn,
int cancelled)
{
remote_domain_migrate_finish3_args args = {0};
- remote_domain_migrate_finish3_ret ret = {0};
+ g_auto(remote_domain_migrate_finish3_ret) ret = {0};
struct private_data *priv = dconn->privateData;
- virDomainPtr rv = NULL;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
args.cookie_in.cookie_in_val = (char *)cookiein;
@@ -5945,22 +5773,14 @@ remoteDomainMigrateFinish3(virConnectPtr dconn,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ return NULL;
}
*cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
ret.cookie_out.cookie_out_len = 0;
}
- rv = get_nonnull_domain(dconn, ret.dom);
-
- xdr_free((xdrproc_t) &xdr_remote_domain_migrate_finish3_ret, (char *) &ret);
-
- return rv;
-
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- return NULL;
+ return get_nonnull_domain(dconn, ret.dom);
}
@@ -5996,11 +5816,10 @@ remoteConnectGetCPUModelNames(virConnectPtr conn,
char ***models,
unsigned int flags)
{
- int rv = -1;
size_t i;
g_auto(GStrv) retmodels = NULL;
remote_connect_get_cpu_model_names_args args = {0};
- remote_connect_get_cpu_model_names_ret ret = {0};
+ g_auto(remote_connect_get_cpu_model_names_ret) ret = {0};
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6021,7 +5840,7 @@ remoteConnectGetCPUModelNames(virConnectPtr conn,
_("Too many model names '%d' for limit
'%d'"),
ret.models.models_len,
REMOTE_CONNECT_CPU_MODELS_MAX);
- goto cleanup;
+ return -1;
}
if (models) {
@@ -6033,12 +5852,7 @@ remoteConnectGetCPUModelNames(virConnectPtr conn,
*models = g_steal_pointer(&retmodels);
}
- rv = ret.ret;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_connect_get_cpu_model_names_ret, (char *) &ret);
-
- return rv;
+ return ret.ret;
}
@@ -6161,10 +5975,9 @@ remoteDomainGetDiskErrors(virDomainPtr dom,
unsigned int maxerrors,
unsigned int flags)
{
- int rv = -1;
struct private_data *priv = dom->conn->privateData;
remote_domain_get_disk_errors_args args = {0};
- remote_domain_get_disk_errors_ret ret = {0};
+ g_auto(remote_domain_get_disk_errors_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_domain(&args.dom, dom);
@@ -6183,13 +5996,9 @@ remoteDomainGetDiskErrors(virDomainPtr dom,
REMOTE_DOMAIN_DISK_ERRORS_MAX,
errors,
maxerrors) < 0)
- goto cleanup;
-
- rv = ret.nerrors;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_disk_errors_ret, (char *) &ret);
- return rv;
+ return ret.nerrors;
}
#include "remote_client_bodies.h"
@@ -6267,9 +6076,8 @@ remoteDomainGetInterfaceParameters(virDomainPtr domain,
virTypedParameterPtr params, int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_domain_get_interface_parameters_args args = {0};
- remote_domain_get_interface_parameters_ret ret = {0};
+ g_auto(remote_domain_get_interface_parameters_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6288,8 +6096,7 @@ remoteDomainGetInterfaceParameters(virDomainPtr domain,
*/
if (*nparams == 0) {
*nparams = ret.nparams;
- rv = 0;
- goto cleanup;
+ return 0;
}
if (virTypedParamsDeserialize((struct _virTypedParameterRemote *)
ret.params.params_val,
@@ -6297,14 +6104,9 @@ remoteDomainGetInterfaceParameters(virDomainPtr domain,
REMOTE_DOMAIN_INTERFACE_PARAMETERS_MAX,
¶ms,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_interface_parameters_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
@@ -6314,9 +6116,8 @@ remoteNodeGetMemoryParameters(virConnectPtr conn,
int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_node_get_memory_parameters_args args = {0};
- remote_node_get_memory_parameters_ret ret = {0};
+ g_auto(remote_node_get_memory_parameters_ret) ret = {0};
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6333,8 +6134,7 @@ remoteNodeGetMemoryParameters(virConnectPtr conn,
*/
if (*nparams == 0) {
*nparams = ret.nparams;
- rv = 0;
- goto cleanup;
+ return 0;
}
if (virTypedParamsDeserialize((struct _virTypedParameterRemote *)
ret.params.params_val,
@@ -6342,14 +6142,9 @@ remoteNodeGetMemoryParameters(virConnectPtr conn,
REMOTE_NODE_MEMORY_PARAMETERS_MAX,
¶ms,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_node_get_memory_parameters_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
@@ -6359,9 +6154,8 @@ remoteNodeGetSEVInfo(virConnectPtr conn,
int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_node_get_sev_info_args args = {0};
- remote_node_get_sev_info_ret ret = {0};
+ g_auto(remote_node_get_sev_info_ret) ret = {0};
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6377,13 +6171,9 @@ remoteNodeGetSEVInfo(virConnectPtr conn,
REMOTE_NODE_SEV_INFO_MAX,
params,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_node_get_sev_info_ret, (char *) &ret);
- return rv;
+ return 0;
}
@@ -6393,9 +6183,8 @@ remoteNodeGetCPUMap(virConnectPtr conn,
unsigned int *online,
unsigned int flags)
{
- int rv = -1;
remote_node_get_cpu_map_args args = {0};
- remote_node_get_cpu_map_ret ret = {0};
+ g_auto(remote_node_get_cpu_map_ret) ret = {0};
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6411,7 +6200,7 @@ remoteNodeGetCPUMap(virConnectPtr conn,
return -1;
if (ret.ret < 0)
- goto cleanup;
+ return -1;
if (cpumap) {
*cpumap = g_new0(unsigned char, ret.cpumap.cpumap_len);
@@ -6421,11 +6210,7 @@ remoteNodeGetCPUMap(virConnectPtr conn,
if (online)
*online = ret.online;
- rv = ret.ret;
-
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_node_get_cpu_map_ret, (char *) &ret);
- return rv;
+ return ret.ret;
}
@@ -6462,9 +6247,8 @@ remoteDomainGetJobStats(virDomainPtr domain,
int *nparams,
unsigned int flags)
{
- int rv = -1;
remote_domain_get_job_stats_args args = {0};
- remote_domain_get_job_stats_ret ret = {0};
+ g_auto(remote_domain_get_job_stats_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6482,14 +6266,9 @@ remoteDomainGetJobStats(virDomainPtr domain,
ret.params.params_len,
REMOTE_DOMAIN_JOB_STATS_MAX,
params, nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_domain_get_job_stats_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
@@ -6503,7 +6282,7 @@ remoteDomainMigrateBegin3Params(virDomainPtr domain,
{
char *rv = NULL;
remote_domain_migrate_begin3_params_args args = {0};
- remote_domain_migrate_begin3_params_ret ret = {0};
+ g_auto(remote_domain_migrate_begin3_params_ret) ret = {0};
struct private_data *priv = domain->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6514,9 +6293,8 @@ remoteDomainMigrateBegin3Params(virDomainPtr domain,
REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX,
(struct _virTypedParameterRemote **)
&args.params.params_val,
&args.params.params_len,
- VIR_TYPED_PARAM_STRING_OKAY) < 0) {
- goto cleanup;
- }
+ VIR_TYPED_PARAM_STRING_OKAY) < 0)
+ return NULL;
if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_BEGIN3_PARAMS,
(xdrproc_t) xdr_remote_domain_migrate_begin3_params_args,
@@ -6529,22 +6307,19 @@ remoteDomainMigrateBegin3Params(virDomainPtr domain,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ goto cleanup;
}
- *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+ *cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
+ ret.cookie_out.cookie_out_len = 0;
}
- rv = ret.xml; /* caller frees */
+ rv = g_steal_pointer(&ret.xml); /* caller frees */
cleanup:
virTypedParamsRemoteFree((struct _virTypedParameterRemote *) args.params.params_val,
args.params.params_len);
return rv;
-
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- goto cleanup;
}
@@ -6561,7 +6336,7 @@ remoteDomainMigratePrepare3Params(virConnectPtr dconn,
{
int rv = -1;
remote_domain_migrate_prepare3_params_args args = {0};
- remote_domain_migrate_prepare3_params_ret ret = {0};
+ g_auto(remote_domain_migrate_prepare3_params_ret) ret = {0};
struct private_data *priv = dconn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6569,9 +6344,8 @@ remoteDomainMigratePrepare3Params(virConnectPtr dconn,
REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX,
(struct _virTypedParameterRemote **)
&args.params.params_val,
&args.params.params_len,
- VIR_TYPED_PARAM_STRING_OKAY) < 0) {
- goto cleanup;
- }
+ VIR_TYPED_PARAM_STRING_OKAY) < 0)
+ return -1;
args.cookie_in.cookie_in_val = (char *)cookiein;
args.cookie_in.cookie_in_len = cookieinlen;
@@ -6588,18 +6362,19 @@ remoteDomainMigratePrepare3Params(virConnectPtr dconn,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ goto cleanup;
}
- *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+ *cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
+ ret.cookie_out.cookie_out_len = 0;
}
if (ret.uri_out) {
if (!uri_out) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores uri_out"));
- goto error;
+ goto cleanup;
}
- *uri_out = *ret.uri_out; /* Caller frees. */
+ *uri_out = g_steal_pointer(ret.uri_out); /* Caller frees. */
}
rv = 0;
@@ -6607,14 +6382,7 @@ remoteDomainMigratePrepare3Params(virConnectPtr dconn,
cleanup:
virTypedParamsRemoteFree((struct _virTypedParameterRemote *) args.params.params_val,
args.params.params_len);
- VIR_FREE(ret.uri_out);
return rv;
-
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- if (ret.uri_out)
- VIR_FREE(*ret.uri_out);
- goto cleanup;
}
@@ -6632,7 +6400,7 @@ remoteDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
struct private_data *priv = dconn->privateData;
int rv = -1;
remote_domain_migrate_prepare_tunnel3_params_args args = {0};
- remote_domain_migrate_prepare_tunnel3_params_ret ret = {0};
+ g_auto(remote_domain_migrate_prepare_tunnel3_params_ret) ret = {0};
virNetClientStream *netst;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6644,9 +6412,8 @@ remoteDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX,
(struct _virTypedParameterRemote **)
&args.params.params_val,
&args.params.params_len,
- VIR_TYPED_PARAM_STRING_OKAY) < 0) {
- goto cleanup;
- }
+ VIR_TYPED_PARAM_STRING_OKAY) < 0)
+ return -1;
if (!(netst = virNetClientStreamNew(priv->remoteProgram,
REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL3_PARAMS,
@@ -6677,10 +6444,11 @@ remoteDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ goto cleanup;
}
- *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+ *cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
+ ret.cookie_out.cookie_out_len = 0;
}
rv = 0;
@@ -6689,10 +6457,6 @@ remoteDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
virTypedParamsRemoteFree((struct _virTypedParameterRemote *) args.params.params_val,
args.params.params_len);
return rv;
-
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- goto cleanup;
}
@@ -6709,7 +6473,7 @@ remoteDomainMigratePerform3Params(virDomainPtr dom,
{
int rv = -1;
remote_domain_migrate_perform3_params_args args = {0};
- remote_domain_migrate_perform3_params_ret ret = {0};
+ g_auto(remote_domain_migrate_perform3_params_ret) ret = {0};
struct private_data *priv = dom->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6723,9 +6487,8 @@ remoteDomainMigratePerform3Params(virDomainPtr dom,
REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX,
(struct _virTypedParameterRemote **)
&args.params.params_val,
&args.params.params_len,
- VIR_TYPED_PARAM_STRING_OKAY) < 0) {
- goto cleanup;
- }
+ VIR_TYPED_PARAM_STRING_OKAY) < 0)
+ return -1;
if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PERFORM3_PARAMS,
(xdrproc_t) xdr_remote_domain_migrate_perform3_params_args,
@@ -6738,10 +6501,11 @@ remoteDomainMigratePerform3Params(virDomainPtr dom,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ goto cleanup;
}
- *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+ *cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
+ ret.cookie_out.cookie_out_len = 0;
}
rv = 0;
@@ -6750,10 +6514,6 @@ remoteDomainMigratePerform3Params(virDomainPtr dom,
virTypedParamsRemoteFree((struct _virTypedParameterRemote *) args.params.params_val,
args.params.params_len);
return rv;
-
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- goto cleanup;
}
@@ -6769,7 +6529,7 @@ remoteDomainMigrateFinish3Params(virConnectPtr dconn,
int cancelled)
{
remote_domain_migrate_finish3_params_args args = {0};
- remote_domain_migrate_finish3_params_ret ret = {0};
+ g_auto(remote_domain_migrate_finish3_params_ret) ret = {0};
struct private_data *priv = dconn->privateData;
virDomainPtr rv = NULL;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6783,9 +6543,8 @@ remoteDomainMigrateFinish3Params(virConnectPtr dconn,
REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX,
(struct _virTypedParameterRemote **)
&args.params.params_val,
&args.params.params_len,
- VIR_TYPED_PARAM_STRING_OKAY) < 0) {
- goto cleanup;
- }
+ VIR_TYPED_PARAM_STRING_OKAY) < 0)
+ return NULL;
if (call(dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_FINISH3_PARAMS,
(xdrproc_t) xdr_remote_domain_migrate_finish3_params_args,
@@ -6798,7 +6557,7 @@ remoteDomainMigrateFinish3Params(virConnectPtr dconn,
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("caller ignores cookieout or cookieoutlen"));
- goto error;
+ goto cleanup;
}
*cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller
frees. */
*cookieoutlen = ret.cookie_out.cookie_out_len;
@@ -6806,18 +6565,10 @@ remoteDomainMigrateFinish3Params(virConnectPtr dconn,
}
rv = get_nonnull_domain(dconn, ret.dom);
-
- xdr_free((xdrproc_t) &xdr_remote_domain_migrate_finish3_params_ret,
- (char *) &ret);
-
cleanup:
virTypedParamsRemoteFree((struct _virTypedParameterRemote *) args.params.params_val,
args.params.params_len);
return rv;
-
- error:
- VIR_FREE(ret.cookie_out.cookie_out_val);
- goto cleanup;
}
@@ -6845,9 +6596,8 @@ remoteDomainMigrateConfirm3Params(virDomainPtr domain,
REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX,
(struct _virTypedParameterRemote **)
&args.params.params_val,
&args.params.params_len,
- VIR_TYPED_PARAM_STRING_OKAY) < 0) {
- goto cleanup;
- }
+ VIR_TYPED_PARAM_STRING_OKAY) < 0)
+ return -1;
if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_CONFIRM3_PARAMS,
(xdrproc_t) xdr_remote_domain_migrate_confirm3_params_args,
@@ -6867,10 +6617,9 @@ static virDomainPtr
remoteDomainCreateXMLWithFiles(virConnectPtr conn, const char *xml_desc,
unsigned int nfiles, int *files, unsigned int flags)
{
- virDomainPtr rv = NULL;
struct private_data *priv = conn->privateData;
remote_domain_create_xml_with_files_args args = {0};
- remote_domain_create_xml_with_files_ret ret = {0};
+ g_auto(remote_domain_create_xml_with_files_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
args.xml_desc = (char *)xml_desc;
@@ -6884,10 +6633,7 @@ remoteDomainCreateXMLWithFiles(virConnectPtr conn, const char
*xml_desc,
(xdrproc_t)xdr_remote_domain_create_xml_with_files_ret, (char
*)&ret) == -1)
return NULL;
- rv = get_nonnull_domain(conn, ret.dom);
- xdr_free((xdrproc_t)xdr_remote_domain_create_xml_with_files_ret, (char *)&ret);
-
- return rv;
+ return get_nonnull_domain(conn, ret.dom);
}
@@ -6898,7 +6644,7 @@ remoteDomainCreateWithFiles(virDomainPtr dom,
{
struct private_data *priv = dom->conn->privateData;
remote_domain_create_with_files_args args = {0};
- remote_domain_create_with_files_ret ret = {0};
+ g_auto(remote_domain_create_with_files_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_domain(&args.dom, dom);
@@ -6913,7 +6659,6 @@ remoteDomainCreateWithFiles(virDomainPtr dom,
return -1;
dom->id = ret.dom.id;
- xdr_free((xdrproc_t) &xdr_remote_domain_create_with_files_ret, (char *)
&ret);
return 0;
}
@@ -6925,7 +6670,7 @@ remoteDomainGetTime(virDomainPtr dom,
{
struct private_data *priv = dom->conn->privateData;
remote_domain_get_time_args args = {0};
- remote_domain_get_time_ret ret = {0};
+ g_auto(remote_domain_get_time_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_domain(&args.dom, dom);
@@ -6940,7 +6685,6 @@ remoteDomainGetTime(virDomainPtr dom,
*seconds = ret.seconds;
*nseconds = ret.nseconds;
- xdr_free((xdrproc_t) &xdr_remote_domain_get_time_ret, (char *) &ret);
return 0;
}
@@ -6955,7 +6699,7 @@ remoteNodeGetFreePages(virConnectPtr conn,
unsigned int flags)
{
remote_node_get_free_pages_args args = {0};
- remote_node_get_free_pages_ret ret = {0};
+ g_auto(remote_node_get_free_pages_ret) ret = {0};
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -6979,8 +6723,6 @@ remoteNodeGetFreePages(virConnectPtr conn,
memcpy(counts, ret.counts.counts_val, ret.counts.counts_len * sizeof(*counts));
- xdr_free((xdrproc_t) xdr_remote_node_get_free_pages_ret, (char *) &ret);
-
return ret.counts.counts_len;
}
@@ -7035,7 +6777,7 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net,
size_t i;
struct private_data *priv = net->conn->privateData;
remote_network_get_dhcp_leases_args args = {0};
- remote_network_get_dhcp_leases_ret ret = {0};
+ g_auto(remote_network_get_dhcp_leases_ret) ret = {0};
virNetworkDHCPLeasePtr *leases_ret = NULL;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -7053,7 +6795,7 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Number of leases is %d, which exceeds max limit:
%d"),
ret.leases.leases_len, REMOTE_NETWORK_DHCP_LEASES_MAX);
- goto cleanup;
+ return -1;
}
if (leases) {
@@ -7078,8 +6820,6 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net,
virNetworkDHCPLeaseFree(leases_ret[i]);
VIR_FREE(leases_ret);
}
- xdr_free((xdrproc_t)xdr_remote_network_get_dhcp_leases_ret,
- (char *) &ret);
return rv;
}
@@ -7097,7 +6837,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn,
int rv = -1;
size_t i;
remote_connect_get_all_domain_stats_args args = {0};
- remote_connect_get_all_domain_stats_ret ret = {0};
+ g_auto(remote_connect_get_all_domain_stats_ret) ret = {0};
virDomainStatsRecordPtr elem = NULL;
virDomainStatsRecordPtr *tmpret = NULL;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -7158,8 +6898,6 @@ remoteConnectGetAllDomainStats(virConnectPtr conn,
}
virDomainStatsRecordListFree(tmpret);
VIR_FREE(args.doms.doms_val);
- xdr_free((xdrproc_t)xdr_remote_connect_get_all_domain_stats_ret,
- (char *) &ret);
return rv;
}
@@ -7175,7 +6913,7 @@ remoteNodeAllocPages(virConnectPtr conn,
unsigned int flags)
{
remote_node_alloc_pages_args args = {0};
- remote_node_alloc_pages_ret ret = {0};
+ g_auto(remote_node_alloc_pages_ret) ret = {0};
struct private_data *priv = conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -7208,11 +6946,10 @@ remoteDomainGetFSInfo(virDomainPtr dom,
virDomainFSInfoPtr **info,
unsigned int flags)
{
- int rv = -1;
size_t i, j, len;
struct private_data *priv = dom->conn->privateData;
remote_domain_get_fsinfo_args args = {0};
- remote_domain_get_fsinfo_ret ret = {0};
+ g_auto(remote_domain_get_fsinfo_ret) ret = {0};
remote_domain_fsinfo *src;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -7229,7 +6966,7 @@ remoteDomainGetFSInfo(virDomainPtr dom,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Too many mountpoints in fsinfo: %d for limit %d"),
ret.info.info_len, REMOTE_DOMAIN_FSINFO_MAX);
- goto cleanup;
+ return -1;
}
if (info) {
@@ -7237,8 +6974,7 @@ remoteDomainGetFSInfo(virDomainPtr dom,
if (!ret.info.info_len) {
*info = NULL;
- rv = ret.ret;
- goto cleanup;
+ return ret.ret;
}
info_ret = g_new0(virDomainFSInfoPtr, ret.info.info_len);
@@ -7266,12 +7002,7 @@ remoteDomainGetFSInfo(virDomainPtr dom,
*info = info_ret;
}
- rv = ret.ret;
-
- cleanup:
- xdr_free((xdrproc_t)xdr_remote_domain_get_fsinfo_ret,
- (char *) &ret);
- return rv;
+ return ret.ret;
}
@@ -7286,7 +7017,7 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
virDomainInterfacePtr *ifaces_ret = NULL;
remote_domain_interface_addresses_args args = {0};
- remote_domain_interface_addresses_ret ret = {0};
+ g_auto(remote_domain_interface_addresses_ret) ret = {0};
struct private_data *priv = dom->conn->privateData;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -7305,7 +7036,7 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Number of interfaces, %d exceeds the max limit:
%d"),
ret.ifaces.ifaces_len, REMOTE_DOMAIN_INTERFACE_MAX);
- goto cleanup;
+ return -1;
}
if (ret.ifaces.ifaces_len)
@@ -7358,8 +7089,6 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
virDomainInterfaceFree(ifaces_ret[i]);
VIR_FREE(ifaces_ret);
}
- xdr_free((xdrproc_t)xdr_remote_domain_interface_addresses_ret,
- (char *) &ret);
return rv;
}
@@ -7418,7 +7147,7 @@ remoteDomainRename(virDomainPtr dom, const char *new_name, unsigned
int flags)
int rv = -1;
struct private_data *priv = dom->conn->privateData;
remote_domain_rename_args args = {0};
- remote_domain_rename_ret ret = {0};
+ g_auto(remote_domain_rename_ret) ret = {0};
char *tmp = NULL;
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
@@ -7452,7 +7181,7 @@ remoteStorageVolGetInfoFlags(virStorageVolPtr vol,
{
struct private_data *priv = vol->conn->privateData;
remote_storage_vol_get_info_flags_args args = {0};
- remote_storage_vol_get_info_flags_ret ret = {0};
+ g_auto(remote_storage_vol_get_info_flags_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_storage_vol(&args.vol, vol);
@@ -7479,10 +7208,9 @@ remoteNetworkPortGetParameters(virNetworkPortPtr port,
int *nparams,
unsigned int flags)
{
- int rv = -1;
struct private_data *priv = port->net->conn->privateData;
remote_network_port_get_parameters_args args = {0};
- remote_network_port_get_parameters_ret ret = {0};
+ g_auto(remote_network_port_get_parameters_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_network_port(&args.port, port);
@@ -7498,13 +7226,9 @@ remoteNetworkPortGetParameters(virNetworkPortPtr port,
REMOTE_NETWORK_PORT_PARAMETERS_MAX,
params,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t) xdr_remote_network_port_get_parameters_ret, (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -7514,10 +7238,9 @@ remoteDomainGetGuestInfo(virDomainPtr dom,
int *nparams,
unsigned int flags)
{
- int rv = -1;
struct private_data *priv = dom->conn->privateData;
remote_domain_get_guest_info_args args = {0};
- remote_domain_get_guest_info_ret ret = {0};
+ g_auto(remote_domain_get_guest_info_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_domain(&args.dom, dom);
@@ -7535,14 +7258,9 @@ remoteDomainGetGuestInfo(virDomainPtr dom,
REMOTE_DOMAIN_GUEST_INFO_PARAMS_MAX,
params,
nparams) < 0)
- goto cleanup;
-
- rv = 0;
+ return -1;
- cleanup:
- xdr_free((xdrproc_t)xdr_remote_domain_get_guest_info_ret,
- (char *) &ret);
- return rv;
+ return 0;
}
static int
@@ -7551,11 +7269,10 @@ remoteDomainAuthorizedSSHKeysGet(virDomainPtr domain,
char ***keys,
unsigned int flags)
{
- int rv = -1;
size_t i;
struct private_data *priv = domain->conn->privateData;
remote_domain_authorized_ssh_keys_get_args args = {0};
- remote_domain_authorized_ssh_keys_get_ret ret = {0};
+ g_auto(remote_domain_authorized_ssh_keys_get_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_domain(&args.dom, domain);
@@ -7571,19 +7288,14 @@ remoteDomainAuthorizedSSHKeysGet(virDomainPtr domain,
virReportError(VIR_ERR_RPC, "%s",
_("remoteDomainAuthorizedSSHKeysGet: "
"returned number of keys exceeds limit"));
- goto cleanup;
+ return -1;
}
*keys = g_new0(char *, ret.keys.keys_len + 1);
for (i = 0; i < ret.keys.keys_len; i++)
- (*keys)[i] = g_strdup(ret.keys.keys_val[i]);
-
- rv = ret.keys.keys_len;
+ (*keys)[i] = g_steal_pointer(&ret.keys.keys_val[i]);
- cleanup:
- xdr_free((xdrproc_t)xdr_remote_domain_authorized_ssh_keys_get_ret,
- (char *) &ret);
- return rv;
+ return ret.keys.keys_len;
}
static int
@@ -7624,11 +7336,10 @@ remoteDomainGetMessages(virDomainPtr domain,
char ***msgs,
unsigned int flags)
{
- int rv = -1;
size_t i;
struct private_data *priv = domain->conn->privateData;
remote_domain_get_messages_args args = {0};
- remote_domain_get_messages_ret ret = {0};
+ g_auto(remote_domain_get_messages_ret) ret = {0};
VIR_LOCK_GUARD lock = remoteDriverLock(priv);
make_nonnull_domain(&args.dom, domain);
@@ -7637,26 +7348,21 @@ remoteDomainGetMessages(virDomainPtr domain,
if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_MESSAGES,
(xdrproc_t) xdr_remote_domain_get_messages_args, (char *)&args,
(xdrproc_t) xdr_remote_domain_get_messages_ret, (char *)&ret) == -1) {
- goto cleanup;
+ return -1;
}
if (ret.msgs.msgs_len > REMOTE_DOMAIN_MESSAGES_MAX) {
virReportError(VIR_ERR_RPC, "%s",
_("remoteDomainGetMessages: "
"returned number of msgs exceeds limit"));
- goto cleanup;
+ return -1;
}
*msgs = g_new0(char *, ret.msgs.msgs_len + 1);
for (i = 0; i < ret.msgs.msgs_len; i++)
- (*msgs)[i] = g_strdup(ret.msgs.msgs_val[i]);
+ (*msgs)[i] = g_steal_pointer(&ret.msgs.msgs_val[i]);
- rv = ret.msgs.msgs_len;
-
- cleanup:
- xdr_free((xdrproc_t)xdr_remote_domain_get_messages_ret,
- (char *) &ret);
- return rv;
+ return ret.msgs.msgs_len;
}
--
2.39.1