--- src/storage/storage_backend.c | 35 ++++++------------------- src/storage/storage_backend_disk.c | 17 +++--------- src/storage/storage_backend_fs.c | 31 ++++++---------------- src/storage/storage_backend_iscsi.c | 27 +++++-------------- src/storage/storage_backend_logical.c | 48 +++++++++------------------------- src/storage/storage_backend_mpath.c | 20 ++++---------- src/storage/storage_backend_rbd.c | 18 ++++--------- src/storage/storage_backend_scsi.c | 21 +++------------ src/storage/storage_backend_sheepdog.c | 4 +-- src/storage/storage_driver.c | 23 +++++----------- 10 files changed, 60 insertions(+), 184 deletions(-) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 9a3bcf8..e2527c9 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -161,13 +161,11 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, if (VIR_ALLOC_N(zerobuf, wbytes) < 0) { ret = -errno; - virReportOOMError(); goto cleanup; } if (VIR_ALLOC_N(buf, rbytes) < 0) { ret = -errno; - virReportOOMError(); goto cleanup; } @@ -466,10 +464,8 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, } if (VIR_ALLOC(enc_secret) < 0 || VIR_REALLOC_N(enc->secrets, 1) < 0 || - VIR_ALLOC(def) < 0) { - virReportOOMError(); + VIR_ALLOC(def) < 0) goto cleanup; - } def->ephemeral = false; def->private = false; @@ -798,10 +794,8 @@ virStorageBackendCreateQemuImgCmd(virConnectPtr conn, */ if ('/' != *(vol->backingStore.path) && virAsprintf(&absolutePath, "%s/%s", pool->def->target.path, - vol->backingStore.path) < 0) { - virReportOOMError(); + vol->backingStore.path) < 0) return NULL; - } accessRetCode = access(absolutePath ? absolutePath : vol->backingStore.path, R_OK); VIR_FREE(absolutePath); @@ -986,10 +980,8 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn ATTRIBUTE_UNUSED, /* Size in MB - yes different units to qemu-img :-( */ if (virAsprintf(&size, "%llu", - VIR_DIV_UP(vol->capacity, (1024 * 1024))) < 0) { - virReportOOMError(); + VIR_DIV_UP(vol->capacity, (1024 * 1024))) < 0) return -1; - } cmd = virCommandNewArgList("qcow-create", size, vol->target.path, NULL); @@ -1298,10 +1290,8 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target, target->perms.uid = sb.st_uid; target->perms.gid = sb.st_gid; - if (!target->timestamps && VIR_ALLOC(target->timestamps) < 0) { - virReportOOMError(); + if (!target->timestamps && VIR_ALLOC(target->timestamps) < 0) return -1; - } target->timestamps->atime = get_stat_atime(&sb); target->timestamps->btime = get_stat_birthtime(&sb); target->timestamps->ctime = get_stat_ctime(&sb); @@ -1485,7 +1475,6 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, if (virAsprintf(&stablepath, "%s/%s", pool->def->target.path, dent->d_name) == -1) { - virReportOOMError(); closedir(dh); return NULL; } @@ -1543,10 +1532,8 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool, char **groups; /* Compile all regular expressions */ - if (VIR_ALLOC_N(reg, nregex) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(reg, nregex) < 0) return -1; - } for (i = 0; i < nregex; i++) { err = regcomp(®[i], regex[i], REG_EXTENDED); @@ -1568,14 +1555,10 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool, } /* Storage for matched variables */ - if (VIR_ALLOC_N(groups, totgroups) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(groups, totgroups) < 0) goto cleanup; - } - if (VIR_ALLOC_N(vars, maxvars+1) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(vars, maxvars+1) < 0) goto cleanup; - } virCommandSetOutputFD(cmd, &fd); if (virCommandRunAsync(cmd, NULL) < 0) { @@ -1679,10 +1662,8 @@ virStorageBackendRunProgNul(virStoragePoolObjPtr pool, if (n_columns == 0) return -1; - if (VIR_ALLOC_N(v, n_columns) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(v, n_columns) < 0) return -1; - } for (i = 0; i < n_columns; i++) v[i] = NULL; diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index d0b91f9..6ebcf48 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -50,14 +50,11 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool, char *tmp, *devpath; if (vol == NULL) { - if (VIR_ALLOC(vol) < 0) { - virReportOOMError(); + if (VIR_ALLOC(vol) < 0) return -1; - } if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count+1) < 0) { - virReportOOMError(); virStorageVolDefFree(vol); return -1; } @@ -94,10 +91,8 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool, } if (vol->source.extents == NULL) { - if (VIR_ALLOC(vol->source.extents) < 0) { - virReportOOMError(); + if (VIR_ALLOC(vol->source.extents) < 0) return -1; - } vol->source.nextent = 1; if (virStrToLong_ull(groups[3], NULL, 10, @@ -487,10 +482,8 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr pool, /* XXX Only support one extended partition */ switch (virStorageBackendDiskPartTypeToCreate(pool)) { case VIR_STORAGE_VOL_DISK_TYPE_PRIMARY: - if (virAsprintf(partFormat, "primary %s", partedFormat) < 0) { - virReportOOMError(); + if (virAsprintf(partFormat, "primary %s", partedFormat) < 0) return -1; - } break; case VIR_STORAGE_VOL_DISK_TYPE_LOGICAL: /* make sure we have a extended partition */ @@ -498,10 +491,8 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr pool, if (pool->volumes.objs[i]->target.format == VIR_STORAGE_VOL_DISK_EXTENDED) { if (virAsprintf(partFormat, "logical %s", - partedFormat) < 0) { - virReportOOMError(); + partedFormat) < 0) return -1; - } break; } } diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 3598d83..9802d15 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -129,10 +129,8 @@ virStorageBackendProbeTarget(virStorageVolTargetPtr target, *capacity = meta->capacity; if (encryption != NULL && meta->encrypted) { - if (VIR_ALLOC(*encryption) < 0) { - virReportOOMError(); + if (VIR_ALLOC(*encryption) < 0) goto cleanup; - } switch (target->format) { case VIR_STORAGE_FILE_QCOW: @@ -211,10 +209,8 @@ virStorageBackendFileSystemNetFindPoolSourcesFunc(virStoragePoolObjPtr pool ATTR if (!(src = virStoragePoolSourceListNewSource(&state->list))) goto cleanup; - if (VIR_ALLOC_N(src->hosts, 1) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(src->hosts, 1) < 0) goto cleanup; - } src->nhost = 1; if (VIR_STRDUP(src->hosts[0].name, state->host) < 0 || @@ -292,10 +288,8 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE goto cleanup; retval = virStoragePoolSourceListFormat(&state.list); - if (retval == NULL) { - virReportOOMError(); + if (retval == NULL) goto cleanup; - } cleanup: for (i = 0; i < state.list.nsources; i++) @@ -397,10 +391,8 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) { if (pool->def->type == VIR_STORAGE_POOL_NETFS) { if (virAsprintf(&src, "%s:%s", pool->def->source.hosts[0].name, - pool->def->source.dir) == -1) { - virReportOOMError(); + pool->def->source.dir) == -1) return -1; - } } else { if (VIR_STRDUP(src, pool->def->source.devices[0].path) < 0) @@ -833,7 +825,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, int backingStoreFormat; if (VIR_ALLOC(vol) < 0) - goto no_memory; + goto cleanup; if (VIR_STRDUP(vol->name, ent->d_name) < 0) goto cleanup; @@ -843,7 +835,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, vol->name) == -1) - goto no_memory; + goto cleanup; if (VIR_STRDUP(vol->key, vol->target.path) < 0) goto cleanup; @@ -897,7 +889,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count+1) < 0) - goto no_memory; + goto cleanup; pool->volumes.objs[pool->volumes.count++] = vol; vol = NULL; } @@ -918,10 +910,6 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, return 0; -no_memory: - virReportOOMError(); - /* fallthrough */ - cleanup: if (dir) closedir(dir); @@ -1000,10 +988,8 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn ATTRIBUTE_UNUSED, VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, - vol->name) == -1) { - virReportOOMError(); + vol->name) == -1) return -1; - } if (virFileExists(vol->target.path)) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -1194,7 +1180,6 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn, if (VIR_ALLOC_N(vol->target.encryption->secrets, 1) < 0 || VIR_ALLOC(encsec) < 0) { VIR_FREE(vol->target.encryption->secrets); - virReportOOMError(); virSecretFree(sec); return -1; } diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 0a4cd22..402462d 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -62,11 +62,9 @@ virStorageBackendISCSIPortal(virStoragePoolSourcePtr source) port = source->hosts[0].port; if (strchr(host, ':')) { - if (virAsprintf(&portal, "[%s]:%d,1", host, port) < 0) - virReportOOMError(); + ignore_value(virAsprintf(&portal, "[%s]:%d,1", host, port)); } else { - if (virAsprintf(&portal, "%s:%d,1", host, port) < 0) - virReportOOMError(); + ignore_value(virAsprintf(&portal, "%s:%d,1", host, port)); } return portal; @@ -234,10 +232,8 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn, if (virAsprintf(&temp_ifacename, "libvirt-iface-%08llx", - (unsigned long long)virRandomBits(30)) < 0) { - virReportOOMError(); + (unsigned long long)virRandomBits(30)) < 0) return -1; - } VIR_DEBUG("Attempting to create interface '%s' with IQN '%s'", temp_ifacename, initiatoriqn); @@ -396,10 +392,8 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool, uint32_t host; if (virAsprintf(&sysfs_path, - "/sys/class/iscsi_session/session%s/device", session) < 0) { - virReportOOMError(); + "/sys/class/iscsi_session/session%s/device", session) < 0) return -1; - } if (virStorageBackendISCSIGetHostNumber(sysfs_path, &host) < 0) { virReportSystemError(errno, @@ -452,7 +446,6 @@ virStorageBackendISCSIGetTargets(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, if (VIR_REALLOC_N(list->targets, list->ntargets + 1) < 0) { VIR_FREE(target); - virReportOOMError(); return -1; } @@ -590,17 +583,13 @@ virStorageBackendISCSIFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, &ntargets, &targets) < 0) goto cleanup; - if (VIR_ALLOC_N(list.sources, ntargets) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(list.sources, ntargets) < 0) goto cleanup; - } for (i = 0; i < ntargets; i++) { if (VIR_ALLOC_N(list.sources[i].devices, 1) < 0 || - VIR_ALLOC_N(list.sources[i].hosts, 1) < 0) { - virReportOOMError(); + VIR_ALLOC_N(list.sources[i].hosts, 1) < 0) goto cleanup; - } list.sources[i].nhost = 1; list.sources[i].hosts[0] = source->hosts[0]; list.sources[i].initiator = source->initiator; @@ -609,10 +598,8 @@ virStorageBackendISCSIFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, list.nsources++; } - if (!(ret = virStoragePoolSourceListFormat(&list))) { - virReportOOMError(); + if (!(ret = virStoragePoolSourceListFormat(&list))) goto cleanup; - } cleanup: if (list.sources) { diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 944aa0e..fff303d 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -97,10 +97,8 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, /* Or a completely new volume */ if (vol == NULL) { - if (VIR_ALLOC(vol) < 0) { - virReportOOMError(); + if (VIR_ALLOC(vol) < 0) return -1; - } is_new_vol = true; vol->type = VIR_STORAGE_VOL_BLOCK; @@ -109,18 +107,14 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, goto cleanup; if (VIR_REALLOC_N(pool->volumes.objs, - pool->volumes.count + 1)) { - virReportOOMError(); + pool->volumes.count + 1)) goto cleanup; - } } if (vol->target.path == NULL) { if (virAsprintf(&vol->target.path, "%s/%s", - pool->def->target.path, vol->name) < 0) { - virReportOOMError(); + pool->def->target.path, vol->name) < 0) goto cleanup; - } } /* Skips the backingStore of lv created with "--virtualsize", @@ -132,10 +126,8 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, */ if (groups[1] && !STREQ(groups[1], "") && (groups[1][0] != '[')) { if (virAsprintf(&vol->backingStore.path, "%s/%s", - pool->def->target.path, groups[1]) < 0) { - virReportOOMError(); + pool->def->target.path, groups[1]) < 0) goto cleanup; - } vol->backingStore.format = VIR_STORAGE_POOL_LOGICAL_LVM2; } @@ -157,10 +149,8 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, /* Finally fill in extents information */ if (VIR_REALLOC_N(vol->source.extents, - vol->source.nextent + nextents) < 0) { - virReportOOMError(); + vol->source.nextent + nextents) < 0) goto cleanup; - } if (virStrToLong_ull(groups[6], NULL, 10, &length) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -183,28 +173,22 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, goto cleanup; for (i = 1; i < nextents; i++) { - if (VIR_REALLOC_N(regex, strlen(regex) + strlen(regex_unit) + 2) < 0) { - virReportOOMError(); + if (VIR_REALLOC_N(regex, strlen(regex) + strlen(regex_unit) + 2) < 0) goto cleanup; - } /* "," is the separator of "devices" field */ strcat(regex, ","); strncat(regex, regex_unit, strlen(regex_unit)); } - if (VIR_ALLOC(reg) < 0) { - virReportOOMError(); + if (VIR_ALLOC(reg) < 0) goto cleanup; - } /* Each extent has a "path:offset" pair, and vars[0] will * be the whole matched string. */ nvars = (nextents * 2) + 1; - if (VIR_ALLOC_N(vars, nvars) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(vars, nvars) < 0) goto cleanup; - } err = regcomp(reg, regex, REG_EXTENDED); if (err != 0) { @@ -380,10 +364,8 @@ virStorageBackendLogicalFindPoolSourcesFunc(virStoragePoolObjPtr pool ATTRIBUTE_ else VIR_FREE(vgname); - if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0) { - virReportOOMError(); + if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0) goto error; - } dev = &thisSource->devices[thisSource->ndevice]; thisSource->ndevice++; @@ -473,10 +455,8 @@ virStorageBackendLogicalCheckPool(virConnectPtr conn ATTRIBUTE_UNUSED, char *path; *isActive = false; - if (virAsprintf(&path, "/dev/%s", pool->def->source.name) < 0) { - virReportOOMError(); + if (virAsprintf(&path, "/dev/%s", pool->def->source.name) < 0) return -1; - } if (access(path, F_OK) == 0) *isActive = true; @@ -719,10 +699,8 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, - vol->name) == -1) { - virReportOOMError(); + vol->name) == -1) return -1; - } cmd = virCommandNewArgList(LVCREATE, "--name", vol->name, @@ -822,10 +800,8 @@ virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, virCheckFlags(0, -1); if (virAsprintf(&volpath, "%s/%s", - pool->def->source.name, vol->name) < 0) { - virReportOOMError(); + pool->def->source.name, vol->name) < 0) goto cleanup; - } virFileWaitForDevices(); diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index 357c346..8333f18 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -75,22 +75,16 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol; int ret = -1; - if (VIR_ALLOC(vol) < 0) { - virReportOOMError(); + if (VIR_ALLOC(vol) < 0) goto cleanup; - } vol->type = VIR_STORAGE_VOL_BLOCK; - if (virAsprintf(&(vol->name), "dm-%u", devnum) < 0) { - virReportOOMError(); + if (virAsprintf(&(vol->name), "dm-%u", devnum) < 0) goto cleanup; - } - if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0) { - virReportOOMError(); + if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0) goto cleanup; - } if (virStorageBackendMpathUpdateVolTargetInfo(&vol->target, &vol->allocation, @@ -103,10 +97,8 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool, goto cleanup; if (VIR_REALLOC_N(pool->volumes.objs, - pool->volumes.count + 1) < 0) { - virReportOOMError(); + pool->volumes.count + 1) < 0) goto cleanup; - } pool->volumes.objs[pool->volumes.count++] = vol; pool->def->capacity += vol->capacity; pool->def->allocation += vol->allocation; @@ -220,10 +212,8 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool, if (is_mpath == 1) { - if (virAsprintf(&map_device, "mapper/%s", names->name) < 0) { - virReportOOMError(); + if (virAsprintf(&map_device, "mapper/%s", names->name) < 0) goto out; - } if (virStorageBackendGetMinorNumber(names->name, &minor) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index 953a8ee..7b73a38 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -238,18 +238,14 @@ static int volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol, VIR_FREE(vol->target.path); if (virAsprintf(&vol->target.path, "%s/%s", pool->def->source.name, - vol->name) == -1) { - virReportOOMError(); + vol->name) == -1) goto cleanup; - } VIR_FREE(vol->key); if (virAsprintf(&vol->key, "%s/%s", pool->def->source.name, - vol->name) == -1) { - virReportOOMError(); + vol->name) == -1) goto cleanup; - } ret = 0; @@ -308,7 +304,7 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, while (true) { if (VIR_ALLOC_N(names, max_size) < 0) - goto out_of_memory; + goto cleanup; len = rbd_list(ptr.ioctx, names, &max_size); if (len >= 0) @@ -325,14 +321,14 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count + 1) < 0) { virStoragePoolObjClearVols(pool); - goto out_of_memory; + goto cleanup; } if (STREQ(name, "")) break; if (VIR_ALLOC(vol) < 0) - goto out_of_memory; + goto cleanup; if (VIR_STRDUP(vol->name, name) < 0) { VIR_FREE(vol); @@ -358,10 +354,6 @@ cleanup: VIR_FREE(names); virStorageBackendRBDCloseRADOSConn(ptr); return ret; - -out_of_memory: - virReportOOMError(); - goto cleanup; } static int virStorageBackendRBDDeleteVol(virConnectPtr conn, diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 3deceda..8cb762a 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -56,10 +56,8 @@ getDeviceType(uint32_t host, int retval = 0; if (virAsprintf(&type_path, "/sys/bus/scsi/devices/%u:%u:%u:%u/type", - host, bus, target, lun) < 0) { - virReportOOMError(); + host, bus, target, lun) < 0) goto out; - } typefile = fopen(type_path, "r"); if (typefile == NULL) { @@ -213,7 +211,6 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, int retval = 0; if (VIR_ALLOC(vol) < 0) { - virReportOOMError(); retval = -1; goto out; } @@ -226,13 +223,11 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, * just leave 'host' out */ if (virAsprintf(&(vol->name), "unit:%u:%u:%u", bus, target, lun) < 0) { - virReportOOMError(); retval = -1; goto free_vol; } if (virAsprintf(&devpath, "/dev/%s", dev) < 0) { - virReportOOMError(); retval = -1; goto free_vol; } @@ -284,7 +279,6 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count + 1) < 0) { - virReportOOMError(); retval = -1; goto free_vol; } @@ -310,10 +304,8 @@ getNewStyleBlockDevice(const char *lun_path, struct dirent *block_dirent = NULL; int retval = 0; - if (virAsprintf(&block_path, "%s/block", lun_path) < 0) { - virReportOOMError(); + if (virAsprintf(&block_path, "%s/block", lun_path) < 0) goto out; - } VIR_DEBUG("Looking for block device in '%s'", block_path); @@ -395,10 +387,8 @@ getBlockDevice(uint32_t host, int retval = 0; if (virAsprintf(&lun_path, "/sys/bus/scsi/devices/%u:%u:%u:%u", - host, bus, target, lun) < 0) { - virReportOOMError(); + host, bus, target, lun) < 0) goto out; - } lun_dir = opendir(lun_path); if (lun_dir == NULL) { @@ -543,7 +533,6 @@ virStorageBackendSCSITriggerRescan(uint32_t host) VIR_DEBUG("Triggering rescan of host %d", host); if (virAsprintf(&path, "/sys/class/scsi_host/host%u/scan", host) < 0) { - virReportOOMError(); retval = -1; goto out; } @@ -708,10 +697,8 @@ virStorageBackendSCSICheckPool(virConnectPtr conn ATTRIBUTE_UNUSED, if (getHostNumber(name, &host) < 0) goto cleanup; - if (virAsprintf(&path, "/sys/class/scsi_host/host%d", host) < 0) { - virReportOOMError(); + if (virAsprintf(&path, "/sys/class/scsi_host/host%d", host) < 0) goto cleanup; - } if (access(path, F_OK) == 0) *isActive = true; diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c index b4d7b8e..a97af1b 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -263,10 +263,8 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED, VIR_FREE(vol->key); if (virAsprintf(&vol->key, "%s/%s", - pool->def->source.name, vol->name) == -1) { - virReportOOMError(); + pool->def->source.name, vol->name) == -1) goto cleanup; - } VIR_FREE(vol->target.path); ignore_value(VIR_STRDUP(vol->target.path, vol->name)); diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 02f7b69..3cbb15a 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -158,11 +158,11 @@ storageStateInitialize(bool privileged, */ if (virAsprintf(&driverState->configDir, "%s/storage", base) == -1) - goto out_of_memory; + goto error; if (virAsprintf(&driverState->autostartDir, "%s/storage/autostart", base) == -1) - goto out_of_memory; + goto error; VIR_FREE(base); @@ -175,8 +175,6 @@ storageStateInitialize(bool privileged, storageDriverUnlock(driverState); return 0; -out_of_memory: - virReportOOMError(); error: VIR_FREE(base); storageDriverUnlock(driverState); @@ -1283,10 +1281,8 @@ storagePoolListAllVolumes(virStoragePoolPtr pool, goto cleanup; } - if (VIR_ALLOC_N(tmp_vols, obj->volumes.count + 1) < 0) { - virReportOOMError(); + if (VIR_ALLOC_N(tmp_vols, obj->volumes.count + 1) < 0) goto cleanup; - } for (i = 0; i < obj->volumes.count; i++) { if (!virStoragePoolListAllVolumesCheckACL(pool->conn, obj->def, @@ -1512,10 +1508,8 @@ storageVolCreateXML(virStoragePoolPtr obj, } if (VIR_REALLOC_N(pool->volumes.objs, - pool->volumes.count+1) < 0) { - virReportOOMError(); + pool->volumes.count+1) < 0) goto cleanup; - } if (!backend->createVol) { virReportError(VIR_ERR_NO_SUPPORT, @@ -1541,7 +1535,6 @@ storageVolCreateXML(virStoragePoolPtr obj, virStorageVolDefPtr buildvoldef = NULL; if (VIR_ALLOC(buildvoldef) < 0) { - virReportOOMError(); voldef = NULL; goto cleanup; } @@ -1693,10 +1686,8 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj, goto cleanup; if (VIR_REALLOC_N(pool->volumes.objs, - pool->volumes.count+1) < 0) { - virReportOOMError(); + pool->volumes.count+1) < 0) goto cleanup; - } /* 'Define' the new volume so we get async progress reporting */ if (backend->createVol(obj->conn, pool, newvol) < 0) { @@ -2173,10 +2164,8 @@ storageVolWipeInternal(virStorageVolDefPtr def, ret = storageVolZeroSparseFile(def, st.st_size, fd); } else { - if (VIR_ALLOC_N(writebuf, st.st_blksize) != 0) { - virReportOOMError(); + if (VIR_ALLOC_N(writebuf, st.st_blksize) < 0) goto out; - } ret = storageWipeExtent(def, fd, -- 1.8.1.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list