]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: start relying on mailbox_header_lookup_unref(NULL) being a no-op
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Mon, 29 Jan 2018 13:41:03 +0000 (08:41 -0500)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 31 Jan 2018 11:58:35 +0000 (13:58 +0200)
Cleanup performed with the following semantic patch:

@@
expression E;
@@

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

src/doveadm/doveadm-mail-iter.c
src/doveadm/dsync/dsync-mailbox-export.c
src/imap/imap-fetch.c
src/lib-imap-storage/imap-msgpart.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-search.c
src/plugins/mail-log/mail-log-plugin.c
src/plugins/virtual/virtual-mail.c

index 05d0bf13ae5a9803420815e7af192cc7d1ce8007..da03c1f6faf5cbec8dda6950939bd2a7d5241699 100644 (file)
@@ -61,8 +61,7 @@ int doveadm_mail_iter_init(struct doveadm_mail_cmd_context *ctx,
        iter->t = mailbox_transaction_begin(iter->box, 0, ctx->cmd->name);
        iter->search_ctx = mailbox_search_init(iter->t, search_args, NULL,
                                               wanted_fields, headers_ctx);
-       if (headers_ctx != NULL)
-               mailbox_header_lookup_unref(&headers_ctx);
+       mailbox_header_lookup_unref(&headers_ctx);
        *iter_r = iter;
        return 0;
 }
index 7fd574e19885ca82a497e2443397e861ff0d80c3..9cf5e36a4e30f486be56ca4cb863c54f70e84d35 100644 (file)
@@ -938,8 +938,7 @@ int dsync_mailbox_export_deinit(struct dsync_mailbox_exporter **_exporter,
                (void)mailbox_attribute_iter_deinit(&exporter->attr_iter);
        dsync_mailbox_export_body_search_deinit(exporter);
        (void)mailbox_transaction_commit(&exporter->trans);
-       if (exporter->wanted_headers != NULL)
-               mailbox_header_lookup_unref(&exporter->wanted_headers);
+       mailbox_header_lookup_unref(&exporter->wanted_headers);
 
        i_stream_unref(&exporter->attr.value_stream);
        hash_table_destroy(&exporter->export_guids);
index e21212258233fc0a0db8253c910a35e47722a356..4df3cd5ee88677670999b1f12ec5b719dbf8a1b8 100644 (file)
@@ -408,8 +408,7 @@ void imap_fetch_begin(struct imap_fetch_context *ctx, struct mailbox *box,
        ctx->state.cur_str = str_new(default_pool, 8192);
        ctx->state.fetching = TRUE;
 
-       if (wanted_headers != NULL)
-               mailbox_header_lookup_unref(&wanted_headers);
+       mailbox_header_lookup_unref(&wanted_headers);
 }
 
 static int imap_fetch_flush_buffer(struct imap_fetch_context *ctx)
index 9e38fbf9fa7ec95e28dc9268f5900a916286ead0..72375e998fc48bc283fd73573af369ffceda9673 100644 (file)
@@ -847,6 +847,5 @@ int imap_msgpart_bodypartstructure(struct mail *mail,
 
 void imap_msgpart_close_mailbox(struct imap_msgpart *msgpart)
 {
-       if (msgpart->header_ctx != NULL)
-               mailbox_header_lookup_unref(&msgpart->header_ctx);
+       mailbox_header_lookup_unref(&msgpart->header_ctx);
 }
index bc2dcc12615efc946987522f30a333d8d57ef3ff..e059297ddc51db8b73f33e8beb1985d935188b48 100644 (file)
@@ -1715,8 +1715,7 @@ void index_mail_close(struct mail *_mail)
           memory until this point. */
        mail_cache_close_mail(_mail->transaction->cache_trans, _mail->seq);
 
-       if (mail->data.wanted_headers != NULL)
-               mailbox_header_lookup_unref(&mail->data.wanted_headers);
+       mailbox_header_lookup_unref(&mail->data.wanted_headers);
        if (!mail->freeing)
                index_mail_reset_data(mail);
 }
@@ -2075,8 +2074,7 @@ void index_mail_free(struct mail *_mail)
        if (array_is_created(&mail->header_match_lines))
                array_free(&mail->header_match_lines);
 
-       if (headers_ctx != NULL)
-               mailbox_header_lookup_unref(&headers_ctx);
+       mailbox_header_lookup_unref(&headers_ctx);
        event_unref(&_mail->event);
        pool_unref(&mail->mail.data_pool);
        pool_unref(&mail->mail.pool);
index b7fac19eb4f067a494d573aa93b67bc19bffcb4f..ea438083a54dbf63330a5f73d380953af2eb535d 100644 (file)
@@ -797,8 +797,7 @@ static int search_arg_match_text(struct mail_search_arg *args,
                        }
                }
        }
-       if (headers_ctx != NULL)
-               mailbox_header_lookup_unref(&headers_ctx);
+       mailbox_header_lookup_unref(&headers_ctx);
 
        if (failed) {
                /* opening mail failed. maybe because of lookup_abort.
@@ -1355,8 +1354,7 @@ int index_storage_search_deinit(struct mail_search_context *_ctx)
        (void)mail_search_args_foreach(ctx->mail_ctx.args->args,
                                       search_arg_deinit, ctx);
 
-       if (ctx->mail_ctx.wanted_headers != NULL)
-               mailbox_header_lookup_unref(&ctx->mail_ctx.wanted_headers);
+       mailbox_header_lookup_unref(&ctx->mail_ctx.wanted_headers);
        if (ctx->mail_ctx.sort_program != NULL) {
                if (index_sort_program_deinit(&ctx->mail_ctx.sort_program) < 0)
                        ret = -1;
index 1df083c55c1727c72479e5b2f28c5de804cd9135..f01cd0de70080e75242b1eb45dfe70e46cc1dc72 100644 (file)
@@ -231,8 +231,7 @@ mail_log_update_wanted_fields(struct mail *mail, enum mail_log_field fields)
                wanted_fields |= MAIL_FETCH_VIRTUAL_SIZE;
 
        mail_add_temp_wanted_fields(mail, wanted_fields, wanted_headers);
-       if (wanted_headers != NULL)
-               mailbox_header_lookup_unref(&wanted_headers);
+       mailbox_header_lookup_unref(&wanted_headers);
 }
 
 static void
index 1fbe5a361df52e6ca6d98eb77fd11f71433db045..e1337c76280dcc03f23345b15f6804a5735f989b 100644 (file)
@@ -81,8 +81,7 @@ static void virtual_mail_free(struct mail *mail)
                mail_free(&mails[i]);
        array_free(&vmail->backend_mails);
 
-       if (vmail->wanted_headers != NULL)
-               mailbox_header_lookup_unref(&vmail->wanted_headers);
+       mailbox_header_lookup_unref(&vmail->wanted_headers);
 
        pool_unref(&vmail->imail.mail.data_pool);
        pool_unref(&vmail->imail.mail.pool);
@@ -163,8 +162,7 @@ virtual_mail_set_backend_mail(struct mail *mail,
                                           vmail->wanted_headers->name);
        vmail->cur_backend_mail =
                mail_alloc(backend_trans, vmail->wanted_fields, backend_headers);
-       if (backend_headers != NULL)
-               mailbox_header_lookup_unref(&backend_headers);
+       mailbox_header_lookup_unref(&backend_headers);
 
        backend_pmail = (struct mail_private *)vmail->cur_backend_mail;
        backend_pmail->vmail = mail;