mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00: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
|
* Otherwise, later argument lists may be assigned to _argv without
|
||||||
* freeing the earlier ones. */
|
* freeing the earlier ones. */
|
||||||
if (!_bhyve_argv && STREQ(arglist[0], "/usr/sbin/bhyve")) {
|
if (!_bhyve_argv && STREQ(arglist[0], "/usr/sbin/bhyve")) {
|
||||||
if ((VIR_REALLOC_N(_bhyve_argv, args_count + 1) < 0)
|
VIR_REALLOC_N(_bhyve_argv, args_count + 1);
|
||||||
|| (!bhyve_argc))
|
if (!bhyve_argc)
|
||||||
goto error;
|
goto error;
|
||||||
for (j = 0; j < args_count; j++)
|
for (j = 0; j < args_count; j++)
|
||||||
_bhyve_argv[j] = arglist[j];
|
_bhyve_argv[j] = arglist[j];
|
||||||
@ -228,8 +228,8 @@ bhyveCommandLineToArgv(const char *nativeConfig,
|
|||||||
*bhyve_argc = args_count-1;
|
*bhyve_argc = args_count-1;
|
||||||
VIR_FREE(arglist);
|
VIR_FREE(arglist);
|
||||||
} else if (!_loader_argv) {
|
} else if (!_loader_argv) {
|
||||||
if ((VIR_REALLOC_N(_loader_argv, args_count + 1) < 0)
|
VIR_REALLOC_N(_loader_argv, args_count + 1);
|
||||||
|| (!loader_argc))
|
if (!loader_argc)
|
||||||
goto error;
|
goto error;
|
||||||
for (j = 0; j < args_count; j++)
|
for (j = 0; j < args_count; j++)
|
||||||
_loader_argv[j] = arglist[j];
|
_loader_argv[j] = arglist[j];
|
||||||
|
@ -1476,8 +1476,7 @@ virCapabilitiesGetNUMASiblingInfo(int node,
|
|||||||
tmp_size++;
|
tmp_size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(tmp, tmp_size) < 0)
|
VIR_REALLOC_N(tmp, tmp_size);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
*nsiblings = tmp_size;
|
*nsiblings = tmp_size;
|
||||||
*siblings = g_steal_pointer(&tmp);
|
*siblings = g_steal_pointer(&tmp);
|
||||||
|
@ -3433,8 +3433,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
|
|||||||
def->iothreadids[i]->iothread_id));
|
def->iothreadids[i]->iothread_id));
|
||||||
|
|
||||||
/* resize array */
|
/* resize array */
|
||||||
if (VIR_REALLOC_N(def->iothreadids, iothreads) < 0)
|
VIR_REALLOC_N(def->iothreadids, iothreads);
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Populate iothreadids[] using the set bit number from thrmap */
|
/* Populate iothreadids[] using the set bit number from thrmap */
|
||||||
while (def->niothreadids < iothreads) {
|
while (def->niothreadids < iothreads) {
|
||||||
@ -17587,7 +17586,8 @@ virDomainChrPreAlloc(virDomainDefPtr vmdef,
|
|||||||
&arrPtr, &cntPtr) < 0)
|
&arrPtr, &cntPtr) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return VIR_REALLOC_N(*arrPtr, *cntPtr + 1);
|
VIR_REALLOC_N(*arrPtr, *cntPtr + 1);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -21442,8 +21442,9 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
/* analysis of the host devices */
|
/* analysis of the host devices */
|
||||||
if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0)
|
if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (n && VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n) < 0)
|
if (n > 0)
|
||||||
goto error;
|
VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
virDomainHostdevDefPtr hostdev;
|
virDomainHostdevDefPtr hostdev;
|
||||||
|
|
||||||
|
@ -1787,8 +1787,7 @@ virStoragePoolSourceListNewSource(virStoragePoolSourceListPtr list)
|
|||||||
{
|
{
|
||||||
virStoragePoolSourcePtr source;
|
virStoragePoolSourcePtr source;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(list->sources, list->nsources + 1) < 0)
|
VIR_REALLOC_N(list->sources, list->nsources + 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
source = &list->sources[list->nsources++];
|
source = &list->sources[list->nsources++];
|
||||||
memset(source, 0, sizeof(*source));
|
memset(source, 0, sizeof(*source));
|
||||||
|
@ -329,7 +329,7 @@ virInterfaceObjListExport(virConnectPtr conn,
|
|||||||
|
|
||||||
if (data.ifaces) {
|
if (data.ifaces) {
|
||||||
/* trim the array to the final size */
|
/* 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;
|
*ifaces = data.ifaces;
|
||||||
data.ifaces = NULL;
|
data.ifaces = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1428,7 +1428,7 @@ virNetworkObjListExport(virConnectPtr conn,
|
|||||||
|
|
||||||
if (data.nets) {
|
if (data.nets) {
|
||||||
/* trim the array to the final size */
|
/* 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;
|
*nets = data.nets;
|
||||||
data.nets = NULL;
|
data.nets = NULL;
|
||||||
}
|
}
|
||||||
@ -1816,7 +1816,7 @@ virNetworkObjPortListExport(virNetworkPtr net,
|
|||||||
|
|
||||||
if (data.ports) {
|
if (data.ports) {
|
||||||
/* trim the array to the final size */
|
/* 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;
|
*ports = data.ports;
|
||||||
data.ports = NULL;
|
data.ports = NULL;
|
||||||
}
|
}
|
||||||
|
@ -958,7 +958,7 @@ virNodeDeviceObjListExport(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (data.devices) {
|
if (data.devices) {
|
||||||
ignore_value(VIR_REALLOC_N(data.devices, data.ndevices + 1));
|
VIR_REALLOC_N(data.devices, data.ndevices + 1);
|
||||||
*devices = data.devices;
|
*devices = data.devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ virSecretObjListExport(virConnectPtr conn,
|
|||||||
|
|
||||||
if (data.secrets) {
|
if (data.secrets) {
|
||||||
/* trim the array to the final size */
|
/* 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;
|
*secrets = data.secrets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2089,7 +2089,7 @@ virStoragePoolObjListExport(virConnectPtr conn,
|
|||||||
|
|
||||||
if (data.pools) {
|
if (data.pools) {
|
||||||
/* trim the array to the final size */
|
/* 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;
|
*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) {
|
} else if (input_remaining > backlog_remaining) {
|
||||||
priv->backlog_size += input_remaining - backlog_remaining;
|
priv->backlog_size += input_remaining - backlog_remaining;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(priv->backlog, priv->backlog_size) < 0)
|
VIR_REALLOC_N(priv->backlog, priv->backlog_size);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(priv->backlog + priv->backlog_used, input + input_used,
|
memcpy(priv->backlog + priv->backlog_used, input + input_used,
|
||||||
|
@ -714,7 +714,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
|
|||||||
|
|
||||||
if (tmp_iface_objs) {
|
if (tmp_iface_objs) {
|
||||||
/* trim the array to the final size */
|
/* 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);
|
*ifaces = g_steal_pointer(&tmp_iface_objs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ udevConnectListAllInterfaces(virConnectPtr conn,
|
|||||||
|
|
||||||
/* Trim the array to its final size */
|
/* Trim the array to its final size */
|
||||||
if (ifaces) {
|
if (ifaces) {
|
||||||
ignore_value(VIR_REALLOC_N(ifaces_list, count + 1));
|
VIR_REALLOC_N(ifaces_list, count + 1);
|
||||||
*ifaces = g_steal_pointer(&ifaces_list);
|
*ifaces = g_steal_pointer(&ifaces_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,8 +285,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
|
|||||||
if (nr_cpus_node[node] == 1) {
|
if (nr_cpus_node[node] == 1) {
|
||||||
cpus[node] = g_new0(virCapsHostNUMACellCPU, 1);
|
cpus[node] = g_new0(virCapsHostNUMACellCPU, 1);
|
||||||
} else {
|
} else {
|
||||||
if (VIR_REALLOC_N(cpus[node], nr_cpus_node[node]) < 0)
|
VIR_REALLOC_N(cpus[node], nr_cpus_node[node]);
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mapping between what libxl tells and what libvirt wants */
|
/* Mapping between what libxl tells and what libvirt wants */
|
||||||
|
@ -1751,9 +1751,10 @@ libxlDriverConfigNew(void)
|
|||||||
#ifdef DEFAULT_LOADER_NVRAM
|
#ifdef DEFAULT_LOADER_NVRAM
|
||||||
if (virFirmwareParseList(DEFAULT_LOADER_NVRAM,
|
if (virFirmwareParseList(DEFAULT_LOADER_NVRAM,
|
||||||
&cfg->firmwares,
|
&cfg->firmwares,
|
||||||
&cfg->nfirmwares) < 0)
|
&cfg->nfirmwares) < 0) {
|
||||||
goto error;
|
virObjectUnref(cfg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
cfg->firmwares = g_new0(virFirmwarePtr, 1);
|
cfg->firmwares = g_new0(virFirmwarePtr, 1);
|
||||||
cfg->nfirmwares = 1;
|
cfg->nfirmwares = 1;
|
||||||
@ -1762,8 +1763,7 @@ libxlDriverConfigNew(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Always add hvmloader to firmwares */
|
/* Always add hvmloader to firmwares */
|
||||||
if (VIR_REALLOC_N(cfg->firmwares, cfg->nfirmwares + 1) < 0)
|
VIR_REALLOC_N(cfg->firmwares, cfg->nfirmwares + 1);
|
||||||
goto error;
|
|
||||||
cfg->nfirmwares++;
|
cfg->nfirmwares++;
|
||||||
cfg->firmwares[cfg->nfirmwares - 1] = g_new0(virFirmware, 1);
|
cfg->firmwares[cfg->nfirmwares - 1] = g_new0(virFirmware, 1);
|
||||||
cfg->firmwares[cfg->nfirmwares - 1]->name = g_strdup(LIBXL_FIRMWARE_DIR "/hvmloader");
|
cfg->firmwares[cfg->nfirmwares - 1]->name = g_strdup(LIBXL_FIRMWARE_DIR "/hvmloader");
|
||||||
@ -1773,10 +1773,6 @@ libxlDriverConfigNew(void)
|
|||||||
cfg->keepAliveCount = 5;
|
cfg->keepAliveCount = 5;
|
||||||
|
|
||||||
return cfg;
|
return cfg;
|
||||||
|
|
||||||
error:
|
|
||||||
virObjectUnref(cfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -3054,8 +3054,7 @@ libxlDomainAttachDeviceDiskLive(virDomainObjPtr vm, virDomainDeviceDefPtr dev)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
|
VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (libxlMakeDisk(l_disk, &x_disk) < 0)
|
if (libxlMakeDisk(l_disk, &x_disk) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3122,8 +3121,7 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
|
VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virHostdevPreparePCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
if (virHostdevPreparePCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
||||||
vm->def->name, vm->def->uuid,
|
vm->def->name, vm->def->uuid,
|
||||||
@ -3190,8 +3188,7 @@ libxlDomainAttachControllerDevice(libxlDriverPrivatePtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers + 1) < 0)
|
VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (libxlMakeUSBController(controller, &usbctrl) < 0)
|
if (libxlMakeUSBController(controller, &usbctrl) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3259,8 +3256,7 @@ libxlDomainAttachHostUSBDevice(libxlDriverPrivatePtr driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
|
VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virHostdevPrepareUSBDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
if (virHostdevPrepareUSBDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
||||||
vm->def->name, &hostdev, 1, 0) < 0)
|
vm->def->name, &hostdev, 1, 0) < 0)
|
||||||
@ -3403,8 +3399,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver,
|
|||||||
libxl_device_nic_init(&nic);
|
libxl_device_nic_init(&nic);
|
||||||
|
|
||||||
/* preallocate new slot for device */
|
/* preallocate new slot for device */
|
||||||
if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
|
VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* If appropriate, grab a physical device from the configured
|
/* If appropriate, grab a physical device from the configured
|
||||||
* network's pool of devices, or resolve bridge device name
|
* network's pool of devices, or resolve bridge device name
|
||||||
|
@ -456,9 +456,7 @@ qemuAgentIORead(qemuAgentPtr agent)
|
|||||||
QEMU_AGENT_MAX_RESPONSE);
|
QEMU_AGENT_MAX_RESPONSE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (VIR_REALLOC_N(agent->buffer,
|
VIR_REALLOC_N(agent->buffer, agent->bufferLength + 1024);
|
||||||
agent->bufferLength + 1024) < 0)
|
|
||||||
return -1;
|
|
||||||
agent->bufferLength += 1024;
|
agent->bufferLength += 1024;
|
||||||
avail += 1024;
|
avail += 1024;
|
||||||
}
|
}
|
||||||
|
@ -1464,9 +1464,8 @@ qemuFirmwareGetSupported(const char *machine,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fws && !*fws && nfirmwares &&
|
if (fws && !*fws && nfirmwares)
|
||||||
VIR_REALLOC_N(*fws, 0) < 0)
|
VIR_REALLOC_N(*fws, 0);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < nfirmwares; i++)
|
for (i = 0; i < nfirmwares; i++)
|
||||||
qemuFirmwareFree(firmwares[i]);
|
qemuFirmwareFree(firmwares[i]);
|
||||||
|
@ -737,8 +737,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
|
|||||||
if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, 0, priv->qemuCaps)))
|
if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, 0, priv->qemuCaps)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1) < 0)
|
VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_NONE) < 0)
|
if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -880,8 +879,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
|
|||||||
if (!devstr)
|
if (!devstr)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1) < 0)
|
VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
|
||||||
@ -1198,8 +1196,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
virErrorPtr save_err = NULL;
|
virErrorPtr save_err = NULL;
|
||||||
|
|
||||||
/* preallocate new slot for device */
|
/* preallocate new slot for device */
|
||||||
if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
|
VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* If appropriate, grab a physical device from the configured
|
/* If appropriate, grab a physical device from the configured
|
||||||
* network's pool of devices, or resolve bridge device name
|
* network's pool of devices, or resolve bridge device name
|
||||||
@ -1604,8 +1601,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
|
|||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
|
VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!cfg->relaxedACS)
|
if (!cfg->relaxedACS)
|
||||||
flags |= VIR_HOSTDEV_STRICT_ACS_CHECK;
|
flags |= VIR_HOSTDEV_STRICT_ACS_CHECK;
|
||||||
@ -1938,8 +1934,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
|||||||
if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, priv->qemuCaps)))
|
if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, priv->qemuCaps)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(def->redirdevs, def->nredirdevs+1) < 0)
|
VIR_REALLOC_N(def->redirdevs, def->nredirdevs+1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuDomainAddChardevTLSObjects(driver, vm, redirdev->source,
|
if (qemuDomainAddChardevTLSObjects(driver, vm, redirdev->source,
|
||||||
redirdev->info.alias, charAlias,
|
redirdev->info.alias, charAlias,
|
||||||
@ -2286,8 +2281,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* preallocate space for the device definition */
|
/* preallocate space for the device definition */
|
||||||
if (VIR_REALLOC_N(vm->def->rngs, vm->def->nrngs + 1) < 0)
|
VIR_REALLOC_N(vm->def->rngs, vm->def->nrngs + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "rng") < 0)
|
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "rng") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2569,8 +2563,7 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
|
|||||||
if (!(devstr = qemuBuildUSBHostdevDevStr(vm->def, hostdev, priv->qemuCaps)))
|
if (!(devstr = qemuBuildUSBHostdevDevStr(vm->def, hostdev, priv->qemuCaps)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0)
|
VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
ret = qemuMonitorAddDevice(priv->mon, devstr);
|
ret = qemuMonitorAddDevice(priv->mon, devstr);
|
||||||
@ -2662,8 +2655,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
|
|||||||
if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, backendalias)))
|
if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, backendalias)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
|
VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
|
||||||
@ -2774,8 +2766,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver,
|
|||||||
vhostfdName)))
|
vhostfdName)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
|
VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
|
||||||
@ -2877,8 +2868,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriverPtr driver,
|
|||||||
priv->qemuCaps)))
|
priv->qemuCaps)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)
|
VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0)
|
if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3006,8 +2996,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
qemuDomainPrepareShmemChardev(shmem);
|
qemuDomainPrepareShmemChardev(shmem);
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->shmems, vm->def->nshmems + 1) < 0)
|
VIR_REALLOC_N(vm->def->shmems, vm->def->nshmems + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if ((shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
|
if ((shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
|
||||||
shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) &&
|
shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) &&
|
||||||
@ -3209,8 +3198,7 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
teardownlabel = true;
|
teardownlabel = true;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->inputs, vm->def->ninputs + 1) < 0)
|
VIR_REALLOC_N(vm->def->inputs, vm->def->ninputs + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
|
||||||
|
@ -474,9 +474,7 @@ qemuMonitorIORead(qemuMonitorPtr mon)
|
|||||||
QEMU_MONITOR_MAX_RESPONSE);
|
QEMU_MONITOR_MAX_RESPONSE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (VIR_REALLOC_N(mon->buffer,
|
VIR_REALLOC_N(mon->buffer, mon->bufferLength + 1024);
|
||||||
mon->bufferLength + 1024) < 0)
|
|
||||||
return -1;
|
|
||||||
mon->bufferLength += 1024;
|
mon->bufferLength += 1024;
|
||||||
avail += 1024;
|
avail += 1024;
|
||||||
}
|
}
|
||||||
|
@ -659,12 +659,8 @@ qemuMonitorJSONParseKeywords(const char *str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (keywordAlloc == keywordCount) {
|
if (keywordAlloc == keywordCount) {
|
||||||
if (VIR_REALLOC_N(keywords, keywordAlloc + 10) < 0 ||
|
VIR_REALLOC_N(keywords, keywordAlloc + 10);
|
||||||
VIR_REALLOC_N(values, keywordAlloc + 10) < 0) {
|
VIR_REALLOC_N(values, keywordAlloc + 10);
|
||||||
VIR_FREE(keyword);
|
|
||||||
VIR_FREE(value);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
keywordAlloc += 10;
|
keywordAlloc += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,10 +675,6 @@ qemuMonitorJSONParseKeywords(const char *str,
|
|||||||
*retvalues = values;
|
*retvalues = values;
|
||||||
*retnkeywords = keywordCount;
|
*retnkeywords = keywordCount;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
qemuMonitorJSONParseKeywordsFree(keywordCount, keywords, values);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1073,7 +1073,6 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC_UNUSED,
|
|||||||
virDomainEventGraphicsAddressPtr localAddr = NULL;
|
virDomainEventGraphicsAddressPtr localAddr = NULL;
|
||||||
virDomainEventGraphicsAddressPtr remoteAddr = NULL;
|
virDomainEventGraphicsAddressPtr remoteAddr = NULL;
|
||||||
virDomainEventGraphicsSubjectPtr subject = NULL;
|
virDomainEventGraphicsSubjectPtr subject = NULL;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
localAddr = g_new0(virDomainEventGraphicsAddress, 1);
|
localAddr = g_new0(virDomainEventGraphicsAddress, 1);
|
||||||
localAddr->family = localFamily;
|
localAddr->family = localFamily;
|
||||||
@ -1087,15 +1086,13 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC_UNUSED,
|
|||||||
|
|
||||||
subject = g_new0(virDomainEventGraphicsSubject, 1);
|
subject = g_new0(virDomainEventGraphicsSubject, 1);
|
||||||
if (x509dname) {
|
if (x509dname) {
|
||||||
if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0)
|
VIR_REALLOC_N(subject->identities, subject->nidentity+1);
|
||||||
goto error;
|
|
||||||
subject->nidentity++;
|
subject->nidentity++;
|
||||||
subject->identities[subject->nidentity - 1].type = g_strdup("x509dname");
|
subject->identities[subject->nidentity - 1].type = g_strdup("x509dname");
|
||||||
subject->identities[subject->nidentity - 1].name = g_strdup(x509dname);
|
subject->identities[subject->nidentity - 1].name = g_strdup(x509dname);
|
||||||
}
|
}
|
||||||
if (saslUsername) {
|
if (saslUsername) {
|
||||||
if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0)
|
VIR_REALLOC_N(subject->identities, subject->nidentity+1);
|
||||||
goto error;
|
|
||||||
subject->nidentity++;
|
subject->nidentity++;
|
||||||
subject->identities[subject->nidentity - 1].type = g_strdup("saslUsername");
|
subject->identities[subject->nidentity - 1].type = g_strdup("saslUsername");
|
||||||
subject->identities[subject->nidentity - 1].name = 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);
|
virObjectEventStateQueue(driver->domainEventState, event);
|
||||||
|
|
||||||
return 0;
|
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
|
static int
|
||||||
|
@ -1154,8 +1154,7 @@ virNetClientCallDispatchReply(virNetClientPtr client)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(thecall->msg->buffer, client->msg.bufferLength) < 0)
|
VIR_REALLOC_N(thecall->msg->buffer, client->msg.bufferLength);
|
||||||
return -1;
|
|
||||||
|
|
||||||
memcpy(thecall->msg->buffer, client->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));
|
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
|
/* Extend our declared buffer length and carry
|
||||||
on reading the header + payload */
|
on reading the header + payload */
|
||||||
msg->bufferLength += len;
|
msg->bufferLength += len;
|
||||||
if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
|
VIR_REALLOC_N(msg->buffer, msg->bufferLength);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
VIR_DEBUG("Got length, now need %zu total (%u more)",
|
VIR_DEBUG("Got length, now need %zu total (%u more)",
|
||||||
msg->bufferLength, len);
|
msg->bufferLength, len);
|
||||||
@ -229,8 +228,7 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg)
|
|||||||
unsigned int len = 0;
|
unsigned int len = 0;
|
||||||
|
|
||||||
msg->bufferLength = VIR_NET_MESSAGE_INITIAL + VIR_NET_MESSAGE_LEN_MAX;
|
msg->bufferLength = VIR_NET_MESSAGE_INITIAL + VIR_NET_MESSAGE_LEN_MAX;
|
||||||
if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
|
VIR_REALLOC_N(msg->buffer, msg->bufferLength);
|
||||||
return ret;
|
|
||||||
msg->bufferOffset = 0;
|
msg->bufferOffset = 0;
|
||||||
|
|
||||||
/* Format the header. */
|
/* Format the header. */
|
||||||
@ -370,8 +368,7 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
|
|||||||
|
|
||||||
msg->bufferLength = newlen + VIR_NET_MESSAGE_LEN_MAX;
|
msg->bufferLength = newlen + VIR_NET_MESSAGE_LEN_MAX;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
|
VIR_REALLOC_N(msg->buffer, msg->bufferLength);
|
||||||
goto error;
|
|
||||||
|
|
||||||
xdrmem_create(&xdr, msg->buffer + msg->bufferOffset,
|
xdrmem_create(&xdr, msg->buffer + msg->bufferOffset,
|
||||||
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
|
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
|
||||||
@ -454,8 +451,7 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
|
|||||||
|
|
||||||
msg->bufferLength = msg->bufferOffset + len;
|
msg->bufferLength = msg->bufferOffset + len;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
|
VIR_REALLOC_N(msg->buffer, msg->bufferLength);
|
||||||
return -1;
|
|
||||||
|
|
||||||
VIR_DEBUG("Increased message buffer length = %zu", msg->bufferLength);
|
VIR_DEBUG("Increased message buffer length = %zu", msg->bufferLength);
|
||||||
}
|
}
|
||||||
|
@ -235,9 +235,7 @@ virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPtr pool,
|
|||||||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||||
virStoragePoolSourceDevicePtr dev = &def->source.devices[0];
|
virStoragePoolSourceDevicePtr dev = &def->source.devices[0];
|
||||||
|
|
||||||
if (VIR_REALLOC_N(dev->freeExtents,
|
VIR_REALLOC_N(dev->freeExtents, dev->nfreeExtent + 1);
|
||||||
dev->nfreeExtent + 1) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
memset(dev->freeExtents +
|
memset(dev->freeExtents +
|
||||||
dev->nfreeExtent, 0,
|
dev->nfreeExtent, 0,
|
||||||
|
@ -447,8 +447,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(char **const groups,
|
|||||||
thisSource->name = g_steal_pointer(&vgname);
|
thisSource->name = g_steal_pointer(&vgname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0)
|
VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
dev = &thisSource->devices[thisSource->ndevice];
|
dev = &thisSource->devices[thisSource->ndevice];
|
||||||
thisSource->ndevice++;
|
thisSource->ndevice++;
|
||||||
|
@ -583,8 +583,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (VIR_REALLOC_N(images, nimages) < 0)
|
VIR_REALLOC_N(images, nimages);
|
||||||
goto error;
|
|
||||||
|
|
||||||
rc = rbd_list2(ptr->ioctx, images, &nimages);
|
rc = rbd_list2(ptr->ioctx, images, &nimages);
|
||||||
if (rc >= 0)
|
if (rc >= 0)
|
||||||
|
@ -114,9 +114,8 @@ virArpTableGet(void)
|
|||||||
if (tb[NDA_DST]) {
|
if (tb[NDA_DST]) {
|
||||||
g_autofree char *ipstr = NULL;
|
g_autofree char *ipstr = NULL;
|
||||||
virSocketAddr virAddr;
|
virSocketAddr virAddr;
|
||||||
if (VIR_REALLOC_N(table->t, num + 1) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
|
VIR_REALLOC_N(table->t, num + 1);
|
||||||
table->n = num + 1;
|
table->n = num + 1;
|
||||||
|
|
||||||
addr = RTA_DATA(tb[NDA_DST]);
|
addr = RTA_DATA(tb[NDA_DST]);
|
||||||
|
@ -1742,7 +1742,7 @@ virCommandSetSendBuffer(virCommandPtr cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
i = virCommandGetNumSendBuffers(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].fd = pipefd[1];
|
||||||
cmd->sendBuffers[i].buffer = g_steal_pointer(&localbuf);
|
cmd->sendBuffers[i].buffer = g_steal_pointer(&localbuf);
|
||||||
@ -2250,8 +2250,7 @@ virCommandProcessIO(virCommandPtr cmd)
|
|||||||
else
|
else
|
||||||
errfd = -1;
|
errfd = -1;
|
||||||
} else {
|
} else {
|
||||||
if (VIR_REALLOC_N(*buf, *len + done + 1) < 0)
|
VIR_REALLOC_N(*buf, *len + done + 1);
|
||||||
goto cleanup;
|
|
||||||
memcpy(*buf + *len, data, done);
|
memcpy(*buf + *len, data, done);
|
||||||
*len += done;
|
*len += done;
|
||||||
}
|
}
|
||||||
|
@ -105,8 +105,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
if (VIR_REALLOC_N(addnhostsfile->hosts, addnhostsfile->nhosts + 1) < 0)
|
VIR_REALLOC_N(addnhostsfile->hosts, addnhostsfile->nhosts + 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
idx = addnhostsfile->nhosts;
|
idx = addnhostsfile->nhosts;
|
||||||
addnhostsfile->hosts[idx].hostnames = g_new0(char *, 1);
|
addnhostsfile->hosts[idx].hostnames = g_new0(char *, 1);
|
||||||
@ -117,8 +116,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile,
|
|||||||
addnhostsfile->nhosts++;
|
addnhostsfile->nhosts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(addnhostsfile->hosts[idx].hostnames, addnhostsfile->hosts[idx].nhostnames + 1) < 0)
|
VIR_REALLOC_N(addnhostsfile->hosts[idx].hostnames, addnhostsfile->hosts[idx].nhostnames + 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
addnhostsfile->hosts[idx].hostnames[addnhostsfile->hosts[idx].nhostnames] = g_strdup(name);
|
addnhostsfile->hosts[idx].hostnames[addnhostsfile->hosts[idx].nhostnames] = g_strdup(name);
|
||||||
|
|
||||||
@ -127,10 +125,6 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile,
|
|||||||
addnhostsfile->hosts[idx].nhostnames++;
|
addnhostsfile->hosts[idx].nhostnames++;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
VIR_FREE(ipstr);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static dnsmasqAddnHostsfile *
|
static dnsmasqAddnHostsfile *
|
||||||
@ -297,8 +291,7 @@ hostsfileAdd(dnsmasqHostsfile *hostsfile,
|
|||||||
g_autofree char *ipstr = NULL;
|
g_autofree char *ipstr = NULL;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(hostsfile->hosts, hostsfile->nhosts + 1) < 0)
|
VIR_REALLOC_N(hostsfile->hosts, hostsfile->nhosts + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!(ipstr = virSocketAddrFormat(ip)))
|
if (!(ipstr = virSocketAddrFormat(ip)))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1346,10 +1346,7 @@ saferead_lim(int fd, size_t max_len, size_t *length)
|
|||||||
if (alloc < size + BUFSIZ + 1)
|
if (alloc < size + BUFSIZ + 1)
|
||||||
alloc = size + BUFSIZ + 1;
|
alloc = size + BUFSIZ + 1;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(buf, alloc) < 0) {
|
VIR_REALLOC_N(buf, alloc);
|
||||||
save_errno = errno;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure that (size + requested <= max_len); */
|
/* Ensure that (size + requested <= max_len); */
|
||||||
|
@ -779,9 +779,7 @@ virJSONValueArrayAppend(virJSONValuePtr array,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(array->data.array.values,
|
VIR_REALLOC_N(array->data.array.values, array->data.array.nvalues + 1);
|
||||||
array->data.array.nvalues + 1) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
array->data.array.values[array->data.array.nvalues] = g_steal_pointer(value);
|
array->data.array.values[array->data.array.nvalues] = g_steal_pointer(value);
|
||||||
array->data.array.nvalues++;
|
array->data.array.nvalues++;
|
||||||
@ -1697,10 +1695,7 @@ virJSONParserHandleStartMap(void *ctx)
|
|||||||
if (virJSONParserInsertValue(parser, &value) < 0)
|
if (virJSONParserInsertValue(parser, &value) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(parser->state,
|
VIR_REALLOC_N(parser->state, parser->nstate + 1);
|
||||||
parser->nstate + 1) < 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
parser->state[parser->nstate].value = tmp;
|
parser->state[parser->nstate].value = tmp;
|
||||||
parser->state[parser->nstate].key = NULL;
|
parser->state[parser->nstate].key = NULL;
|
||||||
@ -1745,9 +1740,7 @@ virJSONParserHandleStartArray(void *ctx)
|
|||||||
if (virJSONParserInsertValue(parser, &value) < 0)
|
if (virJSONParserInsertValue(parser, &value) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(parser->state,
|
VIR_REALLOC_N(parser->state, parser->nstate + 1);
|
||||||
parser->nstate + 1) < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
parser->state[parser->nstate].value = tmp;
|
parser->state[parser->nstate].value = tmp;
|
||||||
parser->state[parser->nstate].key = NULL;
|
parser->state[parser->nstate].key = NULL;
|
||||||
|
@ -795,10 +795,9 @@ virNumaGetPages(int node,
|
|||||||
&page_avail, &page_free) < 0)
|
&page_avail, &page_free) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(tmp_size, ntmp + 1) < 0 ||
|
VIR_REALLOC_N(tmp_size, ntmp + 1);
|
||||||
VIR_REALLOC_N(tmp_avail, ntmp + 1) < 0 ||
|
VIR_REALLOC_N(tmp_avail, ntmp + 1);
|
||||||
VIR_REALLOC_N(tmp_free, ntmp + 1) < 0)
|
VIR_REALLOC_N(tmp_free, ntmp + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
tmp_size[ntmp] = page_size;
|
tmp_size[ntmp] = page_size;
|
||||||
tmp_avail[ntmp] = page_avail;
|
tmp_avail[ntmp] = page_avail;
|
||||||
@ -814,10 +813,9 @@ virNumaGetPages(int node,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Now append the ordinary system pages */
|
/* Now append the ordinary system pages */
|
||||||
if (VIR_REALLOC_N(tmp_size, ntmp + 1) < 0 ||
|
VIR_REALLOC_N(tmp_size, ntmp + 1);
|
||||||
VIR_REALLOC_N(tmp_avail, ntmp + 1) < 0 ||
|
VIR_REALLOC_N(tmp_avail, ntmp + 1);
|
||||||
VIR_REALLOC_N(tmp_free, ntmp + 1) < 0)
|
VIR_REALLOC_N(tmp_free, ntmp + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (virNumaGetPageInfo(node, system_page_size, huge_page_sum,
|
if (virNumaGetPageInfo(node, system_page_size, huge_page_sum,
|
||||||
&tmp_avail[ntmp], &tmp_free[ntmp]) < 0)
|
&tmp_avail[ntmp], &tmp_free[ntmp]) < 0)
|
||||||
|
@ -78,8 +78,7 @@ virStringListMerge(char ***dst,
|
|||||||
dst_len = g_strv_length(*dst);
|
dst_len = g_strv_length(*dst);
|
||||||
src_len = g_strv_length(*src);
|
src_len = g_strv_length(*src);
|
||||||
|
|
||||||
if (VIR_REALLOC_N(*dst, dst_len + src_len + 1) < 0)
|
VIR_REALLOC_N(*dst, dst_len + src_len + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i <= src_len; i++)
|
for (i = 0; i <= src_len; i++)
|
||||||
(*dst)[i + dst_len] = (*src)[i];
|
(*dst)[i + dst_len] = (*src)[i];
|
||||||
|
@ -827,8 +827,7 @@ virSysinfoParseX86BaseBoard(const char *base,
|
|||||||
if (nboards == 0) {
|
if (nboards == 0) {
|
||||||
VIR_FREE(boards);
|
VIR_FREE(boards);
|
||||||
} else {
|
} else {
|
||||||
/* This is safe, as we can be only shrinking the memory */
|
VIR_REALLOC_N(boards, nboards);
|
||||||
ignore_value(VIR_REALLOC_N(boards, nboards));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*nbaseBoard = nboards;
|
*nbaseBoard = nboards;
|
||||||
|
@ -7560,9 +7560,7 @@ vboxConnectListAllDomains(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (doms) {
|
if (doms) {
|
||||||
/* safe to ignore, new size will be equal or less than
|
VIR_REALLOC_N(doms, count + 1);
|
||||||
* previous allocation */
|
|
||||||
ignore_value(VIR_REALLOC_N(doms, count + 1));
|
|
||||||
*domains = g_steal_pointer(&doms);
|
*domains = g_steal_pointer(&doms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,22 +30,18 @@
|
|||||||
static int G_GNUC_NULL_TERMINATED
|
static int G_GNUC_NULL_TERMINATED
|
||||||
fillStringValues(virDomainCapsStringValuesPtr values, ...)
|
fillStringValues(virDomainCapsStringValuesPtr values, ...)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
va_list list;
|
va_list list;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
va_start(list, values);
|
va_start(list, values);
|
||||||
while ((str = va_arg(list, const char *))) {
|
while ((str = va_arg(list, const char *))) {
|
||||||
if (VIR_REALLOC_N(values->values, values->nvalues + 1) < 0) {
|
VIR_REALLOC_N(values->values, values->nvalues + 1);
|
||||||
ret = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
values->values[values->nvalues] = g_strdup(str);
|
values->values[values->nvalues] = g_strdup(str);
|
||||||
values->nvalues++;
|
values->nvalues++;
|
||||||
}
|
}
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* WITH_QEMU || WITH_BHYVE */
|
#endif /* WITH_QEMU || WITH_BHYVE */
|
||||||
|
|
||||||
|
@ -316,8 +316,7 @@ testQemuDiskXMLToProps(const void *opaque)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(data->images, data->nimages + 1) < 0)
|
VIR_REALLOC_N(data->images, data->nimages + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
data->images[data->nimages].formatprops = g_steal_pointer(&formatProps);
|
data->images[data->nimages].formatprops = g_steal_pointer(&formatProps);
|
||||||
data->images[data->nimages].storageprops = g_steal_pointer(&storageProps);
|
data->images[data->nimages].storageprops = g_steal_pointer(&storageProps);
|
||||||
|
@ -60,8 +60,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED)
|
|||||||
t[i].b = 20;
|
t[i].b = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(t, nt + 5) < 0)
|
VIR_REALLOC_N(t, nt + 5);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (testCheckNonNull(t) < 0)
|
if (testCheckNonNull(t) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -74,8 +73,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(t, nt) < 0)
|
VIR_REALLOC_N(t, nt);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (testCheckNonNull(t) < 0)
|
if (testCheckNonNull(t) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -88,8 +86,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(t, nt - 5) < 0)
|
VIR_REALLOC_N(t, nt - 5);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (testCheckNonNull(t) < 0)
|
if (testCheckNonNull(t) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -167,11 +167,8 @@ virConsoleEventOnStream(virStreamPtr st,
|
|||||||
int got;
|
int got;
|
||||||
|
|
||||||
if (avail < 1024) {
|
if (avail < 1024) {
|
||||||
if (VIR_REALLOC_N(con->streamToTerminal.data,
|
VIR_REALLOC_N(con->streamToTerminal.data,
|
||||||
con->streamToTerminal.length + 1024) < 0) {
|
con->streamToTerminal.length + 1024);
|
||||||
virConsoleShutdown(con, false);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
con->streamToTerminal.length += 1024;
|
con->streamToTerminal.length += 1024;
|
||||||
avail += 1024;
|
avail += 1024;
|
||||||
}
|
}
|
||||||
@ -212,8 +209,8 @@ virConsoleEventOnStream(virStreamPtr st,
|
|||||||
|
|
||||||
avail = con->terminalToStream.length - con->terminalToStream.offset;
|
avail = con->terminalToStream.length - con->terminalToStream.offset;
|
||||||
if (avail > 1024) {
|
if (avail > 1024) {
|
||||||
ignore_value(VIR_REALLOC_N(con->terminalToStream.data,
|
VIR_REALLOC_N(con->terminalToStream.data,
|
||||||
con->terminalToStream.offset + 1024));
|
con->terminalToStream.offset + 1024);
|
||||||
con->terminalToStream.length = con->terminalToStream.offset + 1024;
|
con->terminalToStream.length = con->terminalToStream.offset + 1024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,11 +248,8 @@ virConsoleEventOnStdin(int watch G_GNUC_UNUSED,
|
|||||||
int got;
|
int got;
|
||||||
|
|
||||||
if (avail < 1024) {
|
if (avail < 1024) {
|
||||||
if (VIR_REALLOC_N(con->terminalToStream.data,
|
VIR_REALLOC_N(con->terminalToStream.data,
|
||||||
con->terminalToStream.length + 1024) < 0) {
|
con->terminalToStream.length + 1024);
|
||||||
virConsoleShutdown(con, false);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
con->terminalToStream.length += 1024;
|
con->terminalToStream.length += 1024;
|
||||||
avail += 1024;
|
avail += 1024;
|
||||||
}
|
}
|
||||||
@ -340,8 +334,8 @@ virConsoleEventOnStdout(int watch G_GNUC_UNUSED,
|
|||||||
|
|
||||||
avail = con->streamToTerminal.length - con->streamToTerminal.offset;
|
avail = con->streamToTerminal.length - con->streamToTerminal.offset;
|
||||||
if (avail > 1024) {
|
if (avail > 1024) {
|
||||||
ignore_value(VIR_REALLOC_N(con->streamToTerminal.data,
|
VIR_REALLOC_N(con->streamToTerminal.data,
|
||||||
con->streamToTerminal.offset + 1024));
|
con->streamToTerminal.offset + 1024);
|
||||||
con->streamToTerminal.length = con->streamToTerminal.offset + 1024;
|
con->streamToTerminal.length = con->streamToTerminal.offset + 1024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,8 +335,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmdstr) {
|
if (cmdstr) {
|
||||||
if (VIR_REALLOC_N(shargv, shargvlen + 3) < 0)
|
VIR_REALLOC_N(shargv, shargvlen + 3);
|
||||||
goto cleanup;
|
|
||||||
shargv[shargvlen++] = g_strdup("-c");
|
shargv[shargvlen++] = g_strdup("-c");
|
||||||
shargv[shargvlen++] = g_strdup(cmdstr);
|
shargv[shargvlen++] = g_strdup(cmdstr);
|
||||||
shargv[shargvlen] = NULL;
|
shargv[shargvlen] = NULL;
|
||||||
|
@ -2582,8 +2582,7 @@ vshReadlineCommandGenerator(void)
|
|||||||
if (cmds[cmd_list_index].flags & VSH_CMD_FLAG_ALIAS)
|
if (cmds[cmd_list_index].flags & VSH_CMD_FLAG_ALIAS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(ret, ret_size + 2) < 0)
|
VIR_REALLOC_N(ret, ret_size + 2);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret[ret_size] = g_strdup(name);
|
ret[ret_size] = g_strdup(name);
|
||||||
ret_size++;
|
ret_size++;
|
||||||
@ -2630,8 +2629,7 @@ vshReadlineOptionsGenerator(const vshCmdDef *cmd,
|
|||||||
if (exists)
|
if (exists)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(ret, ret_size + 2) < 0)
|
VIR_REALLOC_N(ret, ret_size + 2);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret[ret_size] = g_strdup_printf("--%s", name);
|
ret[ret_size] = g_strdup_printf("--%s", name);
|
||||||
ret_size++;
|
ret_size++;
|
||||||
|
Loading…
Reference in New Issue
Block a user