]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: start relying on [io]_stream_unref(NULL) being a no-op
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Tue, 19 Sep 2017 10:19:36 +0000 (13:19 +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) {
-  i_stream_unref(&E);
- }
+ i_stream_unref(&E);

@@
expression E;
@@

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

48 files changed:
src/auth/auth-master-connection.c
src/auth/auth-postfix-connection.c
src/doveadm/doveadm-mail.c
src/doveadm/dsync/dsync-brain-mails.c
src/doveadm/dsync/dsync-mailbox-export.c
src/imap/cmd-append.c
src/imap/cmd-getmetadata.c
src/imap/cmd-urlfetch.c
src/imap/imap-fetch.c
src/lib-fs/fs-metawrap.c
src/lib-fs/fs-sis.c
src/lib-fs/test-fs-metawrap.c
src/lib-http/http-client-request.c
src/lib-http/http-message-parser.c
src/lib-http/http-server-response.c
src/lib-http/test-http-payload.c
src/lib-imap-client/test-imapc-client.c
src/lib-imap-storage/imap-msgpart-url.c
src/lib-imap-urlauth/imap-urlauth-fetch.c
src/lib-index/mail-index-strmap.c
src/lib-mail/istream-attachment-connector.c
src/lib-program-client/program-client.c
src/lib-program-client/test-program-client-net.c
src/lib-program-client/test-program-client-unix.c
src/lib-smtp/lmtp-client.c
src/lib-smtp/test-smtp-submit.c
src/lib-storage/index/cydir/cydir-save.c
src/lib-storage/index/dbox-common/dbox-mail.c
src/lib-storage/index/imapc/imapc-mail-fetch.c
src/lib-storage/index/imapc/imapc-save.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/pop3c/pop3c-mail.c
src/lib/ioloop.c
src/lib/iostream-rawlog.c
src/lib/istream-chain.c
src/lib/istream-seekable.c
src/lib/istream.c
src/lib/ostream.c
src/lmtp/client.c
src/lmtp/lmtp-proxy.c
src/login-common/client-common.c
src/plugins/fs-compress/fs-compress.c
src/plugins/fts/fts-expunge-log.c
src/plugins/fts/fts-parser-tika.c
src/plugins/mail-crypt/fs-crypt-common.c
src/plugins/mail-crypt/mail-crypt-plugin.c
src/plugins/zlib/zlib-plugin.c

index eadc8431c35943c9c19accb2f046f7ab638de927..7f3d7f36f60b14822855f2b2104486b5b55b7ad5 100644 (file)
@@ -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);
index 18592e5536c150d4c9a75a8f6c21e7e4596e7612..9ab0adeab7028b9c654443f5fd043d98847027db 100644 (file)
@@ -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);
 }
 
index affbfa0afc13215d1c7486a13684a252d7564683..ccf644874d46d96913ef9b472047d432d008dbaa 100644 (file)
@@ -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);
 }
 
index 44e53038c672fe11c4af1373f11cff37cedf38ef..8a14f3b2418af6ecf7691a04928e3393e985a22a 100644 (file)
@@ -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;
 }
 
index 319d9ffe95c76f4a6672155d5f8701ca06a7e100..cb02deba3d494779f7412c3a00934277eadf0e95 100644 (file)
@@ -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);
 
index d9d2037d3b787b9e45404ddfc89c463e9450cba0..f55d43bdd7c087b8c00c5b2299d140512018b5c8 100644 (file)
@@ -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)
index 1b8638a06f5194027aa85544b06bad89f2c95b5e..a18db8d63f1ec9b2a0059cb3f69ee87e06d0748f 100644 (file)
@@ -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;
        }
 
index 650903897494a5d0e1aac246efd1cc7a448ea281..5fc212796dbe81a2d81902a39d404a1fa13118cb 100644 (file)
@@ -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);
 
index e72284a36fc82857b8d6c8a8d515d986836d0ad7..8bd2dac7cc928cf29b8184088a72b4d5bda2aeae 100644 (file)
@@ -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)
index 9f95cc26e33cca5fd0abda94c41b0f8f92b2004d..ae99da3f58096a0193ebd54a31619cf334d6199b 100644 (file)
@@ -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)
index a1e94b971befe138e4ece860f7864d05d7c3d422..5e2d431df3d3c01564666495f71ef50653ba0eca 100644 (file)
@@ -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);
 }
index 38f322aa0d7284aeaa006351598bda4825889664..0739953bfd9945014970d1e713332c836d87e87f 100644 (file)
@@ -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);
index 4dadbcb26e3799ec961549d4a60758f7a0b6ae4e..a49ce510e933e7401ef1e2058ab628d0b08daf6a 100644 (file)
@@ -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;
index 388763d156ad38b8edd540e1c5bea36e14fd13bf..3c08dd3308bdc214724686ef33b7f65941771708 100644 (file)
@@ -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,
index f2ecff488a298b05700d45d336255f3f50310893..9b0f2e844740f2f0cff78d9b8796ff2484d166a4 100644 (file)
@@ -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);
 }
 
index 06abb21f187a970af312600cc02f20e42df9c6f9..555003aff2d33c4a085266e1a0a8b5ec6f8d44a5 100644 (file)
@@ -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);
index 261469e6ff2260f745c96f39be307995b87fcacb..257a3ef2b2ddd48244ccceda468a31322f7622dc 100644 (file)
@@ -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);
 }
 
