]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: start relying on file_lock_free(NULL) being a no-op
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Mon, 29 Jan 2018 13:43:05 +0000 (08:43 -0500)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Mar 2018 09:58:54 +0000 (11:58 +0200)
Cleanup performed with the following semantic patch:

@@
expression E;
@@

- if (E != NULL) {
-       file_lock_free(&E);
- }
+ file_lock_free(&E);

src/lib-index/mail-cache.c
src/lib-storage/index/index-mailbox-size.c
src/lib-storage/mail-autoexpunge.c
src/lib/file-lock.c
src/plugins/fts-squat/squat-trie.c
src/plugins/fts-squat/squat-uidlist.c

index 9596f3bbe903e1cf38bb8a6fb79de52ba696e91a..8f4f2e57d0d58bb2c152697b14a0b9c07aeb0fa0 100644 (file)
@@ -91,8 +91,7 @@ void mail_cache_file_close(struct mail_cache *cache)
        cache->mmap_length = 0;
        cache->last_field_header_offset = 0;
 
-       if (cache->file_lock != NULL)
-               file_lock_free(&cache->file_lock);
+       file_lock_free(&cache->file_lock);
        cache->locked = FALSE;
 
        if (cache->fd != -1) {
index b0400c9e13990e83996bf186c8ddd3b3c42041d4..45d2d8dbd954c5accd1e26b23114795bb63d6bd4 100644 (file)
@@ -225,8 +225,7 @@ void index_mailbox_vsize_update_deinit(struct mailbox_vsize_update **_update)
 
        if (update->lock != NULL || update->rebuild)
                index_mailbox_vsize_update_write(update);
-       if (update->lock != NULL)
-               file_lock_free(&update->lock);
+       file_lock_free(&update->lock);
        if (update->finish_in_background)
                index_mailbox_vsize_notify_indexer(update->box);
 
index 0fa8cb34411433d1b179f917b84175ebebe6b8ad..de6c31b955e5172554e460f79cc04b206616aa7a 100644 (file)
@@ -222,7 +222,6 @@ unsigned int mail_user_autoexpunge(struct mail_user *user)
                                break;
                }
        }
-       if (lock != NULL)
-               file_lock_free(&lock);
+       file_lock_free(&lock);
        return expunged_count;
 }
index 30c2f4caabbc9e8f48876d8319233228d1d7503f..b60fd226374921c8b082b323d689575ec374ff93 100644 (file)
@@ -426,8 +426,7 @@ static void file_try_unlink_locked(struct file_lock *lock)
                /* nobody was waiting on the lock - unlink it */
                i_unlink(lock->path);
        }
-       if (temp_lock != NULL)
-               file_lock_free(&temp_lock);
+       file_lock_free(&temp_lock);
 }
 
 void file_lock_free(struct file_lock **_lock)
index d07966e7e3386dcf7a588b8f6886ffea4d068444..f77a8ea9864f3db323297477ba653b6bfe99ff17 100644 (file)
@@ -1703,8 +1703,7 @@ static int squat_trie_write(struct squat_trie_build_context *ctx)
 
        if (ret < 0) {
                i_unlink_if_exists(path);
-               if (file_lock != NULL)
-                       file_lock_free(&file_lock);
+               file_lock_free(&file_lock);
        } else {
                squat_trie_close_fd(trie);
                trie->fd = fd;
@@ -1712,8 +1711,7 @@ static int squat_trie_write(struct squat_trie_build_context *ctx)
                if (trie->file_cache != NULL)
                        file_cache_set_fd(trie->file_cache, trie->fd);
 
-               if (ctx->file_lock != NULL)
-                       file_lock_free(&ctx->file_lock);
+               file_lock_free(&ctx->file_lock);
                ctx->file_lock = file_lock;
        }
        return ret;
index 74e9fa430502a7fe123a34ddeaee873c2c716ea9..1b623a44fb1214a7265ea60ad4f04e62fadc6e98 100644 (file)
@@ -553,8 +553,7 @@ static void squat_uidlist_close(struct squat_uidlist *uidlist)
        squat_uidlist_unmap(uidlist);
        if (uidlist->file_cache != NULL)
                file_cache_free(&uidlist->file_cache);
-       if (uidlist->file_lock != NULL)
-               file_lock_free(&uidlist->file_lock);
+       file_lock_free(&uidlist->file_lock);
        if (uidlist->dotlock != NULL)
                file_dotlock_delete(&uidlist->dotlock);
        i_close_fd_path(&uidlist->fd, uidlist->path);