Remove unnecessary curly brackets in src/storage/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2014-11-13 15:25:27 +01:00
parent 5cca4cd16f
commit e7a1da8aeb
8 changed files with 35 additions and 70 deletions

View File

@ -91,9 +91,8 @@ int main(int argc, char **argv)
if (VIR_STRDUP_QUIET(canonical_path, path) < 0)
return 2;
} else {
if (virFileResolveLink(path, &canonical_path) != 0) {
if (virFileResolveLink(path, &canonical_path) != 0)
return 2;
}
partsep = *canonical_path &&
c_isdigit(canonical_path[strlen(canonical_path)-1]) ? "p" : "";

View File

@ -182,9 +182,8 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
}
#ifdef __linux__
if (ioctl(fd, BLKBSZGET, &wbytes) < 0) {
if (ioctl(fd, BLKBSZGET, &wbytes) < 0)
wbytes = 0;
}
#endif
if ((wbytes == 0) && fstat(fd, &st) == 0)
wbytes = st.st_blksize;
@ -395,9 +394,8 @@ createRawFile(int fd, virStorageVolDefPtr vol,
(vol->target.allocation < inputvol->target.capacity);
ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, want_sparse);
if (ret < 0) {
if (ret < 0)
goto cleanup;
}
}
if (remain && need_alloc) {
@ -631,9 +629,8 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
virCommandSetGID(cmd, -1);
if (!filecreated) {
if (virCommandRun(cmd, NULL) < 0) {
if (virCommandRun(cmd, NULL) < 0)
return -1;
}
if (stat(vol->target.path, &st) < 0) {
virReportSystemError(errno,
_("failed to create %s"), vol->target.path);

View File

@ -171,9 +171,8 @@ virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPtr pool,
return -1; /* Don't bother to re-alloc freeExtents - it'll be free'd shortly */
/* first block reported as free, even if it is not */
if (dev->freeExtents[dev->nfreeExtent].start == 0) {
if (dev->freeExtents[dev->nfreeExtent].start == 0)
dev->freeExtents[dev->nfreeExtent].start = SECTOR_SIZE;
}
pool->def->available +=
(dev->freeExtents[dev->nfreeExtent].end -
@ -349,9 +348,8 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
return -1;
}
if (virStorageBackendDiskReadGeometry(pool) != 0) {
if (virStorageBackendDiskReadGeometry(pool) != 0)
return -1;
}
return virStorageBackendDiskReadPartitions(pool, NULL);
}
@ -467,9 +465,8 @@ virStorageBackendDiskPartTypeToCreate(virStoragePoolObjPtr pool)
partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED)
count++;
}
if (count >= 4) {
if (count >= 4)
return VIR_STORAGE_VOL_DISK_TYPE_LOGICAL;
}
}
/* for all other cases, all partitions are primary */
@ -587,9 +584,8 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
}
/* if we are creating a logical partition, we need one extra
block between partitions (or actually move start one block) */
if (partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) {
if (partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL)
size -= SECTOR_SIZE;
}
}
if (size > neededSize &&
(smallestSize == 0 ||
@ -659,9 +655,8 @@ virStorageBackendDiskCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
goto cleanup;
}
if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0) {
if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0)
goto cleanup;
}
virCommandAddArg(cmd, partFormat);
if (virStorageBackendDiskPartBoundaries(pool, &startOffset,

View File

@ -639,9 +639,8 @@ virStorageBackendFileSystemProbe(const char *device,
error:
VIR_FREE(libblkid_format);
if (probe != NULL) {
if (probe != NULL)
blkid_free_probe(probe);
}
return ret;
}
@ -737,9 +736,8 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool,
ok_to_mkfs = true;
}
if (ok_to_mkfs) {
if (ok_to_mkfs)
ret = virStorageBackendExecuteMKFS(device, format);
}
error:
return ret;

View File

@ -119,14 +119,12 @@ virStorageBackendIsMultipath(const char *dev_name)
goto out;
}
if (STREQ(target_type, "multipath")) {
if (STREQ(target_type, "multipath"))
ret = 1;
}
out:
if (dmt != NULL) {
if (dmt != NULL)
dm_task_destroy(dmt);
}
return ret;
}
@ -138,21 +136,17 @@ virStorageBackendGetMinorNumber(const char *dev_name, uint32_t *minor)
struct dm_task *dmt;
struct dm_info info;
if (!(dmt = dm_task_create(DM_DEVICE_INFO))) {
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
goto out;
}
if (!dm_task_set_name(dmt, dev_name)) {
if (!dm_task_set_name(dmt, dev_name))
goto out;
}
if (!dm_task_run(dmt)) {
if (!dm_task_run(dmt))
goto out;
}
if (!dm_task_get_info(dmt, &info)) {
if (!dm_task_get_info(dmt, &info))
goto out;
}
*minor = info.minor;
ret = 0;
@ -177,9 +171,8 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool,
do {
is_mpath = virStorageBackendIsMultipath(names->name);
if (is_mpath < 0) {
if (is_mpath < 0)
goto out;
}
if (is_mpath == 1) {
@ -193,9 +186,8 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool,
goto out;
}
if (virStorageBackendMpathNewVol(pool, minor, map_device) < 0) {
if (virStorageBackendMpathNewVol(pool, minor, map_device) < 0)
goto out;
}
VIR_FREE(map_device);
}
@ -247,9 +239,8 @@ virStorageBackendGetMaps(virStoragePoolObjPtr pool)
virStorageBackendCreateVols(pool, names);
out:
if (dmt != NULL) {
if (dmt != NULL)
dm_task_destroy(dmt);
}
return retval;
}

