From: Josef 'Jeff' Sipek Date: Tue, 19 Sep 2017 10:19:36 +0000 (+0300) Subject: global: start relying on [io]_stream_unref(NULL) being a no-op X-Git-Tag: 2.3.0.rc1~980 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=204ee6ed414f5e4eeb6f6c10763b55daf56f11ac;p=thirdparty%2Fdovecot%2Fcore.git global: start relying on [io]_stream_unref(NULL) being a no-op Cleanup performed with the following semantic patch: @@ expression E; @@ - if (E != NULL) { - i_stream_unref(&E); - } + i_stream_unref(&E); @@ expression E; @@ - if (E != NULL) { - o_stream_unref(&E); - } + o_stream_unref(&E); --- diff --git a/src/auth/auth-master-connection.c b/src/auth/auth-master-connection.c index eadc8431c3..7f3d7f36f6 100644 --- a/src/auth/auth-master-connection.c +++ b/src/auth/auth-master-connection.c @@ -814,10 +814,8 @@ void auth_master_connection_unref(struct auth_master_connection **_conn) if (--conn->refcount > 0) return; - if (conn->input != NULL) - i_stream_unref(&conn->input); - if (conn->output != NULL) - o_stream_unref(&conn->output); + i_stream_unref(&conn->input); + o_stream_unref(&conn->output); i_free(conn->path); i_free(conn); diff --git a/src/auth/auth-postfix-connection.c b/src/auth/auth-postfix-connection.c index 18592e5536..9ab0adeab7 100644 --- a/src/auth/auth-postfix-connection.c +++ b/src/auth/auth-postfix-connection.c @@ -229,10 +229,8 @@ auth_postfix_connection_unref(struct auth_postfix_connection **_conn) if (--conn->refcount > 0) return; - if (conn->input != NULL) - i_stream_unref(&conn->input); - if (conn->output != NULL) - o_stream_unref(&conn->output); + i_stream_unref(&conn->input); + o_stream_unref(&conn->output); i_free(conn); } diff --git a/src/doveadm/doveadm-mail.c b/src/doveadm/doveadm-mail.c index affbfa0afc..ccf644874d 100644 --- a/src/doveadm/doveadm-mail.c +++ b/src/doveadm/doveadm-mail.c @@ -645,10 +645,8 @@ doveadm_mail_cmd_exec(struct doveadm_mail_cmd_context *ctx, static void doveadm_mail_cmd_free(struct doveadm_mail_cmd_context *ctx) { - if (ctx->users_list_input != NULL) - i_stream_unref(&ctx->users_list_input); - if (ctx->cmd_input != NULL) - i_stream_unref(&ctx->cmd_input); + i_stream_unref(&ctx->users_list_input); + i_stream_unref(&ctx->cmd_input); pool_unref(&ctx->pool); } diff --git a/src/doveadm/dsync/dsync-brain-mails.c b/src/doveadm/dsync/dsync-brain-mails.c index 44e53038c6..8a14f3b241 100644 --- a/src/doveadm/dsync/dsync-brain-mails.c +++ b/src/doveadm/dsync/dsync-brain-mails.c @@ -98,8 +98,7 @@ static bool dsync_brain_recv_mailbox_attribute(struct dsync_brain *brain) if (dsync_mailbox_import_attribute(brain->box_importer, attr) < 0) brain->failed = TRUE; input = attr->value_stream; - if (input != NULL) - i_stream_unref(&input); + i_stream_unref(&input); return TRUE; } @@ -309,8 +308,7 @@ static bool dsync_brain_recv_mail(struct dsync_brain *brain) } if (dsync_mailbox_import_mail(brain->box_importer, mail) < 0) brain->failed = TRUE; - if (mail->input != NULL) - i_stream_unref(&mail->input); + i_stream_unref(&mail->input); return TRUE; } diff --git a/src/doveadm/dsync/dsync-mailbox-export.c b/src/doveadm/dsync/dsync-mailbox-export.c index 319d9ffe95..cb02deba3d 100644 --- a/src/doveadm/dsync/dsync-mailbox-export.c +++ b/src/doveadm/dsync/dsync-mailbox-export.c @@ -566,8 +566,7 @@ dsync_mailbox_export_iter_next_nonexistent_attr(struct dsync_mailbox_exporter *e break; } if ((value.flags & MAIL_ATTRIBUTE_VALUE_FLAG_READONLY) != 0) { - if (value.value_stream != NULL) - i_stream_unref(&value.value_stream); + i_stream_unref(&value.value_stream); continue; } @@ -680,8 +679,7 @@ int dsync_mailbox_export_next_attr(struct dsync_mailbox_exporter *exporter, if (exporter->error != NULL) return -1; - if (exporter->attr.value_stream != NULL) - i_stream_unref(&exporter->attr.value_stream); + i_stream_unref(&exporter->attr.value_stream); if (exporter->attr_iter != NULL) { ret = dsync_mailbox_export_iter_next_attr(exporter); @@ -935,8 +933,7 @@ int dsync_mailbox_export_deinit(struct dsync_mailbox_exporter **_exporter, if (exporter->wanted_headers != NULL) mailbox_header_lookup_unref(&exporter->wanted_headers); - if (exporter->attr.value_stream != NULL) - i_stream_unref(&exporter->attr.value_stream); + i_stream_unref(&exporter->attr.value_stream); hash_table_destroy(&exporter->export_guids); hash_table_destroy(&exporter->changes); diff --git a/src/imap/cmd-append.c b/src/imap/cmd-append.c index d9d2037d3b..f55d43bdd7 100644 --- a/src/imap/cmd-append.c +++ b/src/imap/cmd-append.c @@ -140,10 +140,8 @@ static void cmd_append_finish(struct cmd_append_context *ctx) o_stream_set_flush_callback(ctx->client->output, client_output, ctx->client); - if (ctx->litinput != NULL) - i_stream_unref(&ctx->litinput); - if (ctx->input != NULL) - i_stream_unref(&ctx->input); + i_stream_unref(&ctx->litinput); + i_stream_unref(&ctx->input); if (ctx->save_ctx != NULL) mailbox_save_cancel(&ctx->save_ctx); if (ctx->t != NULL) diff --git a/src/imap/cmd-getmetadata.c b/src/imap/cmd-getmetadata.c index 1b8638a06f..a18db8d63f 100644 --- a/src/imap/cmd-getmetadata.c +++ b/src/imap/cmd-getmetadata.c @@ -190,8 +190,7 @@ static void cmd_getmetadata_send_entry(struct imap_getmetadata_context *ctx, skip this entry */ if (ctx->largest_seen_size < value_len) ctx->largest_seen_size = value_len; - if (value.value_stream != NULL) - i_stream_unref(&value.value_stream); + i_stream_unref(&value.value_stream); return; } diff --git a/src/imap/cmd-urlfetch.c b/src/imap/cmd-urlfetch.c index 6509038974..5fc212796d 100644 --- a/src/imap/cmd-urlfetch.c +++ b/src/imap/cmd-urlfetch.c @@ -40,8 +40,7 @@ static void cmd_urlfetch_finish(struct client_command_context *cmd) return; ctx->finished = TRUE; - if (ctx->input != NULL) - i_stream_unref(&ctx->input); + i_stream_unref(&ctx->input); if (ctx->ufetch != NULL) imap_urlauth_fetch_deinit(&ctx->ufetch); diff --git a/src/imap/imap-fetch.c b/src/imap/imap-fetch.c index e72284a36f..8bd2dac7cc 100644 --- a/src/imap/imap-fetch.c +++ b/src/imap/imap-fetch.c @@ -670,8 +670,7 @@ int imap_fetch_end(struct imap_fetch_context *ctx) if (state->cur_str != NULL) str_free(&state->cur_str); - if (state->cur_input != NULL) - i_stream_unref(&state->cur_input); + i_stream_unref(&state->cur_input); if (state->search_ctx != NULL) { if (mailbox_search_deinit(&state->search_ctx) < 0) diff --git a/src/lib-fs/fs-metawrap.c b/src/lib-fs/fs-metawrap.c index 9f95cc26e3..ae99da3f58 100644 --- a/src/lib-fs/fs-metawrap.c +++ b/src/lib-fs/fs-metawrap.c @@ -143,8 +143,7 @@ static void fs_metawrap_file_close(struct fs_file *_file) { struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; - if (file->input != NULL) - i_stream_unref(&file->input); + i_stream_unref(&file->input); if (file->super_read != NULL) fs_file_close(file->super_read); if (_file->parent != NULL) diff --git a/src/lib-fs/fs-sis.c b/src/lib-fs/fs-sis.c index a1e94b971b..5e2d431df3 100644 --- a/src/lib-fs/fs-sis.c +++ b/src/lib-fs/fs-sis.c @@ -135,8 +135,7 @@ static void fs_sis_file_close(struct fs_file *_file) { struct sis_fs_file *file = (struct sis_fs_file *)_file; - if (file->hash_input != NULL) - i_stream_unref(&file->hash_input); + i_stream_unref(&file->hash_input); fs_file_close(file->hash_file); fs_file_close(_file->parent); } diff --git a/src/lib-fs/test-fs-metawrap.c b/src/lib-fs/test-fs-metawrap.c index 38f322aa0d..0739953bfd 100644 --- a/src/lib-fs/test-fs-metawrap.c +++ b/src/lib-fs/test-fs-metawrap.c @@ -38,8 +38,7 @@ static void test_fs_metawrap_stat(void) test_assert_idx(fs_stat(file, &st) == 0 && st.st_size == 20, i); - if (input != NULL) - i_stream_unref(&input); + i_stream_unref(&input); fs_file_deinit(&file); } fs_deinit(&fs); diff --git a/src/lib-http/http-client-request.c b/src/lib-http/http-client-request.c index 4dadbcb26e..a49ce510e9 100644 --- a/src/lib-http/http-client-request.c +++ b/src/lib-http/http-client-request.c @@ -265,10 +265,8 @@ bool http_client_request_unref(struct http_client_request **_req) if (req->delayed_error != NULL) http_client_remove_request_error(req->client, req); - if (req->payload_input != NULL) - i_stream_unref(&req->payload_input); - if (req->payload_output != NULL) - o_stream_unref(&req->payload_output); + i_stream_unref(&req->payload_input); + o_stream_unref(&req->payload_output); if (req->headers != NULL) str_free(&req->headers); pool_unref(&req->pool); @@ -1287,8 +1285,7 @@ bool http_client_request_callback(struct http_client_request *req, return FALSE; } else { /* release payload early (prevents server/client deadlock in proxy) */ - if (req->payload_input != NULL) - i_stream_unref(&req->payload_input); + i_stream_unref(&req->payload_input); } } return TRUE; @@ -1465,8 +1462,7 @@ void http_client_request_redirect(struct http_client_request *req, } /* drop payload output stream from previous attempt */ - if (req->payload_output != NULL) - o_stream_unref(&req->payload_output); + o_stream_unref(&req->payload_output); target = http_url_create_target(url); @@ -1496,8 +1492,7 @@ void http_client_request_redirect(struct http_client_request *req, req->method = p_strdup(req->pool, "GET"); /* drop payload */ - if (req->payload_input != NULL) - i_stream_unref(&req->payload_input); + i_stream_unref(&req->payload_input); req->payload_size = 0; req->payload_offset = 0; } @@ -1527,8 +1522,7 @@ void http_client_request_resubmit(struct http_client_request *req) } /* drop payload output stream from previous attempt */ - if (req->payload_output != NULL) - o_stream_unref(&req->payload_output); + o_stream_unref(&req->payload_output); req->peer = NULL; req->state = HTTP_REQUEST_STATE_QUEUED; diff --git a/src/lib-http/http-message-parser.c b/src/lib-http/http-message-parser.c index 388763d156..3c08dd3308 100644 --- a/src/lib-http/http-message-parser.c +++ b/src/lib-http/http-message-parser.c @@ -33,10 +33,8 @@ void http_message_parser_deinit(struct http_message_parser *parser) http_header_parser_deinit(&parser->header_parser); if (parser->msg.pool != NULL) pool_unref(&parser->msg.pool); - if (parser->payload != NULL) - i_stream_unref(&parser->payload); - if (parser->input != NULL) - i_stream_unref(&parser->input); + i_stream_unref(&parser->payload); + i_stream_unref(&parser->input); } void http_message_parser_restart(struct http_message_parser *parser, diff --git a/src/lib-http/http-server-response.c b/src/lib-http/http-server-response.c index f2ecff488a..9b0f2e8447 100644 --- a/src/lib-http/http-server-response.c +++ b/src/lib-http/http-server-response.c @@ -77,10 +77,8 @@ void http_server_response_free(struct http_server_response *resp) i_assert(!resp->payload_blocking); - if (resp->payload_input != NULL) - i_stream_unref(&resp->payload_input); - if (resp->payload_output != NULL) - o_stream_unref(&resp->payload_output); + i_stream_unref(&resp->payload_input); + o_stream_unref(&resp->payload_output); str_free(&resp->headers); } diff --git a/src/lib-http/test-http-payload.c b/src/lib-http/test-http-payload.c index 06abb21f18..555003aff2 100644 --- a/src/lib-http/test-http-payload.c +++ b/src/lib-http/test-http-payload.c @@ -648,10 +648,8 @@ static void test_client_request_destroy(struct test_client_request *tcreq) { io_remove(&tcreq->io); - if (tcreq->payload != NULL) - i_stream_unref(&tcreq->payload); - if (tcreq->file != NULL) - i_stream_unref(&tcreq->file); + i_stream_unref(&tcreq->payload); + i_stream_unref(&tcreq->file); DLLIST_REMOVE(&client_requests, tcreq); i_free(tcreq); diff --git a/src/lib-imap-client/test-imapc-client.c b/src/lib-imap-client/test-imapc-client.c index 261469e6ff..257a3ef2b2 100644 --- a/src/lib-imap-client/test-imapc-client.c +++ b/src/lib-imap-client/test-imapc-client.c @@ -87,10 +87,8 @@ test_server_wait_connection(struct test_server *server, bool send_banner) static void test_server_disconnect(struct test_server *server) { - if (server->input != NULL) - i_stream_unref(&server->input); - if (server->output != NULL) - o_stream_unref(&server->output); + i_stream_unref(&server->input); + o_stream_unref(&server->output); i_close_fd(&server->fd); } diff --git a/src/lib-imap-storage/imap-msgpart-url.c b/src/lib-imap-storage/imap-msgpart-url.c index eae5acb45d..a8dd6155fe 100644 --- a/src/lib-imap-storage/imap-msgpart-url.c +++ b/src/lib-imap-storage/imap-msgpart-url.c @@ -274,8 +274,7 @@ void imap_msgpart_url_free(struct imap_msgpart_url **_mpurl) *_mpurl = NULL; - if (mpurl->result.input != NULL) - i_stream_unref(&mpurl->result.input); + i_stream_unref(&mpurl->result.input); if (mpurl->part != NULL) imap_msgpart_free(&mpurl->part); if (mpurl->mail != NULL) diff --git a/src/lib-imap-urlauth/imap-urlauth-fetch.c b/src/lib-imap-urlauth/imap-urlauth-fetch.c index d5b395027e..9087afcceb 100644 --- a/src/lib-imap-urlauth/imap-urlauth-fetch.c +++ b/src/lib-imap-urlauth/imap-urlauth-fetch.c @@ -65,8 +65,7 @@ static void imap_urlauth_fetch_abort_local(struct imap_urlauth_fetch *ufetch) i_free_and_null(ufetch->pending_reply.url); i_free_and_null(ufetch->pending_reply.bodypartstruct); i_free_and_null(ufetch->pending_reply.error); - if (ufetch->pending_reply.input != NULL) - i_stream_unref(&ufetch->pending_reply.input); + i_stream_unref(&ufetch->pending_reply.input); url = ufetch->local_urls_head; for (; url != NULL; url = url_next) { diff --git a/src/lib-index/mail-index-strmap.c b/src/lib-index/mail-index-strmap.c index a8b7c2afad..63958db554 100644 --- a/src/lib-index/mail-index-strmap.c +++ b/src/lib-index/mail-index-strmap.c @@ -148,8 +148,7 @@ static void mail_index_strmap_close(struct mail_index_strmap *strmap) mail_index_strmap_set_syscall_error(strmap, "close()"); strmap->fd = -1; } - if (strmap->input != NULL) - i_stream_unref(&strmap->input); + i_stream_unref(&strmap->input); } void mail_index_strmap_deinit(struct mail_index_strmap **_strmap) diff --git a/src/lib-mail/istream-attachment-connector.c b/src/lib-mail/istream-attachment-connector.c index bcccf2ac32..46e3a55717 100644 --- a/src/lib-mail/istream-attachment-connector.c +++ b/src/lib-mail/istream-attachment-connector.c @@ -100,8 +100,7 @@ istream_attachment_connector_free(struct istream_attachment_connector *conn) array_foreach(&conn->streams, streamp) { stream = *streamp; - if (stream != NULL) - i_stream_unref(&stream); + i_stream_unref(&stream); } i_stream_unref(&conn->base_input); pool_unref(&conn->pool); diff --git a/src/lib-program-client/program-client.c b/src/lib-program-client/program-client.c index 788d478ba8..1231178e8e 100644 --- a/src/lib-program-client/program-client.c +++ b/src/lib-program-client/program-client.c @@ -108,8 +108,7 @@ void program_client_disconnect_extra_fds(struct program_client *pclient) efds = array_get_modifiable(&pclient->extra_fds, &count); for(i = 0; i < count; i++) { - if (efds[i].input != NULL) - i_stream_unref(&efds[i].input); + i_stream_unref(&efds[i].input); io_remove(&efds[i].io); if (efds[i].parent_fd != -1 && close(efds[i].parent_fd) < 0) i_error("close(fd=%d) failed: %m", efds[i].parent_fd); @@ -438,8 +437,7 @@ void program_client_init(struct program_client *pclient, pool_t pool, void program_client_set_input(struct program_client *pclient, struct istream *input) { - if (pclient->input != NULL) - i_stream_unref(&pclient->input); + i_stream_unref(&pclient->input); if (input != NULL) i_stream_ref(input); pclient->input = input; @@ -448,8 +446,7 @@ void program_client_set_input(struct program_client *pclient, void program_client_set_output(struct program_client *pclient, struct ostream *output) { - if (pclient->output != NULL) - o_stream_unref(&pclient->output); + o_stream_unref(&pclient->output); if (output != NULL) o_stream_ref(output); pclient->output = output; @@ -460,8 +457,7 @@ void program_client_set_output(struct program_client *pclient, void program_client_set_output_seekable(struct program_client *pclient, const char *temp_prefix) { - if (pclient->output != NULL) - o_stream_unref(&pclient->output); + o_stream_unref(&pclient->output); pclient->temp_prefix = i_strdup(temp_prefix); pclient->output_seekable = TRUE; } @@ -568,18 +564,12 @@ void program_client_destroy(struct program_client **_pclient) i_assert(pclient->callback == NULL); - if (pclient->input != NULL) - i_stream_unref(&pclient->input); - if (pclient->dot_input != NULL) - i_stream_unref(&pclient->dot_input); - if (pclient->program_input != NULL) - i_stream_unref(&pclient->program_input); - if (pclient->program_output != NULL) - o_stream_unref(&pclient->program_output); - if (pclient->output != NULL) - o_stream_unref(&pclient->output); - if (pclient->seekable_output != NULL) - i_stream_unref(&pclient->seekable_output); + i_stream_unref(&pclient->input); + i_stream_unref(&pclient->dot_input); + i_stream_unref(&pclient->program_input); + o_stream_unref(&pclient->program_output); + o_stream_unref(&pclient->output); + i_stream_unref(&pclient->seekable_output); io_remove(&pclient->io); i_free(pclient->temp_prefix); diff --git a/src/lib-program-client/test-program-client-net.c b/src/lib-program-client/test-program-client-net.c index d2048603a6..0a47a902fb 100644 --- a/src/lib-program-client/test-program-client-net.c +++ b/src/lib-program-client/test-program-client-net.c @@ -88,10 +88,8 @@ void test_program_client_destroy(struct test_client **_client) io_remove(&client->io); o_stream_unref(&client->out); i_stream_unref(&client->in); - if (client->os_body != NULL) - o_stream_unref(&client->os_body); - if (client->body != NULL) - i_stream_unref(&client->body); + o_stream_unref(&client->os_body); + i_stream_unref(&client->body); close(client->fd); pool_unref(&client->pool); test_globals.client = NULL; diff --git a/src/lib-program-client/test-program-client-unix.c b/src/lib-program-client/test-program-client-unix.c index 2a9fd1fa8a..36699ab562 100644 --- a/src/lib-program-client/test-program-client-unix.c +++ b/src/lib-program-client/test-program-client-unix.c @@ -71,10 +71,8 @@ void test_program_client_destroy(struct test_client **_client) io_remove(&client->io); o_stream_unref(&client->out); i_stream_unref(&client->in); - if (client->os_body != NULL) - o_stream_unref(&client->os_body); - if (client->body != NULL) - i_stream_unref(&client->body); + o_stream_unref(&client->os_body); + i_stream_unref(&client->body); i_close_fd(&client->fd); pool_unref(&client->pool); test_globals.client = NULL; diff --git a/src/lib-smtp/lmtp-client.c b/src/lib-smtp/lmtp-client.c index 02a30f6cef..ebf5a4b895 100644 --- a/src/lib-smtp/lmtp-client.c +++ b/src/lib-smtp/lmtp-client.c @@ -128,8 +128,7 @@ void lmtp_client_close(struct lmtp_client *client) net_disconnect(client->fd); client->fd = -1; } - if (client->data_input != NULL) - i_stream_unref(&client->data_input); + i_stream_unref(&client->data_input); client->output_finished = TRUE; if (!client->finish_called) { @@ -154,10 +153,8 @@ static void lmtp_client_unref(struct lmtp_client **_client) return; i_assert(client->finish_called); - if (client->input != NULL) - i_stream_unref(&client->input); - if (client->output != NULL) - o_stream_unref(&client->output); + i_stream_unref(&client->input); + o_stream_unref(&client->output); str_free(&client->input_multiline); pool_unref(&client->pool); } diff --git a/src/lib-smtp/test-smtp-submit.c b/src/lib-smtp/test-smtp-submit.c index e7c11ab861..8ef4f7bef7 100644 --- a/src/lib-smtp/test-smtp-submit.c +++ b/src/lib-smtp/test-smtp-submit.c @@ -1401,10 +1401,8 @@ test_successful_delivery_deinit(struct server_connection *conn) { struct _successful_delivery_server *ctx = (struct _successful_delivery_server *)conn->context; - if (ctx->dot_input != NULL) - i_stream_unref(&ctx->dot_input); - if (ctx->file != NULL) - o_stream_unref(&ctx->file); + i_stream_unref(&ctx->dot_input); + o_stream_unref(&ctx->file); } static void test_server_successful_delivery(unsigned int index) diff --git a/src/lib-storage/index/cydir/cydir-save.c b/src/lib-storage/index/cydir/cydir-save.c index 567e0a78fd..38a8ef1bfd 100644 --- a/src/lib-storage/index/cydir/cydir-save.c +++ b/src/lib-storage/index/cydir/cydir-save.c @@ -209,8 +209,7 @@ int cydir_save_finish(struct mail_save_context *_ctx) index_mail_cache_parse_deinit(_ctx->dest_mail, _ctx->data.received_date, !ctx->failed); - if (ctx->input != NULL) - i_stream_unref(&ctx->input); + i_stream_unref(&ctx->input); index_save_context_free(_ctx); return ctx->failed ? -1 : 0; diff --git a/src/lib-storage/index/dbox-common/dbox-mail.c b/src/lib-storage/index/dbox-common/dbox-mail.c index b10e64796e..0dc31d2530 100644 --- a/src/lib-storage/index/dbox-common/dbox-mail.c +++ b/src/lib-storage/index/dbox-common/dbox-mail.c @@ -307,8 +307,7 @@ int dbox_mail_get_stream(struct mail *_mail, bool get_body ATTR_UNUSED, dbox_file_set_corrupted(mail->open_file, "uid=%u points to broken data at offset=" "%"PRIuUOFF_T, _mail->uid, offset); - if (input != NULL) - i_stream_unref(&input); + i_stream_unref(&input); return -1; } data->stream = input; diff --git a/src/lib-storage/index/imapc/imapc-mail-fetch.c b/src/lib-storage/index/imapc/imapc-mail-fetch.c index d428db146d..a86660355e 100644 --- a/src/lib-storage/index/imapc/imapc-mail-fetch.c +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c @@ -640,14 +640,12 @@ imapc_fetch_stream(struct imapc_mail *mail, if (arg->type == IMAP_ARG_LITERAL_SIZE) { if (!imapc_find_lfile_arg(reply, arg, &fd)) { - if (hdr_stream != NULL) - i_stream_unref(&hdr_stream); + i_stream_unref(&hdr_stream); return; } if ((fd = dup(fd)) == -1) { i_error("dup() failed: %m"); - if (hdr_stream != NULL) - i_stream_unref(&hdr_stream); + i_stream_unref(&hdr_stream); return; } mail->fd = fd; @@ -657,8 +655,7 @@ imapc_fetch_stream(struct imapc_mail *mail, value = NULL; if (value == NULL) { mail_set_expunged(&imail->mail.mail); - if (hdr_stream != NULL) - i_stream_unref(&hdr_stream); + i_stream_unref(&hdr_stream); return; } if (mail->body == NULL) { diff --git a/src/lib-storage/index/imapc/imapc-save.c b/src/lib-storage/index/imapc/imapc-save.c index 65bbc23b65..7d98a3305c 100644 --- a/src/lib-storage/index/imapc/imapc-save.c +++ b/src/lib-storage/index/imapc/imapc-save.c @@ -289,10 +289,8 @@ int imapc_save_finish(struct mail_save_context *_ctx) ctx->failed = TRUE; } - if (_ctx->data.output != NULL) - o_stream_unref(&_ctx->data.output); - if (ctx->input != NULL) - i_stream_unref(&ctx->input); + o_stream_unref(&_ctx->data.output); + i_stream_unref(&ctx->input); if (ctx->fd != -1) { if (close(ctx->fd) < 0) i_error("close(%s) failed: %m", ctx->temp_path); diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 4ec9221422..21e9da7f37 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -1602,8 +1602,7 @@ static void index_mail_close_streams_full(struct index_mail *mail, bool closing) if (mail->data.save_bodystructure_body) mail->data.save_bodystructure_header = TRUE; } - if (data->filter_stream != NULL) - i_stream_unref(&data->filter_stream); + i_stream_unref(&data->filter_stream); if (data->stream != NULL) { struct istream *orig_stream = data->stream; diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index 815684b87d..541ad02611 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -386,8 +386,7 @@ void index_storage_mailbox_close(struct mailbox *box) struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box); mailbox_watch_remove_all(box); - if (box->input != NULL) - i_stream_unref(&box->input); + i_stream_unref(&box->input); if (box->view_pvt != NULL) mail_index_view_close(&box->view_pvt); diff --git a/src/lib-storage/index/pop3c/pop3c-mail.c b/src/lib-storage/index/pop3c/pop3c-mail.c index b0078b2774..191136adbf 100644 --- a/src/lib-storage/index/pop3c/pop3c-mail.c +++ b/src/lib-storage/index/pop3c/pop3c-mail.c @@ -32,8 +32,7 @@ static void pop3c_mail_close(struct mail *_mail) /* wait for any prefetch to finish before closing the mail */ while (pmail->prefetching) pop3c_client_wait_one(mbox->client); - if (pmail->prefetch_stream != NULL) - i_stream_unref(&pmail->prefetch_stream); + i_stream_unref(&pmail->prefetch_stream); index_mail_close(_mail); } diff --git a/src/lib/ioloop.c b/src/lib/ioloop.c index 4e73e5de24..603855559c 100644 --- a/src/lib/ioloop.c +++ b/src/lib/ioloop.c @@ -160,8 +160,7 @@ static void io_remove_full(struct io **_io, bool closed) /* remove io from the ioloop before unreferencing the istream, because a destroyed istream may automatically close the fd. */ - if (istream != NULL) - i_stream_unref(&istream); + i_stream_unref(&istream); } } diff --git a/src/lib/iostream-rawlog.c b/src/lib/iostream-rawlog.c index fcace8e487..7d84d5bdd6 100644 --- a/src/lib/iostream-rawlog.c +++ b/src/lib/iostream-rawlog.c @@ -135,8 +135,7 @@ void iostream_rawlog_write(struct rawlog_iostream *rstream, void iostream_rawlog_close(struct rawlog_iostream *rstream) { - if (rstream->rawlog_output != NULL) - o_stream_unref(&rstream->rawlog_output); + o_stream_unref(&rstream->rawlog_output); if (rstream->buffer != NULL) buffer_free(&rstream->buffer); } diff --git a/src/lib/istream-chain.c b/src/lib/istream-chain.c index 1b6bfc98d4..fbe458a2a6 100644 --- a/src/lib/istream-chain.c +++ b/src/lib/istream-chain.c @@ -103,8 +103,7 @@ static void i_stream_chain_destroy(struct iostream_private *stream) while (link != NULL) { struct istream_chain_link *next = link->next; - if (link->stream != NULL) - i_stream_unref(&link->stream); + i_stream_unref(&link->stream); i_free(link); link = next; } diff --git a/src/lib/istream-seekable.c b/src/lib/istream-seekable.c index 70e11636ce..a8f304abab 100644 --- a/src/lib/istream-seekable.c +++ b/src/lib/istream-seekable.c @@ -56,8 +56,7 @@ static void i_stream_seekable_destroy(struct iostream_private *stream) if (sstream->membuf != NULL) buffer_free(&sstream->membuf); - if (sstream->fd_input != NULL) - i_stream_unref(&sstream->fd_input); + i_stream_unref(&sstream->fd_input); unref_streams(sstream); if (sstream->free_context) diff --git a/src/lib/istream.c b/src/lib/istream.c index ffcf7b640e..eb82c89934 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -61,8 +61,7 @@ void i_stream_unref(struct istream **stream) str_free(&_stream->line_str); } if (!io_stream_unref(&(*stream)->real_stream->iostream)) { - if ((*stream)->real_stream->parent != NULL) - i_stream_unref(&(*stream)->real_stream->parent); + i_stream_unref(&(*stream)->real_stream->parent); io_stream_free(&(*stream)->real_stream->iostream); } *stream = NULL; @@ -768,8 +767,7 @@ static void i_stream_default_destroy(struct iostream_private *stream) struct istream_private *_stream = (struct istream_private *)stream; i_free(_stream->w_buffer); - if (_stream->parent != NULL) - i_stream_unref(&_stream->parent); + i_stream_unref(&_stream->parent); } static void diff --git a/src/lib/ostream.c b/src/lib/ostream.c index abae3b0712..cf4f28d0e1 100644 --- a/src/lib/ostream.c +++ b/src/lib/ostream.c @@ -481,8 +481,7 @@ static void o_stream_default_destroy(struct iostream_private *stream) { struct ostream_private *_stream = (struct ostream_private *)stream; - if (_stream->parent != NULL) - o_stream_unref(&_stream->parent); + o_stream_unref(&_stream->parent); } static void diff --git a/src/lmtp/client.c b/src/lmtp/client.c index 72540cea47..1d9dc3511c 100644 --- a/src/lmtp/client.c +++ b/src/lmtp/client.c @@ -381,8 +381,7 @@ void client_state_reset(struct client *client, const char *state_name) if (client->state.mail_data != NULL) buffer_free(&client->state.mail_data); - if (client->state.mail_data_output != NULL) - o_stream_unref(&client->state.mail_data_output); + o_stream_unref(&client->state.mail_data_output); if (client->state.mail_data_fd != -1) { if (close(client->state.mail_data_fd) < 0) i_error("close(mail data fd) failed: %m"); diff --git a/src/lmtp/lmtp-proxy.c b/src/lmtp/lmtp-proxy.c index 0db4287e41..e9ef775d57 100644 --- a/src/lmtp/lmtp-proxy.c +++ b/src/lmtp/lmtp-proxy.c @@ -102,10 +102,8 @@ void lmtp_proxy_deinit(struct lmtp_proxy **_proxy) *_proxy = NULL; lmtp_proxy_connections_deinit(proxy); - if (proxy->data_input != NULL) - i_stream_unref(&proxy->data_input); - if (proxy->client_output != NULL) - o_stream_unref(&proxy->client_output); + i_stream_unref(&proxy->data_input); + o_stream_unref(&proxy->client_output); timeout_remove(&proxy->to_finish); array_free(&proxy->rcpt_to); array_free(&proxy->connections); @@ -218,8 +216,7 @@ static void lmtp_conn_finish(void *context) conn->finished = TRUE; timeout_remove(&conn->to); - if (conn->data_input != NULL) - i_stream_unref(&conn->data_input); + i_stream_unref(&conn->data_input); lmtp_proxy_try_finish(conn->proxy); } diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index a0a0f51076..03f0a10235 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -337,10 +337,8 @@ bool client_unref(struct client **_client) if (client->ssl_proxy != NULL) ssl_proxy_free(&client->ssl_proxy); - if (client->input != NULL) - i_stream_unref(&client->input); - if (client->output != NULL) - o_stream_unref(&client->output); + i_stream_unref(&client->input); + o_stream_unref(&client->output); i_free(client->proxy_user); i_free(client->proxy_master_user); diff --git a/src/plugins/fs-compress/fs-compress.c b/src/plugins/fs-compress/fs-compress.c index 7bca3d992c..df3b9ffdee 100644 --- a/src/plugins/fs-compress/fs-compress.c +++ b/src/plugins/fs-compress/fs-compress.c @@ -142,8 +142,7 @@ static void fs_compress_file_close(struct fs_file *_file) { struct compress_fs_file *file = (struct compress_fs_file *)_file; - if (file->input != NULL) - i_stream_unref(&file->input); + i_stream_unref(&file->input); if (file->super_read != NULL) fs_file_close(file->super_read); if (_file->parent != NULL) diff --git a/src/plugins/fts/fts-expunge-log.c b/src/plugins/fts/fts-expunge-log.c index 56f9cb915c..35854901ce 100644 --- a/src/plugins/fts/fts-expunge-log.c +++ b/src/plugins/fts/fts-expunge-log.c @@ -520,8 +520,7 @@ int fts_expunge_log_read_end(struct fts_expunge_log_read_ctx **_ctx) i_unlink_if_exists(ctx->log->path); } - if (ctx->input != NULL) - i_stream_unref(&ctx->input); + i_stream_unref(&ctx->input); i_free(ctx); return ret; } diff --git a/src/plugins/fts/fts-parser-tika.c b/src/plugins/fts/fts-parser-tika.c index cc9d4ba569..d35a3d6517 100644 --- a/src/plugins/fts/fts-parser-tika.c +++ b/src/plugins/fts/fts-parser-tika.c @@ -245,8 +245,7 @@ static int fts_parser_tika_deinit(struct fts_parser *_parser) /* remove io before unrefing payload - otherwise lib-http adds another timeout to ioloop unnecessarily */ - if (parser->payload != NULL) - i_stream_unref(&parser->payload); + i_stream_unref(&parser->payload); io_remove(&parser->io); if (parser->http_req != NULL) http_client_request_abort(&parser->http_req); diff --git a/src/plugins/mail-crypt/fs-crypt-common.c b/src/plugins/mail-crypt/fs-crypt-common.c index 8a7cfa317f..9f810a04fd 100644 --- a/src/plugins/mail-crypt/fs-crypt-common.c +++ b/src/plugins/mail-crypt/fs-crypt-common.c @@ -176,8 +176,7 @@ static void fs_crypt_file_close(struct fs_file *_file) { struct crypt_fs_file *file = (struct crypt_fs_file *)_file; - if (file->input != NULL) - i_stream_unref(&file->input); + i_stream_unref(&file->input); if (file->super_read != NULL) fs_file_close(file->super_read); if (_file->parent != NULL) diff --git a/src/plugins/mail-crypt/mail-crypt-plugin.c b/src/plugins/mail-crypt/mail-crypt-plugin.c index 21c1095378..459e841022 100644 --- a/src/plugins/mail-crypt/mail-crypt-plugin.c +++ b/src/plugins/mail-crypt/mail-crypt-plugin.c @@ -74,8 +74,7 @@ static void mail_crypt_cache_close(struct mail_crypt_user *muser) struct mail_crypt_cache *cache = &muser->cache; timeout_remove(&cache->to); - if (cache->input != NULL) - i_stream_unref(&cache->input); + i_stream_unref(&cache->input); i_zero(cache); } diff --git a/src/plugins/zlib/zlib-plugin.c b/src/plugins/zlib/zlib-plugin.c index 4600e2b8a2..98571a8c4a 100644 --- a/src/plugins/zlib/zlib-plugin.c +++ b/src/plugins/zlib/zlib-plugin.c @@ -69,8 +69,7 @@ static void zlib_mail_cache_close(struct zlib_user *zuser) struct zlib_mail_cache *cache = &zuser->cache; timeout_remove(&cache->to); - if (cache->input != NULL) - i_stream_unref(&cache->input); + i_stream_unref(&cache->input); i_zero(cache); }