From: Karl Fleischmann Date: Wed, 22 Jun 2022 08:14:56 +0000 (+0200) Subject: lib-fs/fs-posix: Fix variable scopes for missing flock() X-Git-Tag: 2.4.0~3814 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d1fb2d5647cb0a4417cd08c39ef156fd1b082a6a;p=thirdparty%2Fdovecot%2Fcore.git lib-fs/fs-posix: Fix variable scopes for missing flock() Move local variables into their used scope to fix unused-variable errors in case flock() is not available. --- diff --git a/src/lib-fs/fs-posix.c b/src/lib-fs/fs-posix.c index b9f5a155e9..65340efa9d 100644 --- a/src/lib-fs/fs-posix.c +++ b/src/lib-fs/fs-posix.c @@ -688,22 +688,22 @@ fs_posix_lock(struct fs_file *_file, unsigned int secs, struct fs_lock **lock_r) struct posix_fs *fs = container_of(_file->fs, struct posix_fs, fs); struct dotlock_settings dotlock_set; struct posix_fs_lock fs_lock, *ret_lock; - const char *error; int ret = -1; i_zero(&fs_lock); fs_lock.lock.file = _file; - struct file_lock_settings lock_set = { - .lock_method = FILE_LOCK_METHOD_FLOCK, - }; switch (fs->lock_method) { - case FS_POSIX_LOCK_METHOD_FLOCK: + case FS_POSIX_LOCK_METHOD_FLOCK: { #ifndef HAVE_FLOCK fs_set_error(_file->event, ENOTSUP, "flock() not supported by OS (for file %s)", file->full_path); #else + const char *error; + struct file_lock_settings lock_set = { + .lock_method = FILE_LOCK_METHOD_FLOCK, + }; if (secs == 0) { ret = file_try_lock(file->fd, file->full_path, F_WRLCK, &lock_set, &fs_lock.file_lock, @@ -719,6 +719,7 @@ fs_posix_lock(struct fs_file *_file, unsigned int secs, struct fs_lock **lock_r) } #endif break; + } case FS_POSIX_LOCK_METHOD_DOTLOCK: i_zero(&dotlock_set); dotlock_set.stale_timeout = FS_POSIX_DOTLOCK_STALE_TIMEOUT_SECS;