mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
Do not check return value of VIR_REALLOC_N
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
52ef4a9af2
commit
1107c0b9c3
@ -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];
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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++;
|
||||
|
@ -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)
|
||||
|
@ -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]);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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); */
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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];
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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++;
|
||||
|
Loading…
Reference in New Issue
Block a user