]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: start relying on pool_unref(NULL) being a no-op
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Tue, 19 Sep 2017 10:25:23 +0000 (13:25 +0300)
committerJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Wed, 20 Sep 2017 09:29:06 +0000 (12:29 +0300)
Cleanup performed with the following semantic patch:

@@
expression E;
@@

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

24 files changed:
src/auth/db-passwd-file.c
src/doveadm/dsync/dsync-brain.c
src/doveadm/dsync/dsync-ibc-pipe.c
src/lib-dict/dict-sql.c
src/lib-fts/fts-language.c
src/lib-http/http-message-parser.c
src/lib-index/mail-index-map.c
src/lib-mail/istream-attachment-extractor.c
src/lib-mail/istream-binary-converter.c
src/lib-sql/driver-cassandra.c
src/lib-sql/driver-sqlpool.c
src/lib-storage/index/dbox-common/dbox-file.c
src/lib-storage/index/dbox-single/sdbox-file.c
src/lib-storage/index/index-search-mime.c
src/lib-storage/index/maildir/maildir-uidlist.c
src/lib-storage/index/pop3c/pop3c-storage.c
src/lib-storage/list/mailbox-list-fs-iter.c
src/lib-storage/mail-storage.c
src/lib/env-util.c
src/login-common/client-common.c
src/login-common/login-proxy.c
src/plugins/acl/acl-backend-vfile.c
src/plugins/lazy-expunge/lazy-expunge-plugin.c
src/pop3/pop3-client.c

index 037a76bc9a6782de3ba662626f6375fac33ffec3..8aa3abb2ea2c1d83b62a91e1f4f3921c4b7b358b 100644 (file)
@@ -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)
index 29a6cc16054c3570c70e782ec1766e893b0142f2..505259f42e6adac876bb70a7924f2912471483b0 100644 (file)
@@ -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 */
index b86b3950c46ce62b4f415e1029a17598d3a7db36..45402c1d402f77a6581df8a04d82c441435371a8 100644 (file)
@@ -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);
index 9e57732f5537392fbd4909552d51b20be78b2540..f36e46d47b1022dae8fb372524fc16280c2ace48 100644 (file)
@@ -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);
index 4208551b909a0e4c4f6870f4e4519e90fad0f307..a68a8fc7345e814073977483aebfa7f8f2109602 100644 (file)
@@ -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)
index 3c08dd3308bdc214724686ef33b7f65941771708..c789ac2d3918ada01940a1fb8e7f574657a09f15 100644 (file)
@@ -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;
index 667d7d712e64d691f26ccb908a7015e8feff38d6..7ee80c8a9e36bc7cf78d669e88bbd9e104acba15 100644 (file)
@@ -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);
index ff62b7b96f815893da62801e7de2111dc96eda45..b9ba462b63fef84ecc7669d7c980e7558e196716 100644 (file)
@@ -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);
 }
index 8bccfe3fda088d31aa6e4d120eec2cfcb1dca792..fe8e05d4efa0003aeacb908c01cce09eca6428fb 100644 (file)
@@ -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);
 }
index 4f81d40e2c16828a8183f9656748084bbe166078..84e1035d31609ebca45221e8e0bb86b4f9220d27 100644 (file)
@@ -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);
index 18b224eac6461698e65b605a91f9fff39e11c51a..b4540a8391a472199e17fb9dd1f57c3d53bb4861 100644 (file)
@@ -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);
 }
 
index 49e74030c7fe24be2d6c99722a8c14bd79903567..205c780b1b1280e6357549840567e283d4801a51 100644 (file)
@@ -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);
index 777a56ef7fd1d700801cc60fae42db6f84f4554f..6efaa2420957d64b91ef35630bf2368671477e17 100644 (file)
@@ -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);
 }
 
index ed2ded0a50926cd5c35289c501021f58bf537634..76b21f6da5c8f6ac60270860e990ff11ee2997fd 100644 (file)
@@ -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;
index deacc1f9c003c0ce30a600774df04581a5fde820..533d81888f23c9eb1c191685a760a92e622a407a 100644 (file)
@@ -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);
index 255b511e0882b0abff85c6612652ec13ee4bf63b..4928939046fa531667ec3ca125c168564d425637 100644 (file)
@@ -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);
index 60705312f9da8690b434ed07328f26954c250ba2..85fda8e3de4b5d8738deaebb1aaff22d35933720 100644 (file)
@@ -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;
 }
index 136b4cb160a1722e2c4d097b4e5c841daaaf5a84..211890c1177283575fb2da9905a1f7bd84a92492 100644 (file)
@@ -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;
 }
 
index e59aa373fb2f186f27d5e363c5efc6ffac105ef7..e6e858380b321e833b7576a7161827ca7f94aeb4 100644 (file)
@@ -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);
 }
index 03f0a10235d288c34f8a759b03085b2e18651b51..7686446d1abc727a3073dfda2c419c9eaf48fc0c 100644 (file)
@@ -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 =
index f448e1368f8f27c5c9cb0f2539ef1215e06258b9..8d688d026cf167ef3a141a076e1aa734db5e7976 100644 (file)
@@ -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);
index 5809d098766d5d88614d239c6276e6ab9fb1598d..7a53e5e175ce6c4a570fc7cefd1677c496c194c8 100644 (file)
@@ -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);
 }
index ce7c02ed868a0420bda9f6b05f83dc4fce37f95b..e0666e49a937f5ba7dee3778fc28a37300d96202 100644 (file)
@@ -398,8 +398,7 @@ static void lazy_expunge_transaction_free(struct lazy_expunge_transaction *lt)
                mailbox_free(&lt->dest_box);
        if (hash_table_is_created(lt->guids))
                hash_table_destroy(&lt->guids);
-       if (lt->pool != NULL)
-               pool_unref(&lt->pool);
+       pool_unref(&lt->pool);
        i_free(lt->delayed_errstr);
        i_free(lt->delayed_internal_errstr);
        i_free(lt);
index bbfe8cb7dfb4c079a55e72bdf0125e5c6c9ee60a..98ff819a92ab6972cc144e0f5410ae80d3e04ec7 100644 (file)
@@ -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);