From: Josef 'Jeff' Sipek Date: Tue, 19 Sep 2017 10:25:23 +0000 (+0300) Subject: global: start relying on pool_unref(NULL) being a no-op X-Git-Tag: 2.3.0.rc1~978 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c69a177207ed18d0f0210347430a60957136bd6c;p=thirdparty%2Fdovecot%2Fcore.git global: start relying on pool_unref(NULL) being a no-op Cleanup performed with the following semantic patch: @@ expression E; @@ - if (E != NULL) { - pool_unref(&E); - } + pool_unref(&E); --- diff --git a/src/auth/db-passwd-file.c b/src/auth/db-passwd-file.c index 037a76bc9a..8aa3abb2ea 100644 --- a/src/auth/db-passwd-file.c +++ b/src/auth/db-passwd-file.c @@ -242,8 +242,7 @@ static void passwd_file_close(struct passwd_file *pw) if (hash_table_is_created(pw->users)) hash_table_destroy(&pw->users); - if (pw->pool != NULL) - pool_unref(&pw->pool); + pool_unref(&pw->pool); } static void passwd_file_free(struct passwd_file *pw) diff --git a/src/doveadm/dsync/dsync-brain.c b/src/doveadm/dsync/dsync-brain.c index 29a6cc1605..505259f42e 100644 --- a/src/doveadm/dsync/dsync-brain.c +++ b/src/doveadm/dsync/dsync-brain.c @@ -362,8 +362,7 @@ int dsync_brain_deinit(struct dsync_brain **_brain, enum mail_error *error_r) hash_table_iterate_deinit(&brain->mailbox_states_iter); hash_table_destroy(&brain->mailbox_states); - if (brain->dsync_box_pool != NULL) - pool_unref(&brain->dsync_box_pool); + pool_unref(&brain->dsync_box_pool); if (brain->lock_fd != -1) { /* unlink the lock file before it gets unlocked */ diff --git a/src/doveadm/dsync/dsync-ibc-pipe.c b/src/doveadm/dsync/dsync-ibc-pipe.c index b86b3950c4..45402c1d40 100644 --- a/src/doveadm/dsync/dsync-ibc-pipe.c +++ b/src/doveadm/dsync/dsync-ibc-pipe.c @@ -117,8 +117,7 @@ dsync_ibc_pipe_pop_item(struct dsync_ibc_pipe *pipe, enum item_type type) array_delete(&pipe->item_queue, 0, 1); item = NULL; - if (pipe->pop_pool != NULL) - pool_unref(&pipe->pop_pool); + pool_unref(&pipe->pop_pool); pipe->pop_pool = pipe->pop_item.pool; return &pipe->pop_item; } @@ -149,11 +148,9 @@ static void dsync_ibc_pipe_deinit(struct dsync_ibc *ibc) pipe->remote->remote = NULL; } - if (pipe->pop_pool != NULL) - pool_unref(&pipe->pop_pool); + pool_unref(&pipe->pop_pool); array_foreach_modifiable(&pipe->item_queue, item) { - if (item->pool != NULL) - pool_unref(&item->pool); + pool_unref(&item->pool); } array_foreach_modifiable(&pipe->pools, poolp) pool_unref(poolp); diff --git a/src/lib-dict/dict-sql.c b/src/lib-dict/dict-sql.c index 9e57732f55..f36e46d47b 100644 --- a/src/lib-dict/dict-sql.c +++ b/src/lib-dict/dict-sql.c @@ -909,8 +909,7 @@ sql_dict_transaction_init(struct dict *_dict) static void sql_dict_transaction_free(struct sql_dict_transaction_context *ctx) { - if (ctx->inc_row_pool != NULL) - pool_unref(&ctx->inc_row_pool); + pool_unref(&ctx->inc_row_pool); i_free(ctx->prev_inc_key); i_free(ctx->error); i_free(ctx); diff --git a/src/lib-fts/fts-language.c b/src/lib-fts/fts-language.c index 4208551b90..a68a8fc734 100644 --- a/src/lib-fts/fts-language.c +++ b/src/lib-fts/fts-language.c @@ -70,8 +70,7 @@ void fts_languages_init(void) void fts_languages_deinit(void) { - if (fts_languages_pool != NULL) - pool_unref(&fts_languages_pool); + pool_unref(&fts_languages_pool); } void fts_language_register(const char *name) diff --git a/src/lib-http/http-message-parser.c b/src/lib-http/http-message-parser.c index 3c08dd3308..c789ac2d39 100644 --- a/src/lib-http/http-message-parser.c +++ b/src/lib-http/http-message-parser.c @@ -31,8 +31,7 @@ void http_message_parser_deinit(struct http_message_parser *parser) { if (parser->header_parser != NULL) http_header_parser_deinit(&parser->header_parser); - if (parser->msg.pool != NULL) - pool_unref(&parser->msg.pool); + pool_unref(&parser->msg.pool); i_stream_unref(&parser->payload); i_stream_unref(&parser->input); } @@ -53,8 +52,7 @@ void http_message_parser_restart(struct http_message_parser *parser, http_header_parser_reset(parser->header_parser); } - if (parser->msg.pool != NULL) - pool_unref(&parser->msg.pool); + pool_unref(&parser->msg.pool); i_zero(&parser->msg); if (pool != NULL) { parser->msg.pool = pool; diff --git a/src/lib-index/mail-index-map.c b/src/lib-index/mail-index-map.c index 667d7d712e..7ee80c8a9e 100644 --- a/src/lib-index/mail-index-map.c +++ b/src/lib-index/mail-index-map.c @@ -312,8 +312,7 @@ void mail_index_unmap(struct mail_index_map **_map) i_assert(map->refcount == 0); mail_index_record_map_unlink(map); - if (map->extension_pool != NULL) - pool_unref(&map->extension_pool); + pool_unref(&map->extension_pool); if (array_is_created(&map->keyword_idx_map)) array_free(&map->keyword_idx_map); buffer_free(&map->hdr_copy_buf); diff --git a/src/lib-mail/istream-attachment-extractor.c b/src/lib-mail/istream-attachment-extractor.c index ff62b7b96f..b9ba462b63 100644 --- a/src/lib-mail/istream-attachment-extractor.c +++ b/src/lib-mail/istream-attachment-extractor.c @@ -676,8 +676,7 @@ static void i_stream_attachment_extractor_close(struct iostream_private *stream, message_parser_deinit(&astream->parser, &parts); } hash_format_deinit_free(&astream->set.hash_format); - if (astream->pool != NULL) - pool_unref(&astream->pool); + pool_unref(&astream->pool); if (close_parent) i_stream_close(astream->istream.parent); } diff --git a/src/lib-mail/istream-binary-converter.c b/src/lib-mail/istream-binary-converter.c index 8bccfe3fda..fe8e05d4ef 100644 --- a/src/lib-mail/istream-binary-converter.c +++ b/src/lib-mail/istream-binary-converter.c @@ -277,8 +277,7 @@ static void i_stream_binary_converter_close(struct iostream_private *stream, if (bstream->parser != NULL) { message_parser_deinit(&bstream->parser, &parts); } - if (bstream->pool != NULL) - pool_unref(&bstream->pool); + pool_unref(&bstream->pool); if (close_parent) i_stream_close(bstream->istream.parent); } diff --git a/src/lib-sql/driver-cassandra.c b/src/lib-sql/driver-cassandra.c index 4f81d40e2c..84e1035d31 100644 --- a/src/lib-sql/driver-cassandra.c +++ b/src/lib-sql/driver-cassandra.c @@ -827,8 +827,7 @@ static void driver_cassandra_result_free(struct sql_result *_result) cass_iterator_free(result->iterator); if (result->statement != NULL) cass_statement_free(result->statement); - if (result->row_pool != NULL) - pool_unref(&result->row_pool); + pool_unref(&result->row_pool); i_free(result->query); i_free(result->error); i_free(result); diff --git a/src/lib-sql/driver-sqlpool.c b/src/lib-sql/driver-sqlpool.c index 18b224eac6..b4540a8391 100644 --- a/src/lib-sql/driver-sqlpool.c +++ b/src/lib-sql/driver-sqlpool.c @@ -709,8 +709,7 @@ driver_sqlpool_transaction_free(struct sqlpool_transaction_context *ctx) { if (ctx->commit_request != NULL) sqlpool_request_abort(&ctx->commit_request); - if (ctx->query_pool != NULL) - pool_unref(&ctx->query_pool); + pool_unref(&ctx->query_pool); i_free(ctx); } diff --git a/src/lib-storage/index/dbox-common/dbox-file.c b/src/lib-storage/index/dbox-common/dbox-file.c index 49e74030c7..205c780b1b 100644 --- a/src/lib-storage/index/dbox-common/dbox-file.c +++ b/src/lib-storage/index/dbox-common/dbox-file.c @@ -74,8 +74,7 @@ void dbox_file_free(struct dbox_file *file) { i_assert(file->refcount == 0); - if (file->metadata_pool != NULL) - pool_unref(&file->metadata_pool); + pool_unref(&file->metadata_pool); dbox_file_close(file); i_free(file->primary_path); i_free(file->alt_path); diff --git a/src/lib-storage/index/dbox-single/sdbox-file.c b/src/lib-storage/index/dbox-single/sdbox-file.c index 777a56ef7f..6efaa24209 100644 --- a/src/lib-storage/index/dbox-single/sdbox-file.c +++ b/src/lib-storage/index/dbox-single/sdbox-file.c @@ -66,8 +66,7 @@ void sdbox_file_free(struct dbox_file *file) { struct sdbox_file *sfile = (struct sdbox_file *)file; - if (sfile->attachment_pool != NULL) - pool_unref(&sfile->attachment_pool); + pool_unref(&sfile->attachment_pool); dbox_file_free(file); } diff --git a/src/lib-storage/index/index-search-mime.c b/src/lib-storage/index/index-search-mime.c index ed2ded0a50..76b21f6da5 100644 --- a/src/lib-storage/index/index-search-mime.c +++ b/src/lib-storage/index/index-search-mime.c @@ -586,8 +586,7 @@ int index_search_mime_arg_match(struct mail_search_arg *args, ret = mail_search_args_foreach(args, search_mimepart_arg, &mpctx); - if (mpctx.pool != NULL) - pool_unref(&mpctx.pool); + pool_unref(&mpctx.pool); if (mpctx.buf != NULL) str_free(&mpctx.buf); return ret; diff --git a/src/lib-storage/index/maildir/maildir-uidlist.c b/src/lib-storage/index/maildir/maildir-uidlist.c index deacc1f9c0..533d81888f 100644 --- a/src/lib-storage/index/maildir/maildir-uidlist.c +++ b/src/lib-storage/index/maildir/maildir-uidlist.c @@ -330,8 +330,7 @@ void maildir_uidlist_deinit(struct maildir_uidlist **_uidlist) maildir_uidlist_close(uidlist); hash_table_destroy(&uidlist->files); - if (uidlist->record_pool != NULL) - pool_unref(&uidlist->record_pool); + pool_unref(&uidlist->record_pool); array_free(&uidlist->records); str_free(&uidlist->hdr_extensions); @@ -1992,8 +1991,7 @@ static void maildir_uidlist_swap(struct maildir_uidlist_sync_ctx *ctx) uidlist->files = ctx->files; i_zero(&ctx->files); - if (uidlist->record_pool != NULL) - pool_unref(&uidlist->record_pool); + pool_unref(&uidlist->record_pool); uidlist->record_pool = ctx->record_pool; ctx->record_pool = NULL; @@ -2063,8 +2061,7 @@ int maildir_uidlist_sync_deinit(struct maildir_uidlist_sync_ctx **_ctx, if (hash_table_is_created(ctx->files)) hash_table_destroy(&ctx->files); - if (ctx->record_pool != NULL) - pool_unref(&ctx->record_pool); + pool_unref(&ctx->record_pool); if (array_is_created(&ctx->records)) array_free(&ctx->records); i_free(ctx); diff --git a/src/lib-storage/index/pop3c/pop3c-storage.c b/src/lib-storage/index/pop3c/pop3c-storage.c index 255b511e08..4928939046 100644 --- a/src/lib-storage/index/pop3c/pop3c-storage.c +++ b/src/lib-storage/index/pop3c/pop3c-storage.c @@ -183,8 +183,7 @@ static void pop3c_mailbox_close(struct mailbox *box) { struct pop3c_mailbox *mbox = POP3C_MAILBOX(box); - if (mbox->uidl_pool != NULL) - pool_unref(&mbox->uidl_pool); + pool_unref(&mbox->uidl_pool); i_free_and_null(mbox->msg_uids); i_free_and_null(mbox->msg_sizes); pop3c_client_deinit(&mbox->client); diff --git a/src/lib-storage/list/mailbox-list-fs-iter.c b/src/lib-storage/list/mailbox-list-fs-iter.c index 60705312f9..85fda8e3de 100644 --- a/src/lib-storage/list/mailbox-list-fs-iter.c +++ b/src/lib-storage/list/mailbox-list-fs-iter.c @@ -553,8 +553,7 @@ int fs_list_iter_deinit(struct mailbox_list_iterate_context *_ctx) pool_unref(&dir->pool); } - if (ctx->info_pool != NULL) - pool_unref(&ctx->info_pool); + pool_unref(&ctx->info_pool); pool_unref(&_ctx->pool); return ret; } diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 136b4cb160..211890c117 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -1408,8 +1408,7 @@ void mailbox_free(struct mailbox **_box) DLLIST_REMOVE(&box->storage->mailboxes, box); mail_storage_obj_unref(box->storage); - if (box->metadata_pool != NULL) - pool_unref(&box->metadata_pool); + pool_unref(&box->metadata_pool); pool_unref(&box->pool); } @@ -2084,8 +2083,7 @@ int mailbox_transaction_commit(struct mailbox_transaction_context **t) /* Store changes temporarily so that plugins overriding transaction_commit() can look at them. */ ret = mailbox_transaction_commit_get_changes(t, &changes); - if (changes.pool != NULL) - pool_unref(&changes.pool); + pool_unref(&changes.pool); return ret; } diff --git a/src/lib/env-util.c b/src/lib/env-util.c index e59aa373fb..e6e858380b 100644 --- a/src/lib/env-util.c +++ b/src/lib/env-util.c @@ -156,6 +156,5 @@ char ***env_get_environ_p(void) void env_deinit(void) { - if (env_pool != NULL) - pool_unref(&env_pool); + pool_unref(&env_pool); } diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index 03f0a10235..7686446d1a 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -224,8 +224,7 @@ void client_destroy(struct client *client, const char *reason) return; client->destroyed = TRUE; - if (client->preproxy_pool != NULL) - pool_unref(&client->preproxy_pool); + pool_unref(&client->preproxy_pool); if (!client->login_success && reason != NULL) { const char *extra_reason = diff --git a/src/login-common/login-proxy.c b/src/login-common/login-proxy.c index f448e1368f..8d688d026c 100644 --- a/src/login-common/login-proxy.c +++ b/src/login-common/login-proxy.c @@ -692,8 +692,7 @@ void login_proxy_detach(struct login_proxy *proxy) const unsigned char *data; size_t size; - if (proxy->client->preproxy_pool != NULL) - pool_unref(&proxy->client->preproxy_pool); + pool_unref(&proxy->client->preproxy_pool); i_assert(proxy->client_fd == -1); i_assert(proxy->server_input != NULL); diff --git a/src/plugins/acl/acl-backend-vfile.c b/src/plugins/acl/acl-backend-vfile.c index 5809d09876..7a53e5e175 100644 --- a/src/plugins/acl/acl-backend-vfile.c +++ b/src/plugins/acl/acl-backend-vfile.c @@ -304,8 +304,7 @@ static void acl_backend_vfile_object_deinit(struct acl_object *_aclobj) if (array_is_created(&aclobj->aclobj.rights)) array_free(&aclobj->aclobj.rights); - if (aclobj->aclobj.rights_pool != NULL) - pool_unref(&aclobj->aclobj.rights_pool); + pool_unref(&aclobj->aclobj.rights_pool); i_free(aclobj->aclobj.name); i_free(aclobj); } diff --git a/src/plugins/lazy-expunge/lazy-expunge-plugin.c b/src/plugins/lazy-expunge/lazy-expunge-plugin.c index ce7c02ed86..e0666e49a9 100644 --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c @@ -398,8 +398,7 @@ static void lazy_expunge_transaction_free(struct lazy_expunge_transaction *lt) mailbox_free(<->dest_box); if (hash_table_is_created(lt->guids)) hash_table_destroy(<->guids); - if (lt->pool != NULL) - pool_unref(<->pool); + pool_unref(<->pool); i_free(lt->delayed_errstr); i_free(lt->delayed_internal_errstr); i_free(lt); diff --git a/src/pop3/pop3-client.c b/src/pop3/pop3-client.c index bbfe8cb7df..98ff819a92 100644 --- a/src/pop3/pop3-client.c +++ b/src/pop3/pop3-client.c @@ -605,8 +605,7 @@ static void client_default_destroy(struct client *client, const char *reason) file_dotlock_delete(&client->session_dotlock); timeout_remove(&client->to_session_dotlock_refresh); - if (client->uidl_pool != NULL) - pool_unref(&client->uidl_pool); + pool_unref(&client->uidl_pool); i_free(client->message_sizes); i_free(client->deleted_bitmask); i_free(client->seen_bitmask);