index eae5acb45d17cd9b6d9205d10457ee96e2f328ee..a8dd6155fe66d1b6ad9914039e5c07536d74beb2 100644 (file)
@@ -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)
index d5b395027edf4a6d5f492efe60fae0aa2e0c7c26..9087afcceb7e1da069546b0b281170a56f301234 100644 (file)
@@ -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) {
index a8b7c2afad74cfa4002cf6ea0422102fce7e0e73..63958db554879c4dc70b91894540899f5ae5b1cd 100644 (file)
@@ -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)
index bcccf2ac324775c8ce2bc010404c1005c9769819..46e3a5571745bec8d874ea2e17aace848f006ec6 100644 (file)
@@ -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);
index 788d478ba89490b4223dc6874cd3aa7c43ddeb97..1231178e8e1740cf02f6938aaab354bc636ff1f0 100644 (file)
@@ -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);
index d2048603a679b7189adf222bb8c74b8b598972f9..0a47a902fb28eeb26986cb45564e8c284697c242 100644 (file)
@@ -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;
index 2a9fd1fa8a2049e3b8ca67a0176cc00bcf29c7a4..36699ab562a37d9f74bcffab367ef2a23c6bf1c3 100644 (file)
@@ -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;
index 02a30f6ceffddc44a97c866dd22d4c6a58fc52c5..ebf5a4b895e57622c0573058d8e5a71b53b1ea00 100644 (file)
@@ -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);
 }
index e7c11ab8612a53f38517d1b6d97cbf0b8d0db154..8ef4f7bef77c5363540a35252d42bce5c78d2fbd 100644 (file)
@@ -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)
index 567e0a78fd3784dd0073e68c062e435d4c391441..38a8ef1bfddaace4babd1878718e0440cf14b813 100644 (file)
@@ -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;
index b10e64796e9d70620c5eeb42d814839176a40d15..0dc31d2530fe778de6a047cacd72081334faedaa 100644 (file)
@@ -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;
index d428db146d680c09612e856515e097a46bfa2286..a86660355e23f96ef44d5fd9dfed125c5c4fd88a 100644 (file)
@@ -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) {
index 65bbc23b65046b5f317c460eec296f8c2d084eb5..7d98a3305c1e7ff776276d5104393df8fb271f6e 100644 (file)
@@ -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);
index 4ec92214220ed668037784394153376301a6a5ca..21e9da7f37ab7adf121e443234b1d1242b6cbaef 100644 (file)
@@ -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;
 
index 815684b87d3ddb296c257590fa4715687d47c8fa..541ad026114bb19566feccb6976245a07ddb9c59 100644 (file)
@@ -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);
index b0078b277413ac976da0d9152017e43f3435e18b..191136adbfaaff365634b1b721ffca99479058e4 100644 (file)
@@ -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);
 }
 
index 4e73e5de243270eb35c27a123431d9f3be238706..603855559c8114ff368b1cedcccabf2f5f0222b3 100644 (file)
@@ -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);
        }
 }
 
index fcace8e48716ffbe5e9ab7856af02bece63144c3..7d84d5bdd612803b1607941b2f77ca3c28319817 100644 (file)
@@ -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);
 }
index 1b6bfc98d48f3a7973f272036af0895bc98efc7c..fbe458a2a64876937efe363606355e71bc29fa61 100644 (file)
@@ -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;
        }
index 70e11636ce4dd0ec44b5df1ceae2befd1fdbb634..a8f304ababdd99e24207dd92f06edc9214916651 100644 (file)
@@ -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)
index ffcf7b640e10babefab05408c544fc6f6aefc5e3..eb82c89934f82d9cb44f9aa4565ba0a70091ffff 100644 (file)
@@ -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
index abae3b07125ccfc781e1e2a0879bd796376fa2a5..cf4f28d0e1274b3d396015482f4453fb8a760ca3 100644 (file)
@@ -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
index 72540cea470b4ba4237937ae48b543fcb96e072f..1d9dc3511c28f7c28f2c4b24450e1e6927cc8609 100644 (file)
@@ -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");
index 0db4287e41198096ac847dd47434a89619fd088e..e9ef775d571e7a99f94a9386b9e92900b932f61a 100644 (file)
@@ -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);
 }
 
index a0a0f51076c97152884a1806e435f0913eed2ef6..03f0a10235d288c34f8a759b03085b2e18651b51 100644 (file)
@@ -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);
index 7bca3d992c5fcef57419fa21f8ecb6063f74bc4b..df3b9ffdeef7ba08eeb626d04511702ee4d9866f 100644 (file)
@@ -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)
index 56f9cb915ca4e602325bbf9755083f603a3a98ac..35854901cea0cacc8fa87de922f436431c5bd9d6 100644 (file)
@@ -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;
 }
index cc9d4ba569b5c29c102261fc73d7b4d853f3eab4..d35a3d6517867f77f8630b220e90f9ee972bc155 100644 (file)
@@ -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);
index 8a7cfa317f3654586fcab9c7561b0c8488b3541c..9f810a04fd85a9fb723d43502062b5e76825fdb5 100644 (file)
@@ -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)
index 21c109537820632e4ebfe4e9f9a1ea93c98d6026..459e84102217153263a6c38549326b578eaaf097 100644 (file)
@@ -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);
 }
 
index 4600e2b8a213b27e81bfc71d9077b6145790ed33..98571a8c4aecf9cbb83836557d8607e44adc3613 100644 (file)
@@ -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);
 }