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