View File

@ -330,13 +330,11 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn,
ptr.cluster = NULL;
ptr.ioctx = NULL;
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
goto cleanup;
}
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
goto cleanup;
}
struct rados_cluster_stat_t clusterstat;
r = rados_cluster_stat(ptr.cluster, &clusterstat);
@ -428,17 +426,14 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn,
VIR_DEBUG("Removing RBD image %s/%s", pool->def->source.name, vol->name);
if (flags & VIR_STORAGE_VOL_DELETE_ZEROED) {
if (flags & VIR_STORAGE_VOL_DELETE_ZEROED)
VIR_WARN("%s", _("This storage backend does not supported zeroed removal of volumes"));
}
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
goto cleanup;
}
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
goto cleanup;
}
r = rbd_remove(ptr.ioctx, vol->name);
if (r < 0) {
@ -555,17 +550,14 @@ static int virStorageBackendRBDRefreshVol(virConnectPtr conn,
ptr.ioctx = NULL;
int ret = -1;
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
goto cleanup;
}
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
goto cleanup;
}
if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0) {
if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0)
goto cleanup;
}
ret = 0;
@ -589,13 +581,11 @@ static int virStorageBackendRBDResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virCheckFlags(0, -1);
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) {
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
goto cleanup;
}
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) {
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
goto cleanup;
}
r = rbd_open(ptr.ioctx, vol->name, &image, NULL);
if (r < 0) {

View File

@ -256,9 +256,8 @@ getNewStyleBlockDevice(const char *lun_path,
while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) {
if (STREQLEN(block_dirent->d_name, ".", 1)) {
if (STREQLEN(block_dirent->d_name, ".", 1))
continue;
}
if (VIR_STRDUP(*block_device, block_dirent->d_name) < 0) {
closedir(block_dir);
@ -397,9 +396,8 @@ processLU(virStoragePoolObjPtr pool,
VIR_DEBUG("%u:%u:%u:%u is a Direct-Access LUN",
host, bus, target, lun);
if (getBlockDevice(host, bus, target, lun, &block_device) < 0) {
if (getBlockDevice(host, bus, target, lun, &block_device) < 0)
goto out;
}
if (virStorageBackendSCSINewLun(pool,
host, bus, target, lun,

View File

@ -484,9 +484,8 @@ storageConnectListDefinedStoragePools(virConnectPtr conn,
cleanup:
storageDriverUnlock();
for (i = 0; i < got; i++) {
for (i = 0; i < got; i++)
VIR_FREE(names[i]);
}
memset(names, 0, nnames * sizeof(*names));
return -1;
}
@ -1650,9 +1649,8 @@ storageVolCreateXML(virStoragePoolPtr obj,
/* Wipe any key the user may have suggested, as volume creation
* will generate the canonical key. */
VIR_FREE(voldef->key);
if (backend->createVol(obj->conn, pool, voldef) < 0) {
if (backend->createVol(obj->conn, pool, voldef) < 0)
goto cleanup;
}
pool->volumes.objs[pool->volumes.count++] = voldef;
volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
@ -1830,9 +1828,8 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
* Wipe any key the user may have suggested, as volume creation
* will generate the canonical key. */
VIR_FREE(newvol->key);
if (backend->createVol(obj->conn, pool, newvol) < 0) {
if (backend->createVol(obj->conn, pool, newvol) < 0)
goto cleanup;
}
pool->volumes.objs[pool->volumes.count++] = newvol;
volobj = virGetStorageVol(obj->conn, pool->def->name, newvol->name,