Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/access/viraccessdriverstack.c | 3 +-
src/conf/backup_conf.c | 3 +-
src/conf/capabilities.c | 4 +-
src/conf/domain_addr.c | 6 +--
src/conf/domain_conf.c | 3 +-
src/conf/nwfilter_conf.c | 6 +--
src/conf/nwfilter_params.c | 8 +---
src/esx/esx_driver.c | 4 +-
src/hyperv/hyperv_wmi.c | 3 +-
src/hypervisor/domain_driver.c | 3 +-
src/hypervisor/virclosecallbacks.c | 2 +-
src/libxl/libxl_conf.c | 9 ++--
src/libxl/xen_common.c | 6 +--
src/locking/lock_driver_lockd.c | 4 +-
src/lxc/lxc_controller.c | 18 ++------
src/lxc/lxc_native.c | 33 +++++----------
src/qemu/qemu_agent.c | 7 +---
src/qemu/qemu_capabilities.c | 3 +-
src/qemu/qemu_conf.c | 6 +--
src/rpc/virnetclient.c | 16 +------
src/rpc/virnetdaemon.c | 3 +-
src/rpc/virnetlibsshsession.c | 8 +---
src/rpc/virnetserver.c | 19 ++-------
src/rpc/virnetsocket.c | 3 +-
src/rpc/virnetsshsession.c | 8 +---
src/storage/storage_backend_rbd.c | 3 +-
.../storage_file_backend_gluster.c | 3 +-
.../storage_source_backingstore.c | 3 +-
src/util/vircommand.c | 2 +-
src/util/virfile.c | 14 ++-----
src/util/virfirewall.c | 3 +-
src/util/virlockspace.c | 7 +---
src/util/virprocess.c | 17 +-------
src/util/virresctrl.c | 42 ++++++++-----------
src/util/virstring.c | 6 +--
src/util/virsysinfo.c | 34 ++++-----------
src/util/virsystemd.c | 3 +-
src/util/virthreadpool.c | 3 +-
src/util/virtypedparam.c | 3 +-
src/vbox/vbox_snapshot_conf.c | 29 ++++---------
tests/qemudomaincheckpointxml2xmltest.c | 3 +-
tests/qemumonitortestutils.c | 12 ++----
tests/securityselinuxlabeltest.c | 7 +---
tests/viralloctest.c | 3 +-
tools/virsh-domain.c | 27 +++---------
45 files changed, 106 insertions(+), 306 deletions(-)
diff --git a/src/access/viraccessdriverstack.c b/src/access/viraccessdriverstack.c
index 238caef115..0f0858e96e 100644
--- a/src/access/viraccessdriverstack.c
+++ b/src/access/viraccessdriverstack.c
@@ -40,8 +40,7 @@ int virAccessDriverStackAppend(virAccessManagerPtr manager,
{
virAccessDriverStackPrivatePtr priv = virAccessManagerGetPrivateData(manager);
- if (VIR_EXPAND_N(priv->managers, priv->managersLen, 1) < 0)
- return -1;
+ VIR_EXPAND_N(priv->managers, priv->managersLen, 1);
priv->managers[priv->managersLen-1] = child;
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index ba58b2e322..2d6d2d99f4 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -554,8 +554,7 @@ virDomainBackupAlignDisks(virDomainBackupDefPtr def,
backup_all = true;
ndisks = def->ndisks;
- if (VIR_EXPAND_N(def->disks, def->ndisks, dom->ndisks - def->ndisks) <
0)
- return -1;
+ VIR_EXPAND_N(def->disks, def->ndisks, dom->ndisks - def->ndisks);
for (i = 0; i < dom->ndisks; i++) {
virDomainBackupDiskDefPtr backupdisk = NULL;
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 14f0d48930..bc9035afae 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -580,9 +580,7 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr
secmodel,
if (type == NULL || label == NULL)
return -1;
- if (VIR_EXPAND_N(secmodel->labels, secmodel->nlabels, 1) < 0)
- return -1;
-
+ VIR_EXPAND_N(secmodel->labels, secmodel->nlabels, 1);
secmodel->labels[secmodel->nlabels - 1].type = g_strdup(type);
secmodel->labels[secmodel->nlabels - 1].label = g_strdup(label);
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 8b927689f8..9167b489d1 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -728,8 +728,7 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSetPtr addrs,
i = addrs->nbuses;
- if (VIR_EXPAND_N(addrs->buses, addrs->nbuses, add) < 0)
- return -1;
+ VIR_EXPAND_N(addrs->buses, addrs->nbuses, add);
if (needDMIToPCIBridge) {
/* first of the new buses is dmi-to-pci-bridge, the
@@ -1985,8 +1984,7 @@ virDomainUSBAddressSetAddController(virDomainUSBAddressSetPtr
addrs,
return 0;
if (addrs->nbuses <= cont->idx) {
- if (VIR_EXPAND_N(addrs->buses, addrs->nbuses, cont->idx -
addrs->nbuses + 1) < 0)
- goto cleanup;
+ VIR_EXPAND_N(addrs->buses, addrs->nbuses, cont->idx - addrs->nbuses +
1);
} else if (addrs->buses[cont->idx]) {
virReportError(VIR_ERR_XML_ERROR,
_("Duplicate USB controllers with index %u"),
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7671050134..afbd6fc7c1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2001,8 +2001,7 @@ virDomainDefSetVcpusMax(virDomainDefPtr def,
return 0;
if (def->maxvcpus < maxvcpus) {
- if (VIR_EXPAND_N(def->vcpus, def->maxvcpus, maxvcpus - def->maxvcpus)
< 0)
- return -1;
+ VIR_EXPAND_N(def->vcpus, def->maxvcpus, maxvcpus - def->maxvcpus);
for (i = oldmax; i < def->maxvcpus; i++) {
if (!(def->vcpus[i] = virDomainVcpuDefNew(xmlopt)))
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index fbb87b7acf..3cc45394c0 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -381,11 +381,7 @@ virNWFilterRuleDefAddVar(virNWFilterRuleDefPtr nwf,
}
}
- if (VIR_EXPAND_N(nwf->varAccess, nwf->nVarAccess, 1) < 0) {
- virNWFilterVarAccessFree(varAccess);
- return -1;
- }
-
+ VIR_EXPAND_N(nwf->varAccess, nwf->nVarAccess, 1);
nwf->varAccess[nwf->nVarAccess - 1] = varAccess;
item->varAccess = varAccess;
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index 5fa5d4fedb..825c151284 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -221,9 +221,7 @@ virNWFilterVarValueAddValue(virNWFilterVarValuePtr val, char *value)
break;
case NWFILTER_VALUE_TYPE_ARRAY:
- if (VIR_EXPAND_N(val->u.array.values,
- val->u.array.nValues, 1) < 0)
- return -1;
+ VIR_EXPAND_N(val->u.array.values, val->u.array.nValues, 1);
val->u.array.values[val->u.array.nValues - 1] = value;
rc = 0;
break;
@@ -374,9 +372,7 @@ virNWFilterVarCombIterAddVariable(virNWFilterVarCombIterEntryPtr cie,
}
}
- if (VIR_EXPAND_N(cie->varNames, cie->nVarNames, 1) < 0)
- return -1;
-
+ VIR_EXPAND_N(cie->varNames, cie->nVarNames, 1);
cie->varNames[cie->nVarNames - 1] = varName;
return 0;
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 9d73bc6de8..21705ef6e3 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -5144,9 +5144,7 @@ esxDomainInterfaceAddresses(virDomainPtr domain,
continue;
}
- if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0)
- goto cleanup;
-
+ VIR_EXPAND_N(ifaces_ret, ifaces_count, 1);
ifaces_ret[ifaces_count - 1] = g_new0(virDomainInterface, 1);
iface = ifaces_ret[ifaces_count - 1];
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 2a898cdf03..6271e85cc6 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -189,8 +189,7 @@ static inline int
hypervCheckParams(hypervInvokeParamsListPtr params)
{
if (params->nbParams + 1 > params->nbAvailParams) {
- if (VIR_EXPAND_N(params->params, params->nbAvailParams, 5) < 0)
- return -1;
+ VIR_EXPAND_N(params->params, params->nbAvailParams, 5);
}
return 0;
diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c
index ef5803ec2a..b861e0ef9b 100644
--- a/src/hypervisor/domain_driver.c
+++ b/src/hypervisor/domain_driver.c
@@ -161,8 +161,7 @@ virDomainDriverMergeBlkioDevice(virBlkioDevicePtr *dest_array,
if (!found) {
if (!src->weight && !src->riops && !src->wiops
&& !src->rbps && !src->wbps)
continue;
- if (VIR_EXPAND_N(*dest_array, *dest_size, 1) < 0)
- return -1;
+ VIR_EXPAND_N(*dest_array, *dest_size, 1);
dest = &(*dest_array)[*dest_size - 1];
if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/virclosecallbacks.c
index 1fd4dd7adf..542dd61d01 100644
--- a/src/hypervisor/virclosecallbacks.c
+++ b/src/hypervisor/virclosecallbacks.c
@@ -262,7 +262,7 @@ virCloseCallbacksGetOne(void *payload,
if (data->conn != closeDef->conn || !closeDef->cb)
return 0;
- ignore_value(VIR_EXPAND_N(data->list->entries, data->list->nentries,
1));
+ VIR_EXPAND_N(data->list->entries, data->list->nentries, 1);
memcpy(data->list->entries[data->list->nentries - 1].uuid,
uuid, VIR_UUID_BUFLEN);
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4b6a7e6096..5ee15d42e3 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -651,8 +651,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
continue;
#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
- if (VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1) < 0)
- return -1;
+ VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1);
#else
nusbdevice++;
if (nusbdevice > 1) {
@@ -685,10 +684,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
/* NULL-terminate usbdevice_list */
- if (nusbdevice > 0 &&
- VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1) < 0) {
- return -1;
- }
+ if (nusbdevice > 0)
+ VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1);
#endif
} else if (pvh) {
b_info->cmdline = g_strdup(def->os.cmdline);
diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index ac71b2d084..835f48ec42 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -552,8 +552,7 @@ xenParseHypervisorFeatures(virConfPtr conf, virDomainDefPtr def)
return -1;
if (strval) {
- if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0)
- return -1;
+ VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1);
timer = g_new0(virDomainTimerDef, 1);
timer->name = VIR_DOMAIN_TIMER_NAME_TSC;
@@ -625,8 +624,7 @@ xenParseHypervisorFeatures(virConfPtr conf, virDomainDefPtr def)
return -1;
if (val != -1) {
- if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0)
- return -1;
+ VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1);
timer = g_new0(virDomainTimerDef, 1);
timer->name = VIR_DOMAIN_TIMER_NAME_HPET;
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index a1deb55788..6137e94e3c 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -641,9 +641,7 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr
lock,
goto cleanup;
}
- if (VIR_EXPAND_N(priv->resources, priv->nresources, 1) < 0)
- goto cleanup;
-
+ VIR_EXPAND_N(priv->resources, priv->nresources, 1);
priv->resources[priv->nresources-1].lockspace =
g_steal_pointer(&newLockspace);
priv->resources[priv->nresources-1].name = g_steal_pointer(&newName);
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 9b7cd6408d..9c4ff5e107 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -321,8 +321,7 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl)
static int virLXCControllerAddConsole(virLXCControllerPtr ctrl,
int hostFd)
{
- if (VIR_EXPAND_N(ctrl->consoles, ctrl->nconsoles, 1) < 0)
- return -1;
+ VIR_EXPAND_N(ctrl->consoles, ctrl->nconsoles, 1);
ctrl->consoles[ctrl->nconsoles-1].daemon = ctrl->daemon;
ctrl->consoles[ctrl->nconsoles-1].hostFd = hostFd;
ctrl->consoles[ctrl->nconsoles-1].hostWatch = -1;
@@ -402,10 +401,7 @@ static int virLXCControllerGetNICIndexes(virLXCControllerPtr ctrl)
if (virNetDevGetIndex(ctrl->def->nets[i]->ifname,
&nicindex) < 0)
return -1;
- if (VIR_EXPAND_N(ctrl->nicindexes,
- ctrl->nnicindexes,
- 1) < 0)
- return -1;
+ VIR_EXPAND_N(ctrl->nicindexes, ctrl->nnicindexes, 1);
VIR_DEBUG("Index %d for %s", nicindex,
ctrl->def->nets[i]->ifname);
ctrl->nicindexes[ctrl->nnicindexes-1] = nicindex;
@@ -636,10 +632,7 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr
ctrl)
return -1;
VIR_DEBUG("Saving loop fd %d", fd);
- if (VIR_EXPAND_N(ctrl->loopDevFds, ctrl->nloopDevs, 1) < 0) {
- VIR_FORCE_CLOSE(fd);
- return -1;
- }
+ VIR_EXPAND_N(ctrl->loopDevFds, ctrl->nloopDevs, 1);
ctrl->loopDevFds[ctrl->nloopDevs - 1] = fd;
} else if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_NBD) {
if (virLXCControllerSetupNBDDeviceFS(fs) < 0)
@@ -694,10 +687,7 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr
ctrl)
return -1;
VIR_DEBUG("Saving loop fd %d", fd);
- if (VIR_EXPAND_N(ctrl->loopDevFds, ctrl->nloopDevs, 1) < 0) {
- VIR_FORCE_CLOSE(fd);
- return -1;
- }
+ VIR_EXPAND_N(ctrl->loopDevFds, ctrl->nloopDevs, 1);
ctrl->loopDevFds[ctrl->nloopDevs - 1] = fd;
} else if (!driver || STREQ(driver, "nbd")) {
if (disk->cachemode != VIR_DOMAIN_DISK_CACHE_DEFAULT &&
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 555e9acd89..36ae821dee 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -123,16 +123,13 @@ static char ** lxcStringSplit(const char *string)
goto error;
/* Append NULL element */
- if (VIR_EXPAND_N(result, ntokens, 1) < 0)
- goto error;
+ VIR_EXPAND_N(result, ntokens, 1);
for (i = 0; parts[i]; i++) {
if (STREQ(parts[i], ""))
continue;
- if (VIR_EXPAND_N(result, ntokens, 1) < 0)
- goto error;
-
+ VIR_EXPAND_N(result, ntokens, 1);
result[ntokens - 2] = g_strdup(parts[i]);
}
@@ -189,8 +186,7 @@ lxcAddFSDef(virDomainDefPtr def,
if (!(fsDef = lxcCreateFSDef(type, src, dst, readonly, usage)))
goto error;
- if (VIR_EXPAND_N(def->fss, def->nfss, 1) < 0)
- goto error;
+ VIR_EXPAND_N(def->fss, def->nfss, 1);
def->fss[def->nfss - 1] = fsDef;
return 0;
@@ -509,8 +505,7 @@ lxcAddNetworkDefinition(virDomainDefPtr def, lxcNetworkParseData
*data)
&hostdev->source.caps.u.net.ip.nroutes)
< 0)
goto error;
- if (VIR_EXPAND_N(def->hostdevs, def->nhostdevs, 1) < 0)
- goto error;
+ VIR_EXPAND_N(def->hostdevs, def->nhostdevs, 1);
def->hostdevs[def->nhostdevs - 1] = hostdev;
} else {
if (!(net = lxcCreateNetDef(data->type, data->link, data->mac,
@@ -533,8 +528,7 @@ lxcAddNetworkDefinition(virDomainDefPtr def, lxcNetworkParseData
*data)
&net->guestIP.nroutes) < 0)
goto error;
- if (VIR_EXPAND_N(def->nets, def->nnets, 1) < 0)
- goto error;
+ VIR_EXPAND_N(def->nets, def->nnets, 1);
def->nets[def->nnets - 1] = net;
}
@@ -651,9 +645,7 @@ lxcNetworkGetParseDataByIndex(lxcNetworkParseDataArray *networks,
/* Index was not found. So, it is time to add new *
* interface and return this last position. */
- if (VIR_EXPAND_N(networks->parseData, networks->ndata, 1) < 0)
- return NULL;
-
+ VIR_EXPAND_N(networks->parseData, networks->ndata, 1);
networks->parseData[ndata] = g_new0(lxcNetworkParseData, 1);
networks->parseData[ndata]->index = index;
@@ -696,9 +688,7 @@ lxcNetworkGetParseDataByIndexLegacy(lxcNetworkParseDataArray
*networks,
if (elem == VIR_LXC_NETWORK_CONFIG_TYPE) {
/* Index was not found. So, it is time to add new *
* interface and return this last position. */
- if (VIR_EXPAND_N(networks->parseData, networks->ndata, 1) < 0)
- return NULL;
-
+ VIR_EXPAND_N(networks->parseData, networks->ndata, 1);
networks->parseData[ndata] = g_new0(lxcNetworkParseData, 1);
networks->parseData[ndata]->index = networks->ndata;
@@ -858,12 +848,10 @@ lxcIdmapWalkCallback(const char *name, virConfValuePtr value, void
*data)
}
if (type == 'u') {
- if (VIR_EXPAND_N(def->idmap.uidmap, def->idmap.nuidmap, 1) < 0)
- return -1;
+ VIR_EXPAND_N(def->idmap.uidmap, def->idmap.nuidmap, 1);
idmap = &def->idmap.uidmap[def->idmap.nuidmap - 1];
} else if (type == 'g') {
- if (VIR_EXPAND_N(def->idmap.gidmap, def->idmap.ngidmap, 1) < 0)
- return -1;
+ VIR_EXPAND_N(def->idmap.gidmap, def->idmap.ngidmap, 1);
idmap = &def->idmap.gidmap[def->idmap.ngidmap - 1];
} else {
return -1;
@@ -1017,8 +1005,7 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValuePtr value,
void *data)
device = &def->blkio.devices[i];
}
if (!device) {
- if (VIR_EXPAND_N(def->blkio.devices, def->blkio.ndevices, 1) < 0)
- goto cleanup;
+ VIR_EXPAND_N(def->blkio.devices, def->blkio.ndevices, 1);
device = &def->blkio.devices[def->blkio.ndevices - 1];
device->path = path;
path = NULL;
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 787a7bb41c..fa37d284b3 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2160,8 +2160,7 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr **ifaces_ret,
/* If the hash table doesn't contain this iface, add it */
if (!iface) {
- if (VIR_EXPAND_N(*ifaces_ret, *ifaces_count, 1) < 0)
- return -1;
+ VIR_EXPAND_N(*ifaces_ret, *ifaces_count, 1);
iface = g_new0(virDomainInterface, 1);
(*ifaces_ret)[*ifaces_count - 1] = iface;
@@ -2191,9 +2190,7 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr **ifaces_ret,
/* If current iface already exists, continue with the count */
addrs_count = iface->naddrs;
- if (VIR_EXPAND_N(iface->addrs, addrs_count,
- virJSONValueArraySize(ip_addr_arr)) < 0)
- return -1;
+ VIR_EXPAND_N(iface->addrs, addrs_count, virJSONValueArraySize(ip_addr_arr));
for (j = 0; j < virJSONValueArraySize(ip_addr_arr); j++) {
virJSONValuePtr ip_addr_obj = virJSONValueArrayGet(ip_addr_arr, j);
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 08bd0e13ce..4ab694de76 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2166,8 +2166,7 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps,
if (defs) {
start = defs->ncpus;
- if (VIR_EXPAND_N(defs->cpus, defs->ncpus, count) < 0)
- return -1;
+ VIR_EXPAND_N(defs->cpus, defs->ncpus, count);
} else {
start = 0;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2bbc75024c..d652bf22b1 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1597,11 +1597,7 @@ qemuSharedDeviceEntryInsert(virQEMUDriverPtr driver,
* recorded in the table.
*/
if (!qemuSharedDeviceEntryDomainExists(entry, name, NULL)) {
- if (VIR_EXPAND_N(entry->domains, entry->ref, 1) < 0) {
- /* entry is owned by the hash table here */
- entry = NULL;
- goto error;
- }
+ VIR_EXPAND_N(entry->domains, entry->ref, 1);
entry->domains[entry->ref - 1] = g_strdup(name);
}
} else {
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index edd65941ac..2de5cfe4b6 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -1070,17 +1070,11 @@ int virNetClientAddProgram(virNetClientPtr client,
{
virObjectLock(client);
- if (VIR_EXPAND_N(client->programs, client->nprograms, 1) < 0)
- goto error;
-
+ VIR_EXPAND_N(client->programs, client->nprograms, 1);
client->programs[client->nprograms-1] = virObjectRef(prog);
virObjectUnlock(client);
return 0;
-
- error:
- virObjectUnlock(client);
- return -1;
}
@@ -1089,17 +1083,11 @@ int virNetClientAddStream(virNetClientPtr client,
{
virObjectLock(client);
- if (VIR_EXPAND_N(client->streams, client->nstreams, 1) < 0)
- goto error;
-
+ VIR_EXPAND_N(client->streams, client->nstreams, 1);
client->streams[client->nstreams-1] = virObjectRef(st);
virObjectUnlock(client);
return 0;
-
- error:
- virObjectUnlock(client);
- return -1;
}
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 14bc9e1335..1f4a2db04f 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -657,8 +657,7 @@ virNetDaemonAddSignalHandler(virNetDaemonPtr dmn,
if (virNetDaemonSignalSetup(dmn) < 0)
goto error;
- if (VIR_EXPAND_N(dmn->signals, dmn->nsignals, 1) < 0)
- goto error;
+ VIR_EXPAND_N(dmn->signals, dmn->nsignals, 1);
sigdata = g_new0(virNetDaemonSignal, 1);
diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index 2dc8cc8911..e08e0c1392 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -182,16 +182,10 @@ virNetLibsshSessionAuthMethodNew(virNetLibsshSessionPtr sess)
auth = g_new0(virNetLibsshAuthMethod, 1);
- if (VIR_EXPAND_N(sess->auths, sess->nauths, 1) < 0)
- goto error;
-
+ VIR_EXPAND_N(sess->auths, sess->nauths, 1);
sess->auths[sess->nauths - 1] = auth;
return auth;
-
- error:
- VIR_FREE(auth);
- return NULL;
}
/* string representation of public key of remote server */
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 2b849465c3..93d55fa906 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -290,8 +290,7 @@ int virNetServerAddClient(virNetServerPtr srv,
if (virNetServerClientInit(client) < 0)
goto error;
- if (VIR_EXPAND_N(srv->clients, srv->nclients, 1) < 0)
- goto error;
+ VIR_EXPAND_N(srv->clients, srv->nclients, 1);
srv->clients[srv->nclients-1] = virObjectRef(client);
virObjectLock(client);
@@ -620,9 +619,7 @@ int virNetServerAddService(virNetServerPtr srv,
{
virObjectLock(srv);
- if (VIR_EXPAND_N(srv->services, srv->nservices, 1) < 0)
- goto error;
-
+ VIR_EXPAND_N(srv->services, srv->nservices, 1);
srv->services[srv->nservices-1] = virObjectRef(svc);
virNetServerServiceSetDispatcher(svc,
@@ -631,10 +628,6 @@ int virNetServerAddService(virNetServerPtr srv,
virObjectUnlock(srv);
return 0;
-
- error:
- virObjectUnlock(srv);
- return -1;
}
@@ -787,17 +780,11 @@ int virNetServerAddProgram(virNetServerPtr srv,
{
virObjectLock(srv);
- if (VIR_EXPAND_N(srv->programs, srv->nprograms, 1) < 0)
- goto error;
-
+ VIR_EXPAND_N(srv->programs, srv->nprograms, 1);
srv->programs[srv->nprograms-1] = virObjectRef(prog);
virObjectUnlock(srv);
return 0;
-
- error:
- virObjectUnlock(srv);
- return -1;
}
int virNetServerSetTLSContext(virNetServerPtr srv,
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 872b8a3c46..0b4e21c3c9 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -440,8 +440,7 @@ int virNetSocketNewListenTCP(const char *nodename,
VIR_DEBUG("%p f=%d f=%d", &addr, runp->ai_family,
addr.data.sa.sa_family);
- if (VIR_EXPAND_N(socks, nsocks, 1) < 0)
- goto error;
+ VIR_EXPAND_N(socks, nsocks, 1);
if (!(socks[nsocks-1] = virNetSocketNew(&addr, NULL, false, fd, -1, 0,
false)))
goto error;
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index f42aed3f62..a42549dcf4 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -175,16 +175,10 @@ virNetSSHSessionAuthMethodNew(virNetSSHSessionPtr sess)
auth = g_new0(virNetSSHAuthMethod, 1);
- if (VIR_EXPAND_N(sess->auths, sess->nauths, 1) < 0)
- goto error;
-
+ VIR_EXPAND_N(sess->auths, sess->nauths, 1);
sess->auths[sess->nauths - 1] = auth;
return auth;
-
- error:
- VIR_FREE(auth);
- return NULL;
}
/* keyboard interactive authentication callback */
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 2804759557..33dda27087 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -649,8 +649,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr)
name += strlen(name) + 1;
}
- if (VIR_EXPAND_N(names, nnames, 1) < 0)
- goto error;
+ VIR_EXPAND_N(names, nnames, 1);
return names;
diff --git a/src/storage_file/storage_file_backend_gluster.c
b/src/storage_file/storage_file_backend_gluster.c
index 8c7a583886..06ba99bfe3 100644
--- a/src/storage_file/storage_file_backend_gluster.c
+++ b/src/storage_file/storage_file_backend_gluster.c
@@ -279,8 +279,7 @@ virStorageFileBackendGlusterReadlinkCallback(const char *path,
return 1;
realloc:
- if (VIR_EXPAND_N(buf, bufsiz, 256) < 0)
- return -1;
+ VIR_EXPAND_N(buf, bufsiz, 256);
if ((ret = glfs_readlink(priv->vol, path, buf, bufsiz)) < 0) {
virReportSystemError(errno,
diff --git a/src/storage_file/storage_source_backingstore.c
b/src/storage_file/storage_source_backingstore.c
index 5e2db3d390..bac5a043e5 100644
--- a/src/storage_file/storage_source_backingstore.c
+++ b/src/storage_file/storage_source_backingstore.c
@@ -146,8 +146,7 @@ virStorageSourceRBDAddHost(virStorageSourcePtr src,
size_t skip;
g_auto(GStrv) parts = NULL;
- if (VIR_EXPAND_N(src->hosts, src->nhosts, 1) < 0)
- return -1;
+ VIR_EXPAND_N(src->hosts, src->nhosts, 1);
if ((port = strchr(hostport, ']'))) {
/* ipv6, strip brackets */
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index d647463f35..29c17454d8 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -228,7 +228,7 @@ virCommandFDSet(virCommandPtr cmd,
if (virCommandFDIsSet(cmd, fd))
return;
- ignore_value(VIR_EXPAND_N(cmd->passfd, cmd->npassfd, 1));
+ VIR_EXPAND_N(cmd->passfd, cmd->npassfd, 1);
cmd->passfd[cmd->npassfd - 1].fd = fd;
cmd->passfd[cmd->npassfd - 1].flags = flags;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 56d6e0605e..c0730f6641 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -2010,7 +2010,6 @@ virFileGetMountSubtreeImpl(const char *mtabpath,
FILE *procmnt;
struct mntent mntent;
char mntbuf[1024];
- int ret = -1;
char **mounts = NULL;
size_t nmounts = 0;
@@ -2031,8 +2030,7 @@ virFileGetMountSubtreeImpl(const char *mtabpath,
mntent.mnt_dir[strlen(prefix)] == '/')))
continue;
- if (VIR_EXPAND_N(mounts, nmounts, nmounts ? 1 : 2) < 0)
- goto cleanup;
+ VIR_EXPAND_N(mounts, nmounts, nmounts ? 1 : 2);
mounts[nmounts - 2] = g_strdup(mntent.mnt_dir);
}
@@ -2042,13 +2040,8 @@ virFileGetMountSubtreeImpl(const char *mtabpath,
*mountsret = mounts;
*nmountsret = nmounts ? nmounts - 1 : 0;
- ret = 0;
-
- cleanup:
- if (ret < 0)
- g_strfreev(mounts);
endmntent(procmnt);
- return ret;
+ return 0;
}
#else /* ! defined WITH_MNTENT_H && defined WITH_GETMNTENT_R */
static int
@@ -3548,8 +3541,7 @@ virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
if (STRNEQ(mb.mnt_type, "hugetlbfs"))
continue;
- if (VIR_EXPAND_N(fs, nfs, 1) < 0)
- goto cleanup;
+ VIR_EXPAND_N(fs, nfs, 1);
tmp = &fs[nfs - 1];
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index dd3e104dbe..eee191ff23 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -510,8 +510,7 @@ void virFirewallStartTransaction(virFirewallPtr firewall,
group = virFirewallGroupNew();
group->actionFlags = flags;
- ignore_value(VIR_EXPAND_N(firewall->groups,
- firewall->ngroups, 1));
+ VIR_EXPAND_N(firewall->groups, firewall->ngroups, 1);
firewall->groups[firewall->ngroups - 1] = group;
firewall->currentGroup = firewall->ngroups - 1;
}
diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index 0d6cff3707..5e6d3ea428 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -214,9 +214,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace,
}
res->lockHeld = true;
- if (VIR_EXPAND_N(res->owners, res->nOwners, 1) < 0)
- goto error;
-
+ VIR_EXPAND_N(res->owners, res->nOwners, 1);
res->owners[res->nOwners-1] = owner;
return res;
@@ -583,8 +581,7 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
if ((res->flags & VIR_LOCK_SPACE_ACQUIRE_SHARED) &&
(flags & VIR_LOCK_SPACE_ACQUIRE_SHARED)) {
- if (VIR_EXPAND_N(res->owners, res->nOwners, 1) < 0)
- goto cleanup;
+ VIR_EXPAND_N(res->owners, res->nOwners, 1);
res->owners[res->nOwners-1] = owner;
goto done;
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 8428c91182..924fc65b50 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -653,7 +653,6 @@ int virProcessGetNamespaces(pid_t pid,
size_t *nfdlist,
int **fdlist)
{
- int ret = -1;
size_t i = 0;
const char *ns[] = { "user", "ipc", "uts",
"net", "pid", "mnt" };
@@ -667,24 +666,12 @@ int virProcessGetNamespaces(pid_t pid,
nsfile = g_strdup_printf("/proc/%llu/ns/%s", (long long)pid, ns[i]);
if ((fd = open(nsfile, O_RDONLY)) >= 0) {
- if (VIR_EXPAND_N(*fdlist, *nfdlist, 1) < 0) {
- VIR_FORCE_CLOSE(fd);
- goto cleanup;
- }
-
+ VIR_EXPAND_N(*fdlist, *nfdlist, 1);
(*fdlist)[(*nfdlist)-1] = fd;
}
}
- ret = 0;
-
- cleanup:
- if (ret < 0) {
- for (i = 0; i < *nfdlist; i++)
- VIR_FORCE_CLOSE((*fdlist)[i]);
- VIR_FREE(*fdlist);
- }
- return ret;
+ return 0;
}
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 0460be8d3a..8458db96bc 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -608,10 +608,9 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl,
if (rv < 0)
goto cleanup;
- if (resctrl->nlevels <= level &&
+ if (resctrl->nlevels <= level)
VIR_EXPAND_N(resctrl->levels, resctrl->nlevels,
- level - resctrl->nlevels + 1) < 0)
- goto cleanup;
+ level - resctrl->nlevels + 1);
if (!resctrl->levels[level]) {
virResctrlInfoPerTypePtr *types = NULL;
@@ -932,8 +931,7 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
i_type->max_cache_id++;
}
- if (VIR_EXPAND_N(*controls, *ncontrols, 1) < 0)
- goto error;
+ VIR_EXPAND_N(*controls, *ncontrols, 1);
(*controls)[*ncontrols - 1] = g_new0(virResctrlInfoPerCache, 1);
memcpy((*controls)[*ncontrols - 1], &i_type->control,
sizeof(i_type->control));
}
@@ -1098,9 +1096,8 @@ virResctrlAllocGetType(virResctrlAllocPtr alloc,
{
virResctrlAllocPerLevelPtr a_level = NULL;
- if (alloc->nlevels <= level &&
- VIR_EXPAND_N(alloc->levels, alloc->nlevels, level - alloc->nlevels + 1)
< 0)
- return NULL;
+ if (alloc->nlevels <= level)
+ VIR_EXPAND_N(alloc->levels, alloc->nlevels, level - alloc->nlevels +
1);
if (!alloc->levels[level]) {
virResctrlAllocPerTypePtr *types = NULL;
@@ -1132,10 +1129,9 @@ virResctrlAllocUpdateMask(virResctrlAllocPtr alloc,
if (!a_type)
return -1;
- if (a_type->nmasks <= cache &&
+ if (a_type->nmasks <= cache)
VIR_EXPAND_N(a_type->masks, a_type->nmasks,
- cache - a_type->nmasks + 1) < 0)
- return -1;
+ cache - a_type->nmasks + 1);
if (!a_type->masks[cache])
a_type->masks[cache] = virBitmapNewCopy(mask);
@@ -1156,10 +1152,9 @@ virResctrlAllocUpdateSize(virResctrlAllocPtr alloc,
if (!a_type)
return -1;
- if (a_type->nsizes <= cache &&
+ if (a_type->nsizes <= cache)
VIR_EXPAND_N(a_type->sizes, a_type->nsizes,
- cache - a_type->nsizes + 1) < 0)
- return -1;
+ cache - a_type->nsizes + 1);
if (!a_type->sizes[cache])
a_type->sizes[cache] = g_new0(unsigned long long, 1);
@@ -1316,10 +1311,9 @@ virResctrlAllocSetMemoryBandwidth(virResctrlAllocPtr alloc,
alloc->mem_bw = mem_bw;
}
- if (mem_bw->nbandwidths <= id &&
+ if (mem_bw->nbandwidths <= id)
VIR_EXPAND_N(mem_bw->bandwidths, mem_bw->nbandwidths,
- id - mem_bw->nbandwidths + 1) < 0)
- return -1;
+ id - mem_bw->nbandwidths + 1);
if (mem_bw->bandwidths[id]) {
virReportError(VIR_ERR_XML_ERROR,
@@ -1469,9 +1463,9 @@ virResctrlAllocParseProcessMemoryBandwidth(virResctrlInfoPtr
resctrl,
"memory bandwidth node '%u'"), id);
return -1;
}
- if (alloc->mem_bw->nbandwidths <= id &&
+ if (alloc->mem_bw->nbandwidths <= id) {
VIR_EXPAND_N(alloc->mem_bw->bandwidths, alloc->mem_bw->nbandwidths,
- id - alloc->mem_bw->nbandwidths + 1) < 0) {
+ id - alloc->mem_bw->nbandwidths + 1);
return -1;
}
if (!alloc->mem_bw->bandwidths[id])
@@ -1856,9 +1850,8 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
if (info->membw_info) {
ret->mem_bw = g_new0(virResctrlAllocMemBW, 1);
- if (VIR_EXPAND_N(ret->mem_bw->bandwidths, ret->mem_bw->nbandwidths,
- info->membw_info->max_id + 1) < 0)
- goto error;
+ VIR_EXPAND_N(ret->mem_bw->bandwidths, ret->mem_bw->nbandwidths,
+ info->membw_info->max_id + 1);
for (i = 0; i < ret->mem_bw->nbandwidths; i++) {
ret->mem_bw->bandwidths[i] = g_new0(unsigned int, 1);
@@ -2146,10 +2139,9 @@ virResctrlAllocCopyMemBW(virResctrlAllocPtr dst,
dst_bw = dst->mem_bw;
- if (src_bw->nbandwidths > dst_bw->nbandwidths &&
+ if (src_bw->nbandwidths > dst_bw->nbandwidths)
VIR_EXPAND_N(dst_bw->bandwidths, dst_bw->nbandwidths,
- src_bw->nbandwidths - dst_bw->nbandwidths) < 0)
- return -1;
+ src_bw->nbandwidths - dst_bw->nbandwidths);
for (i = 0; i < src_bw->nbandwidths; i++) {
if (dst_bw->bandwidths[i])
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 1d6141b5c1..07594292bb 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -691,8 +691,7 @@ virStringSearch(const char *str,
/* '*matches' must always be NULL terminated in every iteration
* of the loop, so start by allocating 1 element
*/
- if (VIR_EXPAND_N(*matches, nmatches, 1) < 0)
- goto cleanup;
+ VIR_EXPAND_N(*matches, nmatches, 1);
while ((nmatches - 1) < max_matches) {
g_autoptr(GMatchInfo) info = NULL;
@@ -702,8 +701,7 @@ virStringSearch(const char *str,
if (!g_regex_match(regex, str, 0, &info))
break;
- if (VIR_EXPAND_N(*matches, nmatches, 1) < 0)
- goto cleanup;
+ VIR_EXPAND_N(*matches, nmatches, 1);
match = g_match_info_fetch(info, 1);
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 1c8193cc58..df1cf59709 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -276,8 +276,7 @@ virSysinfoParsePPCProcessor(const char *base, virSysinfoDefPtr ret)
eol = strchr(base, '\n');
cur = strchr(base, ':') + 1;
- if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
- return -1;
+ VIR_EXPAND_N(ret->processor, ret->nprocessor, 1);
processor = &ret->processor[ret->nprocessor - 1];
virSkipSpaces(&cur);
@@ -409,8 +408,7 @@ virSysinfoParseARMProcessor(const char *base, virSysinfoDefPtr ret)
eol = strchr(base, '\n');
cur = strchr(base, ':') + 1;
- if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
- goto error;
+ VIR_EXPAND_N(ret->processor, ret->nprocessor, 1);
processor = &ret->processor[ret->nprocessor - 1];
virSkipSpaces(&cur);
@@ -425,10 +423,6 @@ virSysinfoParseARMProcessor(const char *base, virSysinfoDefPtr ret)
VIR_FREE(processor_type);
return 0;
-
- error:
- VIR_FREE(processor_type);
- return -1;
}
/* virSysinfoRead for ARMv7
@@ -544,8 +538,7 @@ virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
while ((tmp_base = strstr(tmp_base, "processor "))
&& (tmp_base = virSysinfoParseS390Line(tmp_base, "processor
",
&procline))) {
- if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
- goto error;
+ VIR_EXPAND_N(ret->processor, ret->nprocessor, 1);
processor = &ret->processor[ret->nprocessor - 1];
processor->processor_manufacturer = g_strdup(manufacturer);
if (!virSysinfoParseS390Delimited(procline, "version",
@@ -770,7 +763,6 @@ virSysinfoParseX86BaseBoard(const char *base,
virSysinfoBaseBoardDefPtr *baseBoard,
size_t *nbaseBoard)
{
- int ret = -1;
const char *cur;
char *eol = NULL;
virSysinfoBaseBoardDefPtr boards = NULL;
@@ -779,8 +771,7 @@ virSysinfoParseX86BaseBoard(const char *base,
while (base && (cur = strstr(base, "Base Board Information"))) {
virSysinfoBaseBoardDefPtr def;
- if (VIR_EXPAND_N(boards, nboards, 1) < 0)
- goto cleanup;
+ VIR_EXPAND_N(boards, nboards, 1);
def = &boards[nboards - 1];
@@ -842,13 +833,7 @@ virSysinfoParseX86BaseBoard(const char *base,
*nbaseBoard = nboards;
*baseBoard = g_steal_pointer(&boards);
- nboards = 0;
- ret = 0;
- cleanup:
- while (nboards--)
- virSysinfoBaseBoardDefClear(&boards[nboards]);
- VIR_FREE(boards);
- return ret;
+ return 0;
}
@@ -981,8 +966,7 @@ virSysinfoParseOEMStrings(const char *base,
if (!eol)
continue;
- if (VIR_EXPAND_N(strings->values, strings->nvalues, 1) < 0)
- goto cleanup;
+ VIR_EXPAND_N(strings->values, strings->nvalues, 1);
/* If OEM String contains newline, dmidecode escapes it as a dot.
* If this is the case then run dmidecode again to get raw string.
@@ -1023,8 +1007,7 @@ virSysinfoParseX86Processor(const char *base, virSysinfoDefPtr ret)
base = tmp_base;
eol = NULL;
- if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
- return -1;
+ VIR_EXPAND_N(ret->processor, ret->nprocessor, 1);
processor = &ret->processor[ret->nprocessor - 1];
if ((cur = strstr(base, "Socket Designation: ")) != NULL) {
@@ -1124,8 +1107,7 @@ virSysinfoParseX86Memory(const char *base, virSysinfoDefPtr ret)
base = tmp_base;
eol = NULL;
- if (VIR_EXPAND_N(ret->memory, ret->nmemory, 1) < 0)
- return -1;
+ VIR_EXPAND_N(ret->memory, ret->nmemory, 1);
memory = &ret->memory[ret->nmemory - 1];
if ((cur = strstr(base, "Size: ")) != NULL) {
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index c22f2df866..cf22edaa0a 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -738,8 +738,7 @@ virSystemdActivationAddFD(virSystemdActivationPtr act,
return 0;
}
- if (VIR_EXPAND_N(ent->fds, ent->nfds, 1) < 0)
- return -1;
+ VIR_EXPAND_N(ent->fds, ent->nfds, 1);
VIR_DEBUG("Record extra FD %d with name %s", fd, name);
ent->fds[ent->nfds - 1] = fd;
diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 942cfa48b1..42549c4892 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -183,8 +183,7 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain, bool
priority)
size_t i = 0;
struct virThreadPoolWorkerData *data = NULL;
- if (VIR_EXPAND_N(*workers, *curWorkers, gain) < 0)
- return -1;
+ VIR_EXPAND_N(*workers, *curWorkers, gain);
for (i = 0; i < gain; i++) {
g_autofree char *name = NULL;
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index 1b89233012..018d504433 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -328,8 +328,7 @@ virTypedParamsReplaceString(virTypedParameterPtr *params,
}
old = param->value.s;
} else {
- if (VIR_EXPAND_N(*params, n, 1) < 0)
- return -1;
+ VIR_EXPAND_N(*params, n, 1);
param = *params + n - 1;
}
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
index 4f12d2ebfa..f9637a65ab 100644
--- a/src/vbox/vbox_snapshot_conf.c
+++ b/src/vbox/vbox_snapshot_conf.c
@@ -472,8 +472,7 @@ virVBoxSnapshotConfAllChildren(virVBoxSnapshotConfHardDiskPtr disk,
for (i = 0; i < disk->nchildren; i++) {
tempSize = virVBoxSnapshotConfAllChildren(disk->children[i], &tempList);
- if (VIR_EXPAND_N(ret, returnSize, tempSize) < 0)
- goto error;
+ VIR_EXPAND_N(ret, returnSize, tempSize);
for (j = 0; j < tempSize; j++)
ret[returnSize - tempSize + j] = tempList[j];
@@ -481,17 +480,10 @@ virVBoxSnapshotConfAllChildren(virVBoxSnapshotConfHardDiskPtr disk,
VIR_FREE(tempList);
}
- if (VIR_EXPAND_N(ret, returnSize, 1) < 0)
- goto error;
-
+ VIR_EXPAND_N(ret, returnSize, 1);
ret[returnSize - 1] = disk;
*list = ret;
return returnSize;
-
- error:
- VIR_FREE(tempList);
- VIR_FREE(ret);
- return 0;
}
void
@@ -785,9 +777,7 @@
virVBoxSnapshotConfAddSnapshotToXmlMachine(virVBoxSnapshotConfSnapshotPtr snapsh
_("Unable to find the snapshot %s"),
snapshotParentName);
return -1;
}
- if (VIR_EXPAND_N(parentSnapshot->children, parentSnapshot->nchildren, 1)
< 0)
- return -1;
-
+ VIR_EXPAND_N(parentSnapshot->children, parentSnapshot->nchildren, 1);
parentSnapshot->children[parentSnapshot->nchildren - 1] = snapshot;
}
@@ -829,9 +819,7 @@
virVBoxSnapshotConfAddHardDiskToMediaRegistry(virVBoxSnapshotConfHardDiskPtr har
return -1;
}
/* Hard disk found */
- if (VIR_EXPAND_N(parentDisk->children, parentDisk->nchildren, 1) < 0)
- return -1;
-
+ VIR_EXPAND_N(parentDisk->children, parentDisk->nchildren, 1);
parentDisk->children[parentDisk->nchildren - 1] = hardDisk;
if (hardDisk->parent == NULL)
hardDisk->parent = parentDisk;
@@ -1395,8 +1383,7 @@ virVBoxSnapshotConfDiskListToOpen(virVBoxSnapshotConfMachinePtr
machine,
ret[returnSize - 1] = hardDisk;
while (hardDisk->parent != NULL) {
- if (VIR_EXPAND_N(ret, returnSize, 1) < 0)
- return 0;
+ VIR_EXPAND_N(ret, returnSize, 1);
ret[returnSize - 1] = hardDisk->parent;
hardDisk = hardDisk->parent;
}
@@ -1424,8 +1411,7 @@ virVBoxSnapshotConfRemoveFakeDisks(virVBoxSnapshotConfMachinePtr
machine)
for (i = 0; i < machine->mediaRegistry->ndisks; i++) {
tempSize = virVBoxSnapshotConfAllChildren(machine->mediaRegistry->disks[i],
&tempList);
- if (VIR_EXPAND_N(diskList, diskSize, tempSize) < 0)
- goto cleanup;
+ VIR_EXPAND_N(diskList, diskSize, tempSize);
for (j = 0; j < tempSize; j++)
diskList[diskSize - tempSize + j] = tempList[j];
@@ -1475,8 +1461,7 @@
virVBoxSnapshotConfDiskIsInMediaRegistry(virVBoxSnapshotConfMachinePtr machine,
for (i = 0; i < machine->mediaRegistry->ndisks; i++) {
tempSize = virVBoxSnapshotConfAllChildren(machine->mediaRegistry->disks[i],
&tempList);
- if (VIR_EXPAND_N(diskList, diskSize, tempSize) < 0)
- goto cleanup;
+ VIR_EXPAND_N(diskList, diskSize, tempSize);
for (j = 0; j < tempSize; j++)
diskList[diskSize - tempSize + j] = tempList[j];
diff --git a/tests/qemudomaincheckpointxml2xmltest.c
b/tests/qemudomaincheckpointxml2xmltest.c
index 8b4b75d753..efa6aff2cb 100644
--- a/tests/qemudomaincheckpointxml2xmltest.c
+++ b/tests/qemudomaincheckpointxml2xmltest.c
@@ -68,8 +68,7 @@ testCompareXMLToXMLFiles(const char *inxml,
if (flags & TEST_VDA_BITMAP) {
virDomainCheckpointDiskDefPtr disk;
- if (VIR_EXPAND_N(def->disks, def->ndisks, 1) < 0)
- return -1;
+ VIR_EXPAND_N(def->disks, def->ndisks, 1);
disk = &def->disks[0];
if (disk->bitmap)
return -1;
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index ae3fcf9311..227b78d527 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -117,8 +117,7 @@ qemuMonitorTestAddResponse(qemuMonitorTestPtr test,
if (have < want) {
size_t need = want - have;
- if (VIR_EXPAND_N(test->outgoing, test->outgoingCapacity, need) < 0)
- return -1;
+ VIR_EXPAND_N(test->outgoing, test->outgoingCapacity, need);
}
want -= 2;
@@ -283,10 +282,7 @@ qemuMonitorTestIO(virNetSocketPtr sock,
char *t1, *t2;
if ((test->incomingCapacity - test->incomingLength) < 1024) {
- if (VIR_EXPAND_N(test->incoming, test->incomingCapacity, 1024) < 0)
{
- err = true;
- goto cleanup;
- }
+ VIR_EXPAND_N(test->incoming, test->incomingCapacity, 1024);
}
if ((ret = virNetSocketRead(sock,
@@ -868,9 +864,7 @@ qemuMonitorTestAddItemParams(qemuMonitorTestPtr test,
}
i = data->nargs;
- if (VIR_EXPAND_N(data->args, data->nargs, 1))
- goto error;
-
+ VIR_EXPAND_N(data->args, data->nargs, 1);
data->args[i].argname = g_strdup(argname);
data->args[i].argval = g_strdup(argval);
}
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index b1bf6e0f95..def88e3950 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -144,12 +144,7 @@ testSELinuxLoadFileList(const char *testname,
*tmp = '\0';
}
- if (VIR_EXPAND_N(*files, *nfiles, 1) < 0) {
- VIR_FREE(file);
- VIR_FREE(context);
- goto cleanup;
- }
-
+ VIR_EXPAND_N(*files, *nfiles, 1);
(*files)[(*nfiles)-1].file = file;
(*files)[(*nfiles)-1].context = context;
}
diff --git a/tests/viralloctest.c b/tests/viralloctest.c
index 4794fd7f93..5e27aa51c0 100644
--- a/tests/viralloctest.c
+++ b/tests/viralloctest.c
@@ -133,8 +133,7 @@ testExpandArray(const void *opaque G_GNUC_UNUSED)
t[i].b = 20;
}
- if (VIR_EXPAND_N(t, nt, 5) < 0)
- goto cleanup;
+ VIR_EXPAND_N(t, nt, 5);
if (testCheckNonNull(t) < 0)
goto cleanup;
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 7db88f700a..f5e98a19f8 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4068,10 +4068,7 @@ cmdStartGetFDs(vshControl *ctl,
vshError(ctl, _("Unable to parse FD number '%s'"),
fdlist[i]);
goto error;
}
- if (VIR_EXPAND_N(fds, nfds, 1) < 0) {
- vshError(ctl, "%s", _("Unable to allocate FD list"));
- goto error;
- }
+ VIR_EXPAND_N(fds, nfds, 1);
fds[nfds - 1] = fd;
}
@@ -10055,16 +10052,10 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *cmd)
setlabel = false;
while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
- if (VIR_EXPAND_N(cmdargv, ncmdargv, 1) < 0) {
- vshError(ctl, _("%s: %d: failed to allocate argv"),
- __FILE__, __LINE__);
- }
+ VIR_EXPAND_N(cmdargv, ncmdargv, 1);
cmdargv[ncmdargv-1] = opt->data;
}
- if (VIR_EXPAND_N(cmdargv, ncmdargv, 1) < 0) {
- vshError(ctl, _("%s: %d: failed to allocate argv"),
- __FILE__, __LINE__);
- }
+ VIR_EXPAND_N(cmdargv, ncmdargv, 1);
cmdargv[ncmdargv - 1] = NULL;
if ((nfdlist = virDomainLxcOpenNamespace(dom, &fdlist, 0)) < 0)
@@ -13956,11 +13947,7 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
return false;
while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
- if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) {
- vshError(ctl, _("%s: %d: failed to allocate mountpoints"),
- __FILE__, __LINE__);
- goto cleanup;
- }
+ VIR_EXPAND_N(mountpoints, nmountpoints, 1);
mountpoints[nmountpoints-1] = opt->data;
}
@@ -14009,11 +13996,7 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
return false;
while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
- if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) {
- vshError(ctl, _("%s: %d: failed to allocate mountpoints"),
- __FILE__, __LINE__);
- goto cleanup;
- }
+ VIR_EXPAND_N(mountpoints, nmountpoints, 1);
mountpoints[nmountpoints-1] = opt->data;
}
--
2.31.0