]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: fs_file_init_parent() - Keep mode and flags parameters separated
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 9 Nov 2020 11:04:43 +0000 (13:04 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 9 Nov 2020 11:04:43 +0000 (13:04 +0200)
Internally cast them both to (int) before ORing them together for the
fs_file_init_with_event() call.

This avoids compiler warnings with -Wenum-enum-conversion:
warning: bitwise operation between different enumeration types ('enum fs_open_mode' and 'enum fs_open_flags')

src/lib-fs/fs-api-private.h
src/lib-fs/fs-api.c
src/lib-fs/fs-metawrap.c
src/lib-fs/fs-randomfail.c
src/lib-fs/fs-sis-queue.c
src/lib-fs/fs-sis.c
src/plugins/fs-compress/fs-compress.c
src/plugins/mail-crypt/fs-crypt-common.c

index 9231349f67236e74cf33ab72299a072bcbc2afc1..07545253b0c0b531bae77eb1bd98b73f5dd81dcf 100644 (file)
@@ -198,7 +198,8 @@ int fs_default_copy(struct fs_file *src, struct fs_file *dest);
 void fs_file_timing_end(struct fs_file *file, enum fs_op op);
 
 struct fs_file *
-fs_file_init_parent(struct fs_file *parent, const char *path, int mode_flags);
+fs_file_init_parent(struct fs_file *parent, const char *path,
+                   enum fs_open_mode mode, enum fs_open_flags flags);
 struct fs_iter *
 fs_iter_init_parent(struct fs_iter *parent,
                    const char *path, enum fs_iter_flags flags);
index 44ce7e625fdbf2c62b05e4a083d63f61e82f1303..10c09daafecabadc92c9c3d503f5221f3eaf4bbf 100644 (file)
@@ -1386,10 +1386,11 @@ uint64_t fs_stats_get_write_usecs(const struct fs_stats *stats)
 }
 
 struct fs_file *
-fs_file_init_parent(struct fs_file *parent, const char *path, int mode_flags)
+fs_file_init_parent(struct fs_file *parent, const char *path,
+                   enum fs_open_mode mode, enum fs_open_flags flags)
 {
        return fs_file_init_with_event(parent->fs->parent, parent->event,
-                                      path, mode_flags);
+                                      path, (int)mode | (int)flags);
 }
 
 struct fs_iter *
