From: Ján Tomko Date: Wed, 23 Sep 2020 16:53:29 +0000 (+0200) Subject: storage: createFileDir: use less ternary operators X-Git-Tag: v6.8.0-rc1~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=327580ff6bf365178cfb1b1869606f506481ba3a;p=thirdparty%2Flibvirt.git storage: createFileDir: use less ternary operators Introduce separate variables and if conditions with spaces around them to make the function call easier to read. Signed-off-by: Ján Tomko Reviewed-by: Martin Kletzander --- diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 7bcc0ee832..94f62515f2 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1997,6 +1997,8 @@ createFileDir(virStoragePoolObjPtr pool, unsigned int flags) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); + mode_t permmode = VIR_STORAGE_DEFAULT_VOL_PERM_MODE; + unsigned int createflags = 0; virCheckFlags(0, -1); @@ -2013,15 +2015,17 @@ createFileDir(virStoragePoolObjPtr pool, return -1; } + if (vol->target.perms->mode != (mode_t)-1) + permmode = vol->target.perms->mode; + + if (def->type == VIR_STORAGE_POOL_NETFS) + createflags |= VIR_DIR_CREATE_AS_UID; if (virDirCreate(vol->target.path, - (vol->target.perms->mode == (mode_t)-1 ? - VIR_STORAGE_DEFAULT_VOL_PERM_MODE : - vol->target.perms->mode), + permmode, vol->target.perms->uid, vol->target.perms->gid, - (def->type == VIR_STORAGE_POOL_NETFS - ? VIR_DIR_CREATE_AS_UID : 0)) < 0) { + createflags) < 0) { return -1; }