--- src/xen/block_stats.c | 8 ++------ src/xen/xen_driver.c | 42 +++++++++++------------------------------- src/xen/xen_hypervisor.c | 18 ++++++------------ src/xen/xen_inotify.c | 4 +--- src/xen/xend_internal.c | 38 ++++++++++---------------------------- src/xen/xm_internal.c | 24 ++++++------------------ src/xen/xs_internal.c | 24 ++++++------------------ 7 files changed, 42 insertions(+), 116 deletions(-) diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c index ebb91ea..5824518 100644 --- a/src/xen/block_stats.c +++ b/src/xen/block_stats.c @@ -114,10 +114,8 @@ read_bd_stat(int device, int domid, const char *str) int64_t r; for (i = 0; i < ARRAY_CARDINALITY(paths); ++i) { - if (virAsprintf(&path, paths[i], domid, device, str) < 0) { - virReportOOMError(); + if (virAsprintf(&path, paths[i], domid, device, str) < 0) return -1; - } r = read_stat(path); @@ -296,10 +294,8 @@ xenLinuxDomainDeviceID(int domid, const char *path) if (VIR_STRDUP(mod_path, path) < 0) return -1; } else { - if (virAsprintf(&mod_path, "/dev/%s", path) < 0) { - virReportOOMError(); + if (virAsprintf(&mod_path, "/dev/%s", path) < 0) return -1; - } } retval = -1; diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index f69feb5..19ad755 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -208,20 +208,14 @@ xenDomainUsedCpus(virDomainPtr dom) if (xenUnifiedNodeGetInfo(dom->conn, &nodeinfo) < 0) return NULL; - if (!(cpulist = virBitmapNew(priv->nbNodeCpus))) { - virReportOOMError(); + if (!(cpulist = virBitmapNew(priv->nbNodeCpus))) goto done; - } - if (VIR_ALLOC_N(cpuinfo, nb_vcpu) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(cpuinfo, nb_vcpu) < 0) goto done; - } cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo)); if (xalloc_oversized(nb_vcpu, cpumaplen) || - VIR_ALLOC_N(cpumap, nb_vcpu * cpumaplen) < 0) { - virReportOOMError(); + VIR_ALLOC_N(cpumap, nb_vcpu * cpumaplen) < 0) goto done; - } if ((ncpus = xenUnifiedDomainGetVcpus(dom, cpuinfo, nb_vcpu, cpumap, cpumaplen)) >= 0) { @@ -415,10 +409,8 @@ xenUnifiedConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int f return VIR_DRV_OPEN_ERROR; /* Allocate per-connection private data. */ - if (VIR_ALLOC(priv) < 0) { - virReportOOMError(); + if (VIR_ALLOC(priv) < 0) return VIR_DRV_OPEN_ERROR; - } if (virMutexInit(&priv->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot initialize mutex")); @@ -856,10 +848,8 @@ xenUnifiedDomainIsPersistent(virDomainPtr dom) /* If its running there's no official way to tell, so we * go behind xend's back & look at the config dir */ virUUIDFormat(dom->uuid, uuidstr); - if (virAsprintf(&path, "%s/%s", XEND_DOMAINS_DIR, uuidstr) < 0) { - virReportOOMError(); + if (virAsprintf(&path, "%s/%s", XEND_DOMAINS_DIR, uuidstr) < 0) goto cleanup; - } if (access(path, R_OK) == 0) ret = 1; else if (errno == ENOENT) @@ -1202,10 +1192,8 @@ xenUnifiedDomainManagedSavePath(xenUnifiedPrivatePtr priv, { char *ret; - if (virAsprintf(&ret, "%s/%s.save", priv->saveDir, def->name) < 0) { - virReportOOMError(); + if (virAsprintf(&ret, "%s/%s.save", priv->saveDir, def->name) < 0) return NULL; - } VIR_DEBUG("managed save image: %s", ret); return ret; @@ -1617,10 +1605,8 @@ xenUnifiedConnectDomainXMLToNative(virConnectPtr conn, if (!conf) goto cleanup; - if (VIR_ALLOC_N(ret, len) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(ret, len) < 0) goto cleanup; - } if (virConfWriteMem(ret, &len, conf) < 0) { VIR_FREE(ret); @@ -2473,10 +2459,8 @@ xenUnifiedNodeDeviceAssignedDomainId(virNodeDevicePtr dev) return ret; } if (numdomains > 0){ - if (VIR_ALLOC_N(ids, numdomains) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(ids, numdomains) < 0) goto out; - } if ((numdomains = xenUnifiedConnectListDomains(conn, &ids[0], numdomains)) < 0) { goto out; } @@ -2487,10 +2471,8 @@ xenUnifiedNodeDeviceAssignedDomainId(virNodeDevicePtr dev) goto out; if (virAsprintf(&bdf, "%04x:%02x:%02x.%0x", - domain, bus, slot, function) < 0) { - virReportOOMError(); + domain, bus, slot, function) < 0) goto out; - } xenUnifiedLock(priv); /* Check if bdf is assigned to one of active domains */ @@ -2824,7 +2806,7 @@ xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr list, } if (VIR_ALLOC(info) < 0) - goto memory_error; + goto error; if (VIR_STRDUP(info->name, name) < 0) goto error; @@ -2834,14 +2816,12 @@ xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr list, /* Make space on list */ n = list->count; if (VIR_REALLOC_N(list->doms, n + 1) < 0) { - goto memory_error; + goto error; } list->doms[n] = info; list->count++; return 0; -memory_error: - virReportOOMError(); error: if (info) VIR_FREE(info->name); diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 9d9c3ee..79694f7 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -1509,10 +1509,8 @@ virXen_setvcpumap(int handle, /* The allocated memory to cpumap must be 'sizeof(uint64_t)' byte * * for Xen, and also nr_cpus must be 'sizeof(uint64_t) * 8' */ if (maplen < 8) { - if (VIR_ALLOC_N(new, sizeof(uint64_t)) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(new, sizeof(uint64_t)) < 0) return -1; - } memcpy(new, cpumap, maplen); bitmap = new; nr_cpus = sizeof(uint64_t) * 8; @@ -1829,10 +1827,8 @@ xenHypervisorInit(struct xenHypervisorVersions *override_versions) */ hv_versions.hypervisor = 2; - if (VIR_ALLOC(ipt) < 0) { - virReportOOMError(); + if (VIR_ALLOC(ipt) < 0) return -1; - } /* Currently consider RHEL5.0 Fedora7, xen-3.1, and xen-unstable */ hv_versions.sys_interface = 2; /* XEN_SYSCTL_INTERFACE_VERSION */ if (virXen_getdomaininfo(fd, 0, &info) == 1) { @@ -2265,11 +2261,10 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn) } } - if ((caps = xenHypervisorBuildCapabilities(conn, - virArchFromHost(), - pae, hvm, - guest_arches, i)) == NULL) - virReportOOMError(); + caps = xenHypervisorBuildCapabilities(conn, + virArchFromHost(), + pae, hvm, + guest_arches, i); return caps; } @@ -2428,7 +2423,6 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn, return caps; no_memory: - virReportOOMError(); virObjectUnref(caps); return NULL; } diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c index 8266576..04ac083 100644 --- a/src/xen/xen_inotify.c +++ b/src/xen/xen_inotify.c @@ -360,10 +360,8 @@ xenInotifyOpen(virConnectPtr conn, priv->configDir = XEND_DOMAINS_DIR; priv->useXenConfigCache = 0; - if (VIR_ALLOC(priv->configInfoList) < 0) { - virReportOOMError(); + if (VIR_ALLOC(priv->configInfoList) < 0) return -1; - } /* populate initial list */ if (!(dh = opendir(priv->configDir))) { diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 3c05dff..70718ff 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -283,10 +283,8 @@ xend_req(int fd, char **content) int content_length = 0; int retcode = 0; - if (VIR_ALLOC_N(buffer, buffer_size) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(buffer, buffer_size) < 0) return -1; - } while (sreads(fd, buffer, buffer_size) > 0) { if (STREQ(buffer, "\r\n")) @@ -315,10 +313,8 @@ xend_req(int fd, char **content) /* Allocate one byte beyond the end of the largest buffer we will read. Combined with the fact that VIR_ALLOC_N zeros the returned buffer, this guarantees that "content" will always be NUL-terminated. */ - if (VIR_ALLOC_N(*content, content_length + 1) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(*content, content_length + 1) < 0) return -1; - } ret = sread(fd, *content, content_length); if (ret < 0) @@ -762,10 +758,8 @@ xenDaemonListDomainsOld(virConnectPtr xend) count++; } - if (VIR_ALLOC_N(ret, count + 1) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(ret, count + 1) < 0) goto error; - } i = 0; for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS; @@ -1073,7 +1067,7 @@ sexpr_to_xend_topology(const struct sexpr *root, virCapsPtr caps) if (STRPREFIX(cur, "no cpus")) { nb_cpus = 0; if (!(cpuset = virBitmapNew(numCpus))) - goto memory_error; + goto error; } else { nb_cpus = virBitmapParse(cur, 'n', &cpuset, numCpus); if (nb_cpus < 0) @@ -1082,7 +1076,7 @@ sexpr_to_xend_topology(const struct sexpr *root, virCapsPtr caps) if (VIR_ALLOC_N(cpuInfo, numCpus) < 0) { virBitmapFree(cpuset); - goto memory_error; + goto error; } for (n = 0, cpu = 0; cpu < numCpus; cpu++) { @@ -1095,7 +1089,7 @@ sexpr_to_xend_topology(const struct sexpr *root, virCapsPtr caps) virBitmapFree(cpuset); if (virCapabilitiesAddHostNUMACell(caps, cell, nb_cpus, 0, cpuInfo) < 0) - goto memory_error; + goto error; cpuInfo = NULL; } @@ -1107,10 +1101,6 @@ sexpr_to_xend_topology(const struct sexpr *root, virCapsPtr caps) virCapabilitiesClearHostNUMACellCPUTopology(cpuInfo, nb_cpus); VIR_FREE(cpuInfo); return -1; - - memory_error: - virReportOOMError(); - goto error; } @@ -1219,10 +1209,8 @@ xenDaemonOpen(virConnectPtr conn, goto failed; } else if (STRCASEEQ(conn->uri->scheme, "http")) { if (conn->uri->port && - virAsprintf(&port, "%d", conn->uri->port) == -1) { - virReportOOMError(); + virAsprintf(&port, "%d", conn->uri->port) == -1) goto failed; - } if (xenDaemonOpen_tcp(conn, conn->uri->server ? conn->uri->server : "localhost", @@ -1895,10 +1883,8 @@ xenDaemonDomainPinVcpu(virConnectPtr conn, if (ret == 0) { if (!def->cputune.vcpupin) { - if (VIR_ALLOC(def->cputune.vcpupin) < 0) { - virReportOOMError(); + if (VIR_ALLOC(def->cputune.vcpupin) < 0) goto cleanup; - } def->cputune.nvcpupin = 0; } if (virDomainVcpuPinAdd(&def->cputune.vcpupin, @@ -2302,10 +2288,8 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn, PCIAddr = dev->data.hostdev->source.subsys.u.pci.addr; if (virAsprintf(&target, "PCI device: %.4x:%.2x:%.2x", - PCIAddr.domain, PCIAddr.bus, PCIAddr.slot) < 0) { - virReportOOMError(); + PCIAddr.domain, PCIAddr.bus, PCIAddr.slot) < 0) goto cleanup; - } } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported device type")); @@ -3393,10 +3377,8 @@ virDomainXMLDevID(virConnectPtr conn, hostdef->source.subsys.u.pci.addr.domain, hostdef->source.subsys.u.pci.addr.bus, hostdef->source.subsys.u.pci.addr.slot, - hostdef->source.subsys.u.pci.addr.function) < 0) { - virReportOOMError(); + hostdef->source.subsys.u.pci.addr.function) < 0) return -1; - } strcpy(class, "pci"); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 7c05911..096f24f 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -237,10 +237,8 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename) entry->def = NULL; } else { /* Completely new entry */ newborn = 1; - if (VIR_ALLOC(entry) < 0) { - virReportOOMError(); + if (VIR_ALLOC(entry) < 0) return -1; - } if (VIR_STRDUP(entry->filename, filename) < 0) { VIR_FREE(entry); return -1; @@ -1030,10 +1028,8 @@ xenXMDomainDefineXML(virConnectPtr conn, virDomainDefPtr def) if (virConfWriteFile(filename, conf) < 0) goto error; - if (VIR_ALLOC(entry) < 0) { - virReportOOMError(); + if (VIR_ALLOC(entry) < 0) goto error; - } if ((entry->refreshedAt = time(NULL)) == ((time_t)-1)) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1257,20 +1253,16 @@ xenXMDomainAttachDeviceFlags(virConnectPtr conn, switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: { - if (virDomainDiskInsert(def, dev->data.disk) < 0) { - virReportOOMError(); + if (virDomainDiskInsert(def, dev->data.disk) < 0) goto cleanup; - } dev->data.disk = NULL; } break; case VIR_DOMAIN_DEVICE_NET: { - if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0) { - virReportOOMError(); + if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0) goto cleanup; - } def->nets[def->nnets++] = dev->data.net; dev->data.net = NULL; break; @@ -1444,10 +1436,8 @@ xenXMDomainGetAutostart(virDomainDefPtr def, char *config = xenXMDomainConfigName(def); int ret = -1; - if (!linkname || !config) { - virReportOOMError(); + if (!linkname || !config) goto cleanup; - } *autostart = virFileLinkPointsTo(linkname, config); if (*autostart < 0) { @@ -1474,10 +1464,8 @@ xenXMDomainSetAutostart(virDomainDefPtr def, char *config = xenXMDomainConfigName(def); int ret = -1; - if (!linkname || !config) { - virReportOOMError(); + if (!linkname || !config) goto cleanup; - } if (autostart) { if (symlink(config, linkname) < 0 && diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c index cc55fde..e579453 100644 --- a/src/xen/xs_internal.c +++ b/src/xen/xs_internal.c @@ -132,18 +132,14 @@ xenStoreOpen(virConnectPtr conn, } /* Init activeDomainList */ - if (VIR_ALLOC(priv->activeDomainList) < 0) { - virReportOOMError(); + if (VIR_ALLOC(priv->activeDomainList) < 0) return -1; - } /* Init watch list before filling in domInfoList, so we can know if it is the first time through when the callback fires */ - if (VIR_ALLOC(priv->xsWatchList) < 0) { - virReportOOMError(); + if (VIR_ALLOC(priv->xsWatchList) < 0) return -1; - } /* This will get called once at start */ if (xenStoreAddWatch(conn, "@releaseDomain", @@ -656,10 +652,8 @@ xenStoreAddWatch(virConnectPtr conn, } } - if (VIR_ALLOC(watch) < 0) { - virReportOOMError(); + if (VIR_ALLOC(watch) < 0) goto error; - } watch->cb = cb; watch->opaque = opaque; @@ -669,10 +663,8 @@ xenStoreAddWatch(virConnectPtr conn, /* Make space on list */ n = list->count; - if (VIR_REALLOC_N(list->watches, n + 1) < 0) { - virReportOOMError(); + if (VIR_REALLOC_N(list->watches, n + 1) < 0) goto error; - } list->watches[n] = watch; list->count++; @@ -817,10 +809,8 @@ retry: if (new_domain_cnt < 0) return -1; - if (VIR_ALLOC_N(new_domids,new_domain_cnt) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(new_domids,new_domain_cnt) < 0) return -1; - } nread = xenStoreDoListDomains(conn, priv, new_domids, new_domain_cnt); if (nread != new_domain_cnt) { /* mismatch. retry this read */ @@ -901,10 +891,8 @@ retry: if (new_domain_cnt < 0) return -1; - if (VIR_ALLOC_N(new_domids,new_domain_cnt) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(new_domids,new_domain_cnt) < 0) return -1; - } nread = xenStoreDoListDomains(conn, priv, new_domids, new_domain_cnt); if (nread != new_domain_cnt) { /* mismatch. retry this read */ -- 1.8.1.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list