index 5459c3e7943b23bc2753e2f8d9af4593f4bc3848..f6c86f366832895ce9ae89f79ec1a751e63c4b46 100644 (file)
@@ -115,13 +115,13 @@ fs_metawrap_file_init(struct fs_file *_file, const char *path,
        /* avoid unnecessarily creating two seekable streams */
        flags &= ENUM_NEGATE(FS_OPEN_FLAG_SEEKABLE);
 
-       file->file.parent = fs_file_init_parent(_file, path, mode | flags);
+       file->file.parent = fs_file_init_parent(_file, path, mode, flags);
        if (file->fs->wrap_metadata && mode == FS_OPEN_MODE_READONLY &&
            (flags & FS_OPEN_FLAG_ASYNC) == 0) {
                /* use async stream for parent, so fs_read_stream() won't create
                   another seekable stream needlessly */
                file->super_read = fs_file_init_parent(_file, path,
-                       mode | flags | FS_OPEN_FLAG_ASYNC |
+                       mode, flags | FS_OPEN_FLAG_ASYNC |
                        FS_OPEN_FLAG_ASYNC_NOQUEUE);
        } else {
                file->super_read = file->file.parent;
index ad2cb248c76e0f7bc8e5a82f682f3aad51f8be5a..48b1bf0431994fe7c261deab559ec5484523d8e9 100644 (file)
@@ -223,7 +223,7 @@ fs_randomfail_file_init(struct fs_file *_file, const char *path,
        struct randomfail_fs_file *file = RANDOMFAIL_FILE(_file);
 
        file->file.path = i_strdup(path);
-       file->file.parent = fs_file_init_parent(_file, path, mode | flags);
+       file->file.parent = fs_file_init_parent(_file, path, mode, flags);
 }
 
 static void fs_randomfail_file_deinit(struct fs_file *_file)
index a95b38aa0f7ca0df59b1564975a955ec94a01d2e..8ad7d98086c92515f2c9686bbad2aaa826cdba7c 100644 (file)
@@ -85,7 +85,7 @@ fs_sis_queue_file_init(struct fs_file *_file, const char *path,
        if (mode == FS_OPEN_MODE_APPEND)
                fs_set_error(_file->event, ENOTSUP, "APPEND mode not supported");
        else
-               file->file.parent = fs_file_init_parent(_file, path, mode | flags);
+               file->file.parent = fs_file_init_parent(_file, path, mode, flags);
 }
 
 static void fs_sis_queue_file_deinit(struct fs_file *_file)
@@ -111,7 +111,7 @@ static void fs_sis_queue_add(struct sis_queue_fs_file *file)
                fname = path;
 
        queue_path = t_strdup_printf("%s/%s", fs->queue_dir, fname);
-       queue_file = fs_file_init_parent(&file->file, queue_path, FS_OPEN_MODE_CREATE);
+       queue_file = fs_file_init_parent(&file->file, queue_path, FS_OPEN_MODE_CREATE, 0);
        if (fs_write(queue_file, "", 0) < 0 && errno != EEXIST)
                e_error(file->file.event, "%s", fs_file_last_error(queue_file));
        fs_file_deinit(&queue_file);
index 91df2e15ae7b8f073fde2c9009417d0b075861d7..6a020bcbc736a13e1fd3e3bc4610a01a49431ba0 100644 (file)
@@ -105,7 +105,7 @@ fs_sis_file_init(struct fs_file *_file, const char *path,
        /* if hashes/<hash> already exists, open it */
        file->hash_path = i_strdup_printf("%s/"HASH_DIR_NAME"/%s", dir, hash);
        file->hash_file = fs_file_init_parent(_file, file->hash_path,
-                                             FS_OPEN_MODE_READONLY);
+                                             FS_OPEN_MODE_READONLY, 0);
 
        file->hash_input = fs_read_stream(file->hash_file, IO_BLOCK_SIZE);
        if (i_stream_read(file->hash_input) == -1) {
@@ -117,7 +117,7 @@ fs_sis_file_init(struct fs_file *_file, const char *path,
                i_stream_destroy(&file->hash_input);
        }
 
-       file->file.parent = fs_file_init_parent(_file, path, mode | flags);
+       file->file.parent = fs_file_init_parent(_file, path, mode, flags);
 }
 
 static void fs_sis_file_deinit(struct fs_file *_file)
@@ -216,7 +216,7 @@ static void fs_sis_replace_hash_file(struct sis_fs_file *file)
 
        /* replace existing hash file atomically */
        temp_file = fs_file_init_parent(&file->file, str_c(temp_path),
-                                       FS_OPEN_MODE_READONLY);
+                                       FS_OPEN_MODE_READONLY, 0);
        ret = fs_copy(file->file.parent, temp_file);
        if (ret < 0 && errno == EEXIST) {
                /* either someone's racing us or it's a stale file.
index bfb2b3462116e6e94af1914fe3b38c1f719172e0..871980c97db415e91e39fd35c90744ab339184fa 100644 (file)
@@ -126,13 +126,13 @@ fs_compress_file_init(struct fs_file *_file, const char *path,
        /* avoid unnecessarily creating two seekable streams */
        flags &= ENUM_NEGATE(FS_OPEN_FLAG_SEEKABLE);
 
-       file->file.parent = fs_file_init_parent(_file, path, mode | flags);
+       file->file.parent = fs_file_init_parent(_file, path, mode, flags);
        if (mode == FS_OPEN_MODE_READONLY &&
            (flags & FS_OPEN_FLAG_ASYNC) == 0) {
                /* use async stream for parent, so fs_read_stream() won't create
                   another seekable stream needlessly */
                file->super_read = fs_file_init_parent(_file, path,
-                       mode | flags | FS_OPEN_FLAG_ASYNC |
+                       mode, flags | FS_OPEN_FLAG_ASYNC |
                        FS_OPEN_FLAG_ASYNC_NOQUEUE);
        } else {
                file->super_read = file->file.parent;
index 1651dc9ea11df16fd28f71e383c39f34d6f6d170..7432fa6572507c2152c32bc7173d7832601e0866 100644 (file)
@@ -152,13 +152,13 @@ fs_crypt_file_init(struct fs_file *_file, const char *path,
        /* avoid unnecessarily creating two seekable streams */
        flags &= ENUM_NEGATE(FS_OPEN_FLAG_SEEKABLE);
 
-       file->file.parent = fs_file_init_parent(_file, path, mode | flags);
+       file->file.parent = fs_file_init_parent(_file, path, mode, flags);
        if (mode == FS_OPEN_MODE_READONLY &&
            (flags & FS_OPEN_FLAG_ASYNC) == 0) {
                /* use async stream for super, so fs_read_stream() won't create
                   another seekable stream needlessly */
                file->super_read = fs_file_init_parent(_file, path,
-                       mode | flags | FS_OPEN_FLAG_ASYNC |
+                       mode, flags | FS_OPEN_FLAG_ASYNC |
                        FS_OPEN_FLAG_ASYNC_NOQUEUE);
        } else {
                file->super_read = file->file.parent;