Skip to content

Commit

Permalink
global: start relying on file_lock_free(NULL) being a no-op
Browse files Browse the repository at this point in the history
Cleanup performed with the following semantic patch:

	@@
	expression E;
	@@

	- if (E != NULL) {
	-       file_lock_free(&E);
	- }
	+ file_lock_free(&E);
  • Loading branch information
Josef 'Jeff' Sipek authored and cmouse committed Jan 31, 2018
1 parent ceb8c97 commit 5109f00
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/lib-index/mail-cache.c
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions src/lib-storage/index/index-mailbox-size.c
Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/lib-storage/mail-autoexpunge.c
Expand Up @@ -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;
}
3 changes: 1 addition & 2 deletions src/lib/file-lock.c
Expand Up @@ -406,8 +406,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)
Expand Down
6 changes: 2 additions & 4 deletions src/plugins/fts-squat/squat-trie.c
Expand Up @@ -1703,17 +1703,15 @@ 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;
trie->locked_file_size = trie->hdr.used_file_size;
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;
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fts-squat/squat-uidlist.c
Expand Up @@ -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);
Expand Down

0 comments on commit 5109f00

Please sign in to comment.