Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/bhyve/bhyve_parse_command.c | 8 +++---
src/conf/capabilities.c | 3 +--
src/conf/domain_conf.c | 11 ++++----
src/conf/storage_conf.c | 3 +--
src/conf/virinterfaceobj.c | 2 +-
src/conf/virnetworkobj.c | 4 +--
src/conf/virnodedeviceobj.c | 2 +-
src/conf/virsecretobj.c | 2 +-
src/conf/virstorageobj.c | 2 +-
src/esx/esx_stream.c | 3 +--
src/interface/interface_backend_netcf.c | 2 +-
src/interface/interface_backend_udev.c | 2 +-
src/libxl/libxl_capabilities.c | 3 +--
src/libxl/libxl_conf.c | 14 ++++------
src/libxl/libxl_driver.c | 15 ++++-------
src/qemu/qemu_agent.c | 4 +--
src/qemu/qemu_firmware.c | 5 ++--
src/qemu/qemu_hotplug.c | 36 +++++++++----------------
src/qemu/qemu_monitor.c | 4 +--
src/qemu/qemu_monitor_json.c | 12 ++-------
src/qemu/qemu_process.c | 25 ++---------------
src/rpc/virnetclient.c | 3 +--
src/rpc/virnetmessage.c | 12 +++------
src/storage/storage_backend_disk.c | 4 +--
src/storage/storage_backend_logical.c | 3 +--
src/storage/storage_backend_rbd.c | 3 +--
src/util/virarptable.c | 3 +--
src/util/vircommand.c | 5 ++--
src/util/virdnsmasq.c | 13 +++------
src/util/virfile.c | 5 +---
src/util/virjson.c | 13 +++------
src/util/virnuma.c | 14 +++++-----
src/util/virstring.c | 3 +--
src/util/virsysinfo.c | 3 +--
src/vbox/vbox_common.c | 4 +--
tests/domaincapstest.c | 8 ++----
tests/qemublocktest.c | 3 +--
tests/viralloctest.c | 9 +++----
tools/virsh-console.c | 22 ++++++---------
tools/virt-login-shell-helper.c | 3 +--
tools/vsh.c | 6 ++---
41 files changed, 96 insertions(+), 205 deletions(-)
diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c
index 8d9a21e671..70f5ac42a0 100644
--- a/src/bhyve/bhyve_parse_command.c
+++ b/src/bhyve/bhyve_parse_command.c
@@ -219,8 +219,8 @@ bhyveCommandLineToArgv(const char *nativeConfig,
* Otherwise, later argument lists may be assigned to _argv without
* freeing the earlier ones. */
if (!_bhyve_argv && STREQ(arglist[0], "/usr/sbin/bhyve")) {
- if ((VIR_REALLOC_N(_bhyve_argv, args_count + 1) < 0)
- || (!bhyve_argc))
+ VIR_REALLOC_N(_bhyve_argv, args_count + 1);
+ if (!bhyve_argc)
goto error;
for (j = 0; j < args_count; j++)
_bhyve_argv[j] = arglist[j];
@@ -228,8 +228,8 @@ bhyveCommandLineToArgv(const char *nativeConfig,
*bhyve_argc = args_count-1;
VIR_FREE(arglist);
} else if (!_loader_argv) {
- if ((VIR_REALLOC_N(_loader_argv, args_count + 1) < 0)
- || (!loader_argc))
+ VIR_REALLOC_N(_loader_argv, args_count + 1);
+ if (!loader_argc)
goto error;
for (j = 0; j < args_count; j++)
_loader_argv[j] = arglist[j];
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index bc9035afae..573ac4e975 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -1476,8 +1476,7 @@ virCapabilitiesGetNUMASiblingInfo(int node,
tmp_size++;
}
- if (VIR_REALLOC_N(tmp, tmp_size) < 0)
- goto cleanup;
+ VIR_REALLOC_N(tmp, tmp_size);
*nsiblings = tmp_size;
*siblings = g_steal_pointer(&tmp);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index afbd6fc7c1..95602ae57e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3433,8 +3433,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
def->iothreadids[i]->iothread_id));
/* resize array */
- if (VIR_REALLOC_N(def->iothreadids, iothreads) < 0)
- return -1;
+ VIR_REALLOC_N(def->iothreadids, iothreads);
/* Populate iothreadids[] using the set bit number from thrmap */
while (def->niothreadids < iothreads) {
@@ -17587,7 +17586,8 @@ virDomainChrPreAlloc(virDomainDefPtr vmdef,
&arrPtr, &cntPtr) < 0)
return -1;
- return VIR_REALLOC_N(*arrPtr, *cntPtr + 1);
+ VIR_REALLOC_N(*arrPtr, *cntPtr + 1);
+ return 0;
}
void
@@ -21442,8 +21442,9 @@ virDomainDefParseXML(xmlDocPtr xml,
/* analysis of the host devices */
if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0)
goto error;
- if (n && VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n) < 0)
- goto error;
+ if (n > 0)
+ VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n);
+
for (i = 0; i < n; i++) {
virDomainHostdevDefPtr hostdev;
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 2e07c81f8a..310a062ee7 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1787,8 +1787,7 @@ virStoragePoolSourceListNewSource(virStoragePoolSourceListPtr list)
{
virStoragePoolSourcePtr source;
- if (VIR_REALLOC_N(list->sources, list->nsources + 1) < 0)
- return NULL;
+ VIR_REALLOC_N(list->sources, list->nsources + 1);
source = &list->sources[list->nsources++];
memset(source, 0, sizeof(*source));
diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index 00180cd36e..cc990a05cd 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -329,7 +329,7 @@ virInterfaceObjListExport(virConnectPtr conn,
if (data.ifaces) {
/* trim the array to the final size */
- ignore_value(VIR_REALLOC_N(data.ifaces, data.nifaces + 1));
+ VIR_REALLOC_N(data.ifaces, data.nifaces + 1);
*ifaces = data.ifaces;
data.ifaces = NULL;
}
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 6ff6c63218..47739718a7 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1428,7 +1428,7 @@ virNetworkObjListExport(virConnectPtr conn,
if (data.nets) {
/* trim the array to the final size */
- ignore_value(VIR_REALLOC_N(data.nets, data.nnets + 1));
+ VIR_REALLOC_N(data.nets, data.nnets + 1);
*nets = data.nets;
data.nets = NULL;
}
@@ -1816,7 +1816,7 @@ virNetworkObjPortListExport(virNetworkPtr net,
if (data.ports) {
/* trim the array to the final size */
- ignore_value(VIR_REALLOC_N(data.ports, data.nports + 1));
+ VIR_REALLOC_N(data.ports, data.nports + 1);
*ports = data.ports;
data.ports = NULL;
}
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index c9bda77b2e..ecae3d0479 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -958,7 +958,7 @@ virNodeDeviceObjListExport(virConnectPtr conn,
goto cleanup;
if (data.devices) {
- ignore_value(VIR_REALLOC_N(data.devices, data.ndevices + 1));
+ VIR_REALLOC_N(data.devices, data.ndevices + 1);
*devices = data.devices;
}
diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index fd27bb1f01..a15a288371 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -598,7 +598,7 @@ virSecretObjListExport(virConnectPtr conn,
if (data.secrets) {
/* trim the array to the final size */
- ignore_value(VIR_REALLOC_N(data.secrets, data.nsecrets + 1));
+ VIR_REALLOC_N(data.secrets, data.nsecrets + 1);
*secrets = data.secrets;
}
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 69c2c2da36..0e27b0ca65 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -2089,7 +2089,7 @@ virStoragePoolObjListExport(virConnectPtr conn,
if (data.pools) {
/* trim the array to the final size */
- ignore_value(VIR_REALLOC_N(data.pools, data.nPools + 1));
+ VIR_REALLOC_N(data.pools, data.nPools + 1);
*pools = data.pools;
}
diff --git a/src/esx/esx_stream.c b/src/esx/esx_stream.c
index e4e67a01bb..5b20804bb1 100644
--- a/src/esx/esx_stream.c
+++ b/src/esx/esx_stream.c
@@ -136,8 +136,7 @@ esxVI_CURL_WriteStream(char *input, size_t size, size_t nmemb, void
*userdata)
} else if (input_remaining > backlog_remaining) {
priv->backlog_size += input_remaining - backlog_remaining;
- if (VIR_REALLOC_N(priv->backlog, priv->backlog_size) < 0)
- return 0;
+ VIR_REALLOC_N(priv->backlog, priv->backlog_size);
}
memcpy(priv->backlog + priv->backlog_used, input + input_used,
diff --git a/src/interface/interface_backend_netcf.c
b/src/interface/interface_backend_netcf.c
index 7c0edfae63..54a141eaa9 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -714,7 +714,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
if (tmp_iface_objs) {
/* trim the array to the final size */
- ignore_value(VIR_REALLOC_N(tmp_iface_objs, niface_objs + 1));
+ VIR_REALLOC_N(tmp_iface_objs, niface_objs + 1);
*ifaces = g_steal_pointer(&tmp_iface_objs);
}
diff --git a/src/interface/interface_backend_udev.c
b/src/interface/interface_backend_udev.c
index b6809a45f3..d5bd7c8b18 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -393,7 +393,7 @@ udevConnectListAllInterfaces(virConnectPtr conn,
/* Trim the array to its final size */
if (ifaces) {
- ignore_value(VIR_REALLOC_N(ifaces_list, count + 1));
+ VIR_REALLOC_N(ifaces_list, count + 1);
*ifaces = g_steal_pointer(&ifaces_list);
}
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 10e5d46cdd..8faca38cbc 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -285,8 +285,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
if (nr_cpus_node[node] == 1) {
cpus[node] = g_new0(virCapsHostNUMACellCPU, 1);
} else {
- if (VIR_REALLOC_N(cpus[node], nr_cpus_node[node]) < 0)
- goto cleanup;
+ VIR_REALLOC_N(cpus[node], nr_cpus_node[node]);
}
/* Mapping between what libxl tells and what libvirt wants */
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 5ee15d42e3..90528d4765 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1751,9 +1751,10 @@ libxlDriverConfigNew(void)
#ifdef DEFAULT_LOADER_NVRAM
if (virFirmwareParseList(DEFAULT_LOADER_NVRAM,
&cfg->firmwares,
- &cfg->nfirmwares) < 0)
- goto error;
-
+ &cfg->nfirmwares) < 0) {
+ virObjectUnref(cfg);
+ return NULL;
+ }
#else
cfg->firmwares = g_new0(virFirmwarePtr, 1);
cfg->nfirmwares = 1;
@@ -1762,8 +1763,7 @@ libxlDriverConfigNew(void)
#endif
/* Always add hvmloader to firmwares */
- if (VIR_REALLOC_N(cfg->firmwares, cfg->nfirmwares + 1) < 0)
- goto error;
+ VIR_REALLOC_N(cfg->firmwares, cfg->nfirmwares + 1);
cfg->nfirmwares++;
cfg->firmwares[cfg->nfirmwares - 1] = g_new0(virFirmware, 1);
cfg->firmwares[cfg->nfirmwares - 1]->name = g_strdup(LIBXL_FIRMWARE_DIR
"/hvmloader");
@@ -1773,10 +1773,6 @@ libxlDriverConfigNew(void)
cfg->keepAliveCount = 5;
return cfg;
-
- error:
- virObjectUnref(cfg);
- return NULL;
}
int
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index e3d769b5d9..830634b2bd 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3054,8 +3054,7 @@ libxlDomainAttachDeviceDiskLive(virDomainObjPtr vm,
virDomainDeviceDefPtr dev)
goto cleanup;
}
- if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1);
if (libxlMakeDisk(l_disk, &x_disk) < 0)
goto cleanup;
@@ -3122,8 +3121,7 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr driver,
goto cleanup;
}
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
if (virHostdevPreparePCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
vm->def->name, vm->def->uuid,
@@ -3190,8 +3188,7 @@ libxlDomainAttachControllerDevice(libxlDriverPrivatePtr driver,
goto cleanup;
}
- if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers + 1) <
0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers + 1);
if (libxlMakeUSBController(controller, &usbctrl) < 0)
goto cleanup;
@@ -3259,8 +3256,7 @@ libxlDomainAttachHostUSBDevice(libxlDriverPrivatePtr driver,
}
}
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
if (virHostdevPrepareUSBDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
vm->def->name, &hostdev, 1, 0) < 0)
@@ -3403,8 +3399,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver,
libxl_device_nic_init(&nic);
/* preallocate new slot for device */
- if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1);
/* If appropriate, grab a physical device from the configured
* network's pool of devices, or resolve bridge device name
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index fa37d284b3..02793edd02 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -456,9 +456,7 @@ qemuAgentIORead(qemuAgentPtr agent)
QEMU_AGENT_MAX_RESPONSE);
return -1;
}
- if (VIR_REALLOC_N(agent->buffer,
- agent->bufferLength + 1024) < 0)
- return -1;
+ VIR_REALLOC_N(agent->buffer, agent->bufferLength + 1024);
agent->bufferLength += 1024;
avail += 1024;
}
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index eb33441272..a211d2fb36 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -1464,9 +1464,8 @@ qemuFirmwareGetSupported(const char *machine,
}
}
- if (fws && !*fws && nfirmwares &&
- VIR_REALLOC_N(*fws, 0) < 0)
- return -1;
+ if (fws && !*fws && nfirmwares)
+ VIR_REALLOC_N(*fws, 0);
for (i = 0; i < nfirmwares; i++)
qemuFirmwareFree(firmwares[i]);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a66354426d..58d2abb862 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -737,8 +737,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, 0, priv->qemuCaps)))
goto cleanup;
- if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1);
if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_NONE) <
0)
goto cleanup;
@@ -880,8 +879,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
if (!devstr)
goto cleanup;
- if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1);
qemuDomainObjEnterMonitor(driver, vm);
@@ -1198,8 +1196,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
virErrorPtr save_err = NULL;
/* preallocate new slot for device */
- if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1);
/* If appropriate, grab a physical device from the configured
* network's pool of devices, or resolve bridge device name
@@ -1604,8 +1601,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
unsigned int flags = 0;
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
- return -1;
+ VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
if (!cfg->relaxedACS)
flags |= VIR_HOSTDEV_STRICT_ACS_CHECK;
@@ -1938,8 +1934,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, priv->qemuCaps)))
goto cleanup;
- if (VIR_REALLOC_N(def->redirdevs, def->nredirdevs+1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(def->redirdevs, def->nredirdevs+1);
if (qemuDomainAddChardevTLSObjects(driver, vm, redirdev->source,
redirdev->info.alias, charAlias,
@@ -2286,8 +2281,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
goto cleanup;
/* preallocate space for the device definition */
- if (VIR_REALLOC_N(vm->def->rngs, vm->def->nrngs + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->rngs, vm->def->nrngs + 1);
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "rng")
< 0)
return -1;
@@ -2569,8 +2563,7 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
if (!(devstr = qemuBuildUSBHostdevDevStr(vm->def, hostdev, priv->qemuCaps)))
goto cleanup;
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1);
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorAddDevice(priv->mon, devstr);
@@ -2662,8 +2655,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, backendalias)))
goto cleanup;
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
qemuDomainObjEnterMonitor(driver, vm);
@@ -2774,8 +2766,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver,
vhostfdName)))
goto cleanup;
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
qemuDomainObjEnterMonitor(driver, vm);
@@ -2877,8 +2868,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriverPtr driver,
priv->qemuCaps)))
goto cleanup;
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0)
goto cleanup;
@@ -3006,8 +2996,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
qemuDomainPrepareShmemChardev(shmem);
- if (VIR_REALLOC_N(vm->def->shmems, vm->def->nshmems + 1) < 0)
- return -1;
+ VIR_REALLOC_N(vm->def->shmems, vm->def->nshmems + 1);
if ((shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) &&
@@ -3209,8 +3198,7 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
goto cleanup;
teardownlabel = true;
- if (VIR_REALLOC_N(vm->def->inputs, vm->def->ninputs + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(vm->def->inputs, vm->def->ninputs + 1);
qemuDomainObjEnterMonitor(driver, vm);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index c43c6f180e..3760349450 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -474,9 +474,7 @@ qemuMonitorIORead(qemuMonitorPtr mon)
QEMU_MONITOR_MAX_RESPONSE);
return -1;
}
- if (VIR_REALLOC_N(mon->buffer,
- mon->bufferLength + 1024) < 0)
- return -1;
+ VIR_REALLOC_N(mon->buffer, mon->bufferLength + 1024);
mon->bufferLength += 1024;
avail += 1024;
}
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 5e7f425495..c87a4c6ed1 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -659,12 +659,8 @@ qemuMonitorJSONParseKeywords(const char *str,
}
if (keywordAlloc == keywordCount) {
- if (VIR_REALLOC_N(keywords, keywordAlloc + 10) < 0 ||
- VIR_REALLOC_N(values, keywordAlloc + 10) < 0) {
- VIR_FREE(keyword);
- VIR_FREE(value);
- goto error;
- }
+ VIR_REALLOC_N(keywords, keywordAlloc + 10);
+ VIR_REALLOC_N(values, keywordAlloc + 10);
keywordAlloc += 10;
}
@@ -679,10 +675,6 @@ qemuMonitorJSONParseKeywords(const char *str,
*retvalues = values;
*retnkeywords = keywordCount;
return 0;
-
- error:
- qemuMonitorJSONParseKeywordsFree(keywordCount, keywords, values);
- return -1;
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b86afe4daa..fedd1f56b1 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1073,7 +1073,6 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC_UNUSED,
virDomainEventGraphicsAddressPtr localAddr = NULL;
virDomainEventGraphicsAddressPtr remoteAddr = NULL;
virDomainEventGraphicsSubjectPtr subject = NULL;
- size_t i;
localAddr = g_new0(virDomainEventGraphicsAddress, 1);
localAddr->family = localFamily;
@@ -1087,15 +1086,13 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC_UNUSED,
subject = g_new0(virDomainEventGraphicsSubject, 1);
if (x509dname) {
- if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0)
- goto error;
+ VIR_REALLOC_N(subject->identities, subject->nidentity+1);
subject->nidentity++;
subject->identities[subject->nidentity - 1].type =
g_strdup("x509dname");
subject->identities[subject->nidentity - 1].name = g_strdup(x509dname);
}
if (saslUsername) {
- if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0)
- goto error;
+ VIR_REALLOC_N(subject->identities, subject->nidentity+1);
subject->nidentity++;
subject->identities[subject->nidentity - 1].type =
g_strdup("saslUsername");
subject->identities[subject->nidentity - 1].name = g_strdup(saslUsername);
@@ -1108,24 +1105,6 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC_UNUSED,
virObjectEventStateQueue(driver->domainEventState, event);
return 0;
-
- error:
- VIR_FREE(localAddr->service);
- VIR_FREE(localAddr->node);
- VIR_FREE(localAddr);
-
- VIR_FREE(remoteAddr->service);
- VIR_FREE(remoteAddr->node);
- VIR_FREE(remoteAddr);
-
- for (i = 0; i < subject->nidentity; i++) {
- VIR_FREE(subject->identities[i].type);
- VIR_FREE(subject->identities[i].name);
- }
- VIR_FREE(subject->identities);
- VIR_FREE(subject);
-
- return -1;
}
static int
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 2de5cfe4b6..1ac6bc08de 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -1154,8 +1154,7 @@ virNetClientCallDispatchReply(virNetClientPtr client)
return -1;
}
- if (VIR_REALLOC_N(thecall->msg->buffer, client->msg.bufferLength) < 0)
- return -1;
+ VIR_REALLOC_N(thecall->msg->buffer, client->msg.bufferLength);
memcpy(thecall->msg->buffer, client->msg.buffer,
client->msg.bufferLength);
memcpy(&thecall->msg->header, &client->msg.header,
sizeof(client->msg.header));
diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index 9f7334ae4c..f2b8526817 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -152,8 +152,7 @@ int virNetMessageDecodeLength(virNetMessagePtr msg)
/* Extend our declared buffer length and carry
on reading the header + payload */
msg->bufferLength += len;
- if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
- goto cleanup;
+ VIR_REALLOC_N(msg->buffer, msg->bufferLength);
VIR_DEBUG("Got length, now need %zu total (%u more)",
msg->bufferLength, len);
@@ -229,8 +228,7 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg)
unsigned int len = 0;
msg->bufferLength = VIR_NET_MESSAGE_INITIAL + VIR_NET_MESSAGE_LEN_MAX;
- if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
- return ret;
+ VIR_REALLOC_N(msg->buffer, msg->bufferLength);
msg->bufferOffset = 0;
/* Format the header. */
@@ -370,8 +368,7 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
msg->bufferLength = newlen + VIR_NET_MESSAGE_LEN_MAX;
- if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
- goto error;
+ VIR_REALLOC_N(msg->buffer, msg->bufferLength);
xdrmem_create(&xdr, msg->buffer + msg->bufferOffset,
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
@@ -454,8 +451,7 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
msg->bufferLength = msg->bufferOffset + len;
- if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
- return -1;
+ VIR_REALLOC_N(msg->buffer, msg->bufferLength);
VIR_DEBUG("Increased message buffer length = %zu",
msg->bufferLength);
}
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index af90f3fc45..49747cb7c9 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -235,9 +235,7 @@ virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPtr pool,
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virStoragePoolSourceDevicePtr dev = &def->source.devices[0];
- if (VIR_REALLOC_N(dev->freeExtents,
- dev->nfreeExtent + 1) < 0)
- return -1;
+ VIR_REALLOC_N(dev->freeExtents, dev->nfreeExtent + 1);
memset(dev->freeExtents +
dev->nfreeExtent, 0,
diff --git a/src/storage/storage_backend_logical.c
b/src/storage/storage_backend_logical.c
index ead3dab4fd..3e65318188 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -447,8 +447,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(char **const groups,
thisSource->name = g_steal_pointer(&vgname);
}
- if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0)
- return -1;
+ VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1);
dev = &thisSource->devices[thisSource->ndevice];
thisSource->ndevice++;
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 33dda27087..871304d0d3 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -583,8 +583,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr)
size_t i;
while (true) {
- if (VIR_REALLOC_N(images, nimages) < 0)
- goto error;
+ VIR_REALLOC_N(images, nimages);
rc = rbd_list2(ptr->ioctx, images, &nimages);
if (rc >= 0)
diff --git a/src/util/virarptable.c b/src/util/virarptable.c
index dfe3ebee5b..6abf5b454a 100644
--- a/src/util/virarptable.c
+++ b/src/util/virarptable.c
@@ -114,9 +114,8 @@ virArpTableGet(void)
if (tb[NDA_DST]) {
g_autofree char *ipstr = NULL;
virSocketAddr virAddr;
- if (VIR_REALLOC_N(table->t, num + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(table->t, num + 1);
table->n = num + 1;
addr = RTA_DATA(tb[NDA_DST]);
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 29c17454d8..eb70f8cf85 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -1742,7 +1742,7 @@ virCommandSetSendBuffer(virCommandPtr cmd,
}
i = virCommandGetNumSendBuffers(cmd);
- ignore_value(VIR_REALLOC_N(cmd->sendBuffers, i + 1));
+ VIR_REALLOC_N(cmd->sendBuffers, i + 1);
cmd->sendBuffers[i].fd = pipefd[1];
cmd->sendBuffers[i].buffer = g_steal_pointer(&localbuf);
@@ -2250,8 +2250,7 @@ virCommandProcessIO(virCommandPtr cmd)
else
errfd = -1;
} else {
- if (VIR_REALLOC_N(*buf, *len + done + 1) < 0)
- goto cleanup;
+ VIR_REALLOC_N(*buf, *len + done + 1);
memcpy(*buf + *len, data, done);
*len += done;
}
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index 3913114eca..fa59954997 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -105,8 +105,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile,
}
if (idx < 0) {
- if (VIR_REALLOC_N(addnhostsfile->hosts, addnhostsfile->nhosts + 1) < 0)
- goto error;
+ VIR_REALLOC_N(addnhostsfile->hosts, addnhostsfile->nhosts + 1);
idx = addnhostsfile->nhosts;
addnhostsfile->hosts[idx].hostnames = g_new0(char *, 1);
@@ -117,8 +116,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile,
addnhostsfile->nhosts++;
}
- if (VIR_REALLOC_N(addnhostsfile->hosts[idx].hostnames,
addnhostsfile->hosts[idx].nhostnames + 1) < 0)
- goto error;
+ VIR_REALLOC_N(addnhostsfile->hosts[idx].hostnames,
addnhostsfile->hosts[idx].nhostnames + 1);
addnhostsfile->hosts[idx].hostnames[addnhostsfile->hosts[idx].nhostnames] =
g_strdup(name);
@@ -127,10 +125,6 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile,
addnhostsfile->hosts[idx].nhostnames++;
return 0;
-
- error:
- VIR_FREE(ipstr);
- return -1;
}
static dnsmasqAddnHostsfile *
@@ -297,8 +291,7 @@ hostsfileAdd(dnsmasqHostsfile *hostsfile,
g_autofree char *ipstr = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- if (VIR_REALLOC_N(hostsfile->hosts, hostsfile->nhosts + 1) < 0)
- return -1;
+ VIR_REALLOC_N(hostsfile->hosts, hostsfile->nhosts + 1);
if (!(ipstr = virSocketAddrFormat(ip)))
return -1;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index c0730f6641..93fac200cc 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1346,10 +1346,7 @@ saferead_lim(int fd, size_t max_len, size_t *length)
if (alloc < size + BUFSIZ + 1)
alloc = size + BUFSIZ + 1;
- if (VIR_REALLOC_N(buf, alloc) < 0) {
- save_errno = errno;
- break;
- }
+ VIR_REALLOC_N(buf, alloc);
}
/* Ensure that (size + requested <= max_len); */
diff --git a/src/util/virjson.c b/src/util/virjson.c
index f2a6024db6..9eb4dc4f18 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -779,9 +779,7 @@ virJSONValueArrayAppend(virJSONValuePtr array,
return -1;
}
- if (VIR_REALLOC_N(array->data.array.values,
- array->data.array.nvalues + 1) < 0)
- return -1;
+ VIR_REALLOC_N(array->data.array.values, array->data.array.nvalues + 1);
array->data.array.values[array->data.array.nvalues] = g_steal_pointer(value);
array->data.array.nvalues++;
@@ -1697,10 +1695,7 @@ virJSONParserHandleStartMap(void *ctx)
if (virJSONParserInsertValue(parser, &value) < 0)
return 0;
- if (VIR_REALLOC_N(parser->state,
- parser->nstate + 1) < 0) {
- return 0;
- }
+ VIR_REALLOC_N(parser->state, parser->nstate + 1);
parser->state[parser->nstate].value = tmp;
parser->state[parser->nstate].key = NULL;
@@ -1745,9 +1740,7 @@ virJSONParserHandleStartArray(void *ctx)
if (virJSONParserInsertValue(parser, &value) < 0)
return 0;
- if (VIR_REALLOC_N(parser->state,
- parser->nstate + 1) < 0)
- return 0;
+ VIR_REALLOC_N(parser->state, parser->nstate + 1);
parser->state[parser->nstate].value = tmp;
parser->state[parser->nstate].key = NULL;
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index a05e4ac72c..6c194b54d1 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -795,10 +795,9 @@ virNumaGetPages(int node,
&page_avail, &page_free) < 0)
return -1;
- if (VIR_REALLOC_N(tmp_size, ntmp + 1) < 0 ||
- VIR_REALLOC_N(tmp_avail, ntmp + 1) < 0 ||
- VIR_REALLOC_N(tmp_free, ntmp + 1) < 0)
- return -1;
+ VIR_REALLOC_N(tmp_size, ntmp + 1);
+ VIR_REALLOC_N(tmp_avail, ntmp + 1);
+ VIR_REALLOC_N(tmp_free, ntmp + 1);
tmp_size[ntmp] = page_size;
tmp_avail[ntmp] = page_avail;
@@ -814,10 +813,9 @@ virNumaGetPages(int node,
return -1;
/* Now append the ordinary system pages */
- if (VIR_REALLOC_N(tmp_size, ntmp + 1) < 0 ||
- VIR_REALLOC_N(tmp_avail, ntmp + 1) < 0 ||
- VIR_REALLOC_N(tmp_free, ntmp + 1) < 0)
- return -1;
+ VIR_REALLOC_N(tmp_size, ntmp + 1);
+ VIR_REALLOC_N(tmp_avail, ntmp + 1);
+ VIR_REALLOC_N(tmp_free, ntmp + 1);
if (virNumaGetPageInfo(node, system_page_size, huge_page_sum,
&tmp_avail[ntmp], &tmp_free[ntmp]) < 0)
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 07594292bb..7749eb2db5 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -78,8 +78,7 @@ virStringListMerge(char ***dst,
dst_len = g_strv_length(*dst);
src_len = g_strv_length(*src);
- if (VIR_REALLOC_N(*dst, dst_len + src_len + 1) < 0)
- return -1;
+ VIR_REALLOC_N(*dst, dst_len + src_len + 1);
for (i = 0; i <= src_len; i++)
(*dst)[i + dst_len] = (*src)[i];
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index df1cf59709..2ddbc1ac17 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -827,8 +827,7 @@ virSysinfoParseX86BaseBoard(const char *base,
if (nboards == 0) {
VIR_FREE(boards);
} else {
- /* This is safe, as we can be only shrinking the memory */
- ignore_value(VIR_REALLOC_N(boards, nboards));
+ VIR_REALLOC_N(boards, nboards);
}
*nbaseBoard = nboards;
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 69b99317f2..2ac22120d8 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -7560,9 +7560,7 @@ vboxConnectListAllDomains(virConnectPtr conn,
}
if (doms) {
- /* safe to ignore, new size will be equal or less than
- * previous allocation */
- ignore_value(VIR_REALLOC_N(doms, count + 1));
+ VIR_REALLOC_N(doms, count + 1);
*domains = g_steal_pointer(&doms);
}
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index 65d9f4c635..f913346331 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -30,22 +30,18 @@
static int G_GNUC_NULL_TERMINATED
fillStringValues(virDomainCapsStringValuesPtr values, ...)
{
- int ret = 0;
va_list list;
const char *str;
va_start(list, values);
while ((str = va_arg(list, const char *))) {
- if (VIR_REALLOC_N(values->values, values->nvalues + 1) < 0) {
- ret = -1;
- break;
- }
+ VIR_REALLOC_N(values->values, values->nvalues + 1);
values->values[values->nvalues] = g_strdup(str);
values->nvalues++;
}
va_end(list);
- return ret;
+ return 0;
}
#endif /* WITH_QEMU || WITH_BHYVE */
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index bbfcfee92d..5cc7c27ebe 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -316,8 +316,7 @@ testQemuDiskXMLToProps(const void *opaque)
return -1;
}
- if (VIR_REALLOC_N(data->images, data->nimages + 1) < 0)
- return -1;
+ VIR_REALLOC_N(data->images, data->nimages + 1);
data->images[data->nimages].formatprops =
g_steal_pointer(&formatProps);
data->images[data->nimages].storageprops =
g_steal_pointer(&storageProps);
diff --git a/tests/viralloctest.c b/tests/viralloctest.c
index 5e27aa51c0..1dc11dce7b 100644
--- a/tests/viralloctest.c
+++ b/tests/viralloctest.c
@@ -60,8 +60,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED)
t[i].b = 20;
}
- if (VIR_REALLOC_N(t, nt + 5) < 0)
- goto cleanup;
+ VIR_REALLOC_N(t, nt + 5);
if (testCheckNonNull(t) < 0)
goto cleanup;
@@ -74,8 +73,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED)
}
}
- if (VIR_REALLOC_N(t, nt) < 0)
- goto cleanup;
+ VIR_REALLOC_N(t, nt);
if (testCheckNonNull(t) < 0)
goto cleanup;
@@ -88,8 +86,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED)
}
}
- if (VIR_REALLOC_N(t, nt - 5) < 0)
- goto cleanup;
+ VIR_REALLOC_N(t, nt - 5);
if (testCheckNonNull(t) < 0)
goto cleanup;
diff --git a/tools/virsh-console.c b/tools/virsh-console.c
index 4e9bdb67e1..39e38e5959 100644
--- a/tools/virsh-console.c
+++ b/tools/virsh-console.c
@@ -167,11 +167,8 @@ virConsoleEventOnStream(virStreamPtr st,
int got;
if (avail < 1024) {
- if (VIR_REALLOC_N(con->streamToTerminal.data,
- con->streamToTerminal.length + 1024) < 0) {
- virConsoleShutdown(con, false);
- goto cleanup;
- }
+ VIR_REALLOC_N(con->streamToTerminal.data,
+ con->streamToTerminal.length + 1024);
con->streamToTerminal.length += 1024;
avail += 1024;
}
@@ -212,8 +209,8 @@ virConsoleEventOnStream(virStreamPtr st,
avail = con->terminalToStream.length - con->terminalToStream.offset;
if (avail > 1024) {
- ignore_value(VIR_REALLOC_N(con->terminalToStream.data,
- con->terminalToStream.offset + 1024));
+ VIR_REALLOC_N(con->terminalToStream.data,
+ con->terminalToStream.offset + 1024);
con->terminalToStream.length = con->terminalToStream.offset + 1024;
}
}
@@ -251,11 +248,8 @@ virConsoleEventOnStdin(int watch G_GNUC_UNUSED,
int got;
if (avail < 1024) {
- if (VIR_REALLOC_N(con->terminalToStream.data,
- con->terminalToStream.length + 1024) < 0) {
- virConsoleShutdown(con, false);
- goto cleanup;
- }
+ VIR_REALLOC_N(con->terminalToStream.data,
+ con->terminalToStream.length + 1024);
con->terminalToStream.length += 1024;
avail += 1024;
}
@@ -340,8 +334,8 @@ virConsoleEventOnStdout(int watch G_GNUC_UNUSED,
avail = con->streamToTerminal.length - con->streamToTerminal.offset;
if (avail > 1024) {
- ignore_value(VIR_REALLOC_N(con->streamToTerminal.data,
- con->streamToTerminal.offset + 1024));
+ VIR_REALLOC_N(con->streamToTerminal.data,
+ con->streamToTerminal.offset + 1024);
con->streamToTerminal.length = con->streamToTerminal.offset + 1024;
}
}
diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helper.c
index 1ac02bed00..f848056386 100644
--- a/tools/virt-login-shell-helper.c
+++ b/tools/virt-login-shell-helper.c
@@ -335,8 +335,7 @@ main(int argc, char **argv)
}
if (cmdstr) {
- if (VIR_REALLOC_N(shargv, shargvlen + 3) < 0)
- goto cleanup;
+ VIR_REALLOC_N(shargv, shargvlen + 3);
shargv[shargvlen++] = g_strdup("-c");
shargv[shargvlen++] = g_strdup(cmdstr);
shargv[shargvlen] = NULL;
diff --git a/tools/vsh.c b/tools/vsh.c
index 8fb033249e..1ffc13d443 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2582,8 +2582,7 @@ vshReadlineCommandGenerator(void)
if (cmds[cmd_list_index].flags & VSH_CMD_FLAG_ALIAS)
continue;
- if (VIR_REALLOC_N(ret, ret_size + 2) < 0)
- return NULL;
+ VIR_REALLOC_N(ret, ret_size + 2);
ret[ret_size] = g_strdup(name);
ret_size++;
@@ -2630,8 +2629,7 @@ vshReadlineOptionsGenerator(const vshCmdDef *cmd,
if (exists)
continue;
- if (VIR_REALLOC_N(ret, ret_size + 2) < 0)
- return NULL;
+ VIR_REALLOC_N(ret, ret_size + 2);
ret[ret_size] = g_strdup_printf("--%s", name);
ret_size++;
--
2.31.0