From: Josef 'Jeff' Sipek Date: Mon, 29 Jan 2018 13:41:03 +0000 (-0500) Subject: global: start relying on mailbox_header_lookup_unref(NULL) being a no-op X-Git-Tag: 2.3.9~2386 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ceb8c97c6c9fe0ee7eb544645c6bdb74dfcb519d;p=thirdparty%2Fdovecot%2Fcore.git global: start relying on mailbox_header_lookup_unref(NULL) being a no-op Cleanup performed with the following semantic patch: @@ expression E; @@ - if (E != NULL) { - mailbox_header_lookup_unref(&E); - } + mailbox_header_lookup_unref(&E); --- diff --git a/src/doveadm/doveadm-mail-iter.c b/src/doveadm/doveadm-mail-iter.c index 05d0bf13ae..da03c1f6fa 100644 --- a/src/doveadm/doveadm-mail-iter.c +++ b/src/doveadm/doveadm-mail-iter.c @@ -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; } diff --git a/src/doveadm/dsync/dsync-mailbox-export.c b/src/doveadm/dsync/dsync-mailbox-export.c index 7fd574e198..9cf5e36a4e 100644 --- a/src/doveadm/dsync/dsync-mailbox-export.c +++ b/src/doveadm/dsync/dsync-mailbox-export.c @@ -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); diff --git a/src/imap/imap-fetch.c b/src/imap/imap-fetch.c index e212122582..4df3cd5ee8 100644 --- a/src/imap/imap-fetch.c +++ b/src/imap/imap-fetch.c @@ -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) diff --git a/src/lib-imap-storage/imap-msgpart.c b/src/lib-imap-storage/imap-msgpart.c index 9e38fbf9fa..72375e998f 100644 --- a/src/lib-imap-storage/imap-msgpart.c +++ b/src/lib-imap-storage/imap-msgpart.c @@ -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); } diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index bc2dcc1261..e059297ddc 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -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); diff --git a/src/lib-storage/index/index-search.c b/src/lib-storage/index/index-search.c index b7fac19eb4..ea438083a5 100644 --- a/src/lib-storage/index/index-search.c +++ b/src/lib-storage/index/index-search.c @@ -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; diff --git a/src/plugins/mail-log/mail-log-plugin.c b/src/plugins/mail-log/mail-log-plugin.c index 1df083c55c..f01cd0de70 100644 --- a/src/plugins/mail-log/mail-log-plugin.c +++ b/src/plugins/mail-log/mail-log-plugin.c @@ -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 diff --git a/src/plugins/virtual/virtual-mail.c b/src/plugins/virtual/virtual-mail.c index 1fbe5a361d..e1337c7628 100644 --- a/src/plugins/virtual/virtual-mail.c +++ b/src/plugins/virtual/virtual-mail.c @@ -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;