Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- src/storage/storage_backend_fs.c | 2 +- src/storage/storage_backend_gluster.c | 6 ++-- src/storage/storage_backend_logical.c | 2 +- src/storage/storage_backend_vstorage.c | 6 ++-- src/storage/storage_driver.c | 6 ++-- src/storage/storage_util.c | 44 +++++++++++++------------- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 9b0fcf92c5cd..e10c497bf201 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -798,7 +798,7 @@ virStorageFileBackendFileRead(virStorageSourcePtr src, } if (offset > 0) { - if (lseek(fd, offset, SEEK_SET) == (off_t) -1) { + if (lseek(fd, offset, SEEK_SET) == (off_t)-1) { virReportSystemError(errno, _("cannot seek into '%s'"), src->path); goto cleanup; } diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c index c6cc531e2ff6..fe29e026add8 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -350,7 +350,7 @@ virStorageBackendGlusterRefreshPool(virStoragePoolObjPtr pool) struct { struct dirent ent; /* See comment below about readdir_r needing padding */ - char padding[MAX(1, 256 - (int) (sizeof(struct dirent) + char padding[MAX(1, 256 - (int)(sizeof(struct dirent) - offsetof(struct dirent, d_name)))]; } de; struct dirent *ent; @@ -431,7 +431,7 @@ virStorageBackendGlusterVolDelete(virStoragePoolObjPtr pool, virCheckFlags(0, -1); - switch ((virStorageVolType) vol->type) { + switch ((virStorageVolType)vol->type) { case VIR_STORAGE_VOL_FILE: case VIR_STORAGE_VOL_DIR: case VIR_STORAGE_VOL_BLOCK: @@ -731,7 +731,7 @@ virStorageFileBackendGlusterRead(virStorageSourcePtr src, } if (offset > 0) { - if (glfs_lseek(fd, offset, SEEK_SET) == (off_t) -1) { + if (glfs_lseek(fd, offset, SEEK_SET) == (off_t)-1) { virReportSystemError(errno, _("cannot seek into '%s'"), src->path); goto cleanup; } diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 6a7d59bd57e0..edd4971f1f1f 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -1005,7 +1005,7 @@ virStorageBackendLogicalCreateVol(virStoragePoolObjPtr pool, goto error; } } - if (fchmod(fd, (vol->target.perms->mode == (mode_t) -1 ? + if (fchmod(fd, (vol->target.perms->mode == (mode_t)-1 ? VIR_STORAGE_DEFAULT_VOL_PERM_MODE : vol->target.perms->mode)) < 0) { virReportSystemError(errno, diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_backend_vstorage.c index 076617aeb634..fcaebf29e7c6 100644 --- a/src/storage/storage_backend_vstorage.c +++ b/src/storage/storage_backend_vstorage.c @@ -45,11 +45,11 @@ virStorageBackendVzPoolStart(virStoragePoolObjPtr pool) char *mode = NULL; /* Check the permissions */ - if (def->target.perms.mode == (mode_t) - 1) + if (def->target.perms.mode == (mode_t)- 1) def->target.perms.mode = VIR_STORAGE_DEFAULT_POOL_PERM_MODE; - if (def->target.perms.uid == (uid_t) -1) + if (def->target.perms.uid == (uid_t)-1) def->target.perms.uid = geteuid(); - if (def->target.perms.gid == (gid_t) -1) + if (def->target.perms.gid == (gid_t)-1) def->target.perms.gid = getegid(); /* Convert ids to names because vstorage uses names */ diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 610427673076..b125e2caf916 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1513,7 +1513,7 @@ static bool storageVolLookupByKeyCallback(virStoragePoolObjPtr obj, const void *opaque) { - struct storageVolLookupData *data = (struct storageVolLookupData *) opaque; + struct storageVolLookupData *data = (struct storageVolLookupData *)opaque; if (virStoragePoolObjIsActive(obj)) data->voldef = virStorageVolDefFindByKey(obj, data->key); @@ -1556,7 +1556,7 @@ static bool storageVolLookupByPathCallback(virStoragePoolObjPtr obj, const void *opaque) { - struct storageVolLookupData *data = (struct storageVolLookupData *) opaque; + struct storageVolLookupData *data = (struct storageVolLookupData *)opaque; virStoragePoolDefPtr def; char *stable_path = NULL; @@ -1565,7 +1565,7 @@ storageVolLookupByPathCallback(virStoragePoolObjPtr obj, def = virStoragePoolObjGetDef(obj); - switch ((virStoragePoolType) def->type) { + switch ((virStoragePoolType)def->type) { case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_FS: case VIR_STORAGE_POOL_NETFS: diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 897dfdaaee4d..03f03b407e13 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -271,19 +271,19 @@ storageBackendCreateBlockFrom(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, goto cleanup; } uid = (vol->target.perms->uid != st.st_uid) ? vol->target.perms->uid - : (uid_t) -1; + : (uid_t)-1; gid = (vol->target.perms->gid != st.st_gid) ? vol->target.perms->gid - : (gid_t) -1; - if (((uid != (uid_t) -1) || (gid != (gid_t) -1)) + : (gid_t)-1; + if (((uid != (uid_t)-1) || (gid != (gid_t)-1)) && (fchown(fd, uid, gid) < 0)) { virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"), - vol->target.path, (unsigned int) uid, - (unsigned int) gid); + vol->target.path, (unsigned int)uid, + (unsigned int)gid); goto cleanup; } - mode = (vol->target.perms->mode == (mode_t) -1 ? + mode = (vol->target.perms->mode == (mode_t)-1 ? VIR_STORAGE_DEFAULT_VOL_PERM_MODE : vol->target.perms->mode); if (fchmod(fd, mode) < 0) { virReportSystemError(errno, @@ -433,7 +433,7 @@ storageBackendCreateRaw(virStoragePoolObjPtr pool, if (def->type == VIR_STORAGE_POOL_NETFS) operation_flags |= VIR_FILE_OPEN_FORK; - if (vol->target.perms->mode != (mode_t) -1) + if (vol->target.perms->mode != (mode_t)-1) open_mode = vol->target.perms->mode; if ((fd = virFileOpenAs(vol->target.path, @@ -595,7 +595,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, struct stat st; gid_t gid; uid_t uid; - mode_t mode = (vol->target.perms->mode == (mode_t) -1 ? + mode_t mode = (vol->target.perms->mode == (mode_t)-1 ? VIR_STORAGE_DEFAULT_VOL_PERM_MODE : vol->target.perms->mode); bool filecreated = false; @@ -603,9 +603,9 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, if ((def->type == VIR_STORAGE_POOL_NETFS) && (((geteuid() == 0) - && (vol->target.perms->uid != (uid_t) -1) + && (vol->target.perms->uid != (uid_t)-1) && (vol->target.perms->uid != 0)) - || ((vol->target.perms->gid != (gid_t) -1) + || ((vol->target.perms->gid != (gid_t)-1) && (vol->target.perms->gid != getegid())))) { virCommandSetUID(cmd, vol->target.perms->uid); @@ -656,15 +656,15 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, } uid = (vol->target.perms->uid != st.st_uid) ? vol->target.perms->uid - : (uid_t) -1; + : (uid_t)-1; gid = (vol->target.perms->gid != st.st_gid) ? vol->target.perms->gid - : (gid_t) -1; - if (((uid != (uid_t) -1) || (gid != (gid_t) -1)) + : (gid_t)-1; + if (((uid != (uid_t)-1) || (gid != (gid_t)-1)) && (chown(vol->target.path, uid, gid) < 0)) { virReportSystemError(errno, _("cannot chown %s to (%u, %u)"), - vol->target.path, (unsigned int) uid, - (unsigned int) gid); + vol->target.path, (unsigned int)uid, + (unsigned int)gid); goto cleanup; } @@ -730,7 +730,7 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, if (!inputvol) { if ((virDirCreate(vol->target.path, - (vol->target.perms->mode == (mode_t) -1 ? + (vol->target.perms->mode == (mode_t)-1 ? VIR_STORAGE_DEFAULT_VOL_PERM_MODE: vol->target.perms->mode), vol->target.perms->uid, @@ -1354,8 +1354,8 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolObjPtr pool, } VIR_FORCE_CLOSE(fd); - if ((vol->target.perms->uid != (uid_t) -1) && - (vol->target.perms->gid != (gid_t) -1)) { + if ((vol->target.perms->uid != (uid_t)-1) && + (vol->target.perms->gid != (gid_t)-1)) { if (chown(secretPath, vol->target.perms->uid, vol->target.perms->gid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2105,7 +2105,7 @@ createFileDir(virStoragePoolObjPtr pool, if ((err = virDirCreate(vol->target.path, - (vol->target.perms->mode == (mode_t) -1 ? + (vol->target.perms->mode == (mode_t)-1 ? VIR_STORAGE_DEFAULT_VOL_PERM_MODE : vol->target.perms->mode), vol->target.perms->uid, @@ -2236,7 +2236,7 @@ virStorageBackendVolDeleteLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, { virCheckFlags(0, -1); - switch ((virStorageVolType) vol->type) { + switch ((virStorageVolType)vol->type) { case VIR_STORAGE_VOL_FILE: case VIR_STORAGE_VOL_DIR: if (virFileRemove(vol->target.path, vol->target.perms->uid, @@ -2660,7 +2660,7 @@ storageBackendWipeLocal(const char *path, } } - VIR_DEBUG("wiping start: %zd len: %llu", (ssize_t) size, wipe_len); + VIR_DEBUG("wiping start: %zd len: %llu", (ssize_t)size, wipe_len); remaining = wipe_len; while (remaining > 0) { @@ -2912,7 +2912,7 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool) needs_create_as_uid = (def->type == VIR_STORAGE_POOL_NETFS); mode = def->target.perms.mode; - if (mode == (mode_t) -1 && + if (mode == (mode_t)-1 && (needs_create_as_uid || !virFileExists(def->target.path))) mode = VIR_STORAGE_DEFAULT_POOL_PERM_MODE; if (needs_create_as_uid) -- 2.17.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list