]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: start relying on [io]_stream_destroy(NULL) being a no-op
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Tue, 6 Jun 2017 09:53:41 +0000 (12:53 +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_destroy(&E);
- }
+ i_stream_destroy(&E);

@@
expression E;
@@

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

25 files changed:
src/anvil/anvil-connection.c
src/auth/mech-winbind.c
src/auth/userdb-passwd-file.c
src/director/login-connection.c
src/doveadm/client-connection.c
src/doveadm/server-connection.c
src/imap-urlauth/imap-urlauth-client.c
src/imap-urlauth/imap-urlauth-worker.c
src/lib-dns/dns-lookup.c
src/lib-fs/fs-test.c
src/lib-fs/istream-fs-file.c
src/lib-mail/istream-attachment-extractor.c
src/lib-master/master-login-auth.c
src/lib-program-client/program-client.c
src/lib-storage/index/mbox/mbox-file.c
src/lib-storage/index/mbox/mbox-save.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/pop3c/pop3c-client.c
src/lib-storage/list/subscription-file.c
src/login-common/login-proxy.c
src/plugins/fs-compress/fs-compress.c
src/plugins/mail-crypt/fs-crypt-common.c
src/plugins/mail-filter/istream-ext-filter.c
src/plugins/mail-filter/ostream-ext-filter.c
src/replication/aggregator/notify-connection.c

index 2ba068710058940ebc01bf6ba41a2376b22492f3..531555587ccf2387376096ecdfd9849d48b9c09b 100644 (file)
@@ -210,8 +210,7 @@ void anvil_connection_destroy(struct anvil_connection *conn)
 
        io_remove(&conn->io);
        i_stream_destroy(&conn->input);
-       if (conn->output != NULL)
-               o_stream_destroy(&conn->output);
+       o_stream_destroy(&conn->output);
        if (close(conn->fd) < 0)
                i_error("close(anvil conn) failed: %m");
        i_free(conn);
index c12fb5effd9365734137967b402a5353b6518a31..ca1a9a6d0da7749233149fa2521ae2e22ee11a01 100644 (file)
@@ -54,10 +54,8 @@ static bool sigchld_handler_set = FALSE;
 
 static void winbind_helper_disconnect(struct winbind_helper *winbind)
 {
-       if (winbind->in_pipe != NULL)
-               i_stream_destroy(&winbind->in_pipe);
-       if (winbind->out_pipe != NULL)
-               o_stream_destroy(&winbind->out_pipe);
+       i_stream_destroy(&winbind->in_pipe);
+       o_stream_destroy(&winbind->out_pipe);
 }
 
 static void winbind_wait_pid(struct winbind_helper *winbind)
index b7f41ebb98ce6a0ee3a4ea992f2a307ee1e72ebc..d131275c6d27d142bef5be2e02af487d5c741935 100644 (file)
@@ -173,8 +173,7 @@ static int passwd_file_iterate_deinit(struct userdb_iterate_context *_ctx)
                (struct passwd_file_userdb_iterate_context *)_ctx;
        int ret = _ctx->failed ? -1 : 0;
 
-       if (ctx->input != NULL)
-               i_stream_destroy(&ctx->input);
+       i_stream_destroy(&ctx->input);
        i_free(ctx->path);
        i_free(ctx);
        return ret;
index 86a26fc3eb9e6a17282fd7faf09ea8adcf282433..ca5788ec0fb5ea1c710100df14926fc269d4354b 100644 (file)
@@ -306,8 +306,7 @@ void login_connection_deinit(struct login_connection **_conn)
 
        DLLIST_REMOVE(&login_connections, conn);
        io_remove(&conn->io);
-       if (conn->input != NULL)
-               i_stream_destroy(&conn->input);
+       i_stream_destroy(&conn->input);
        o_stream_destroy(&conn->output);
        if (close(conn->fd) < 0)
                i_error("close(login connection) failed: %m");
index d6f7d4a432dcebbd61424a2e2aab3d7b1b0cf4f9..122a144e07959d4f271bbcbc048d81b7fef5e2e2 100644 (file)
@@ -567,14 +567,11 @@ void client_connection_destroy(struct client_connection **_conn)
        if (conn->ssl_iostream != NULL)
                ssl_iostream_destroy(&conn->ssl_iostream);
 
-       if (conn->output != NULL)
-               o_stream_destroy(&conn->output);
+       o_stream_destroy(&conn->output);
 
        io_remove(&conn->io);
 
-       if (conn->input != NULL) {
-               i_stream_destroy(&conn->input);
-       }
+       i_stream_destroy(&conn->input);
 
        if (conn->fd > 0 && close(conn->fd) < 0)
                i_error("close(client) failed: %m");
index 0ecf996c98e343d88eae472d1a43afd3dc1ed626..2c8039572823618a8176f11b9cd5cafcb14911bb 100644 (file)
@@ -551,15 +551,11 @@ void server_connection_destroy(struct server_connection **_conn)
                print_connection_released();
 
        timeout_remove(&conn->to_input);
-       if (conn->input != NULL)
-               i_stream_destroy(&conn->input);
-       if (conn->output != NULL)
-               o_stream_destroy(&conn->output);
-       if (conn->cmd_input != NULL)
-               i_stream_destroy(&conn->cmd_input);
+       i_stream_destroy(&conn->input);
+       o_stream_destroy(&conn->output);
+       i_stream_destroy(&conn->cmd_input);
        /* close cmd_output after its parent, so the "." isn't sent */
-       if (conn->cmd_output != NULL)
-               o_stream_destroy(&conn->cmd_output);
+       o_stream_destroy(&conn->cmd_output);
        if (conn->ssl_iostream != NULL)
                ssl_iostream_unref(&conn->ssl_iostream);
        io_remove(&conn->io);
index 20850de2509b914782effc8aefcdb3e010755c6e..cda6bf2b91da22b2dac6c79282cf35d60fb3de31 100644 (file)
@@ -192,10 +192,8 @@ void client_worker_disconnect(struct client *client)
        client->worker_state = IMAP_URLAUTH_WORKER_STATE_INACTIVE;
 
        io_remove(&client->ctrl_io);
-       if (client->ctrl_output != NULL)
-               o_stream_destroy(&client->ctrl_output);
-       if (client->ctrl_input != NULL)
-               i_stream_destroy(&client->ctrl_input);
+       o_stream_destroy(&client->ctrl_output);
+       i_stream_destroy(&client->ctrl_input);
        if (client->fd_ctrl >= 0) {
                net_disconnect(client->fd_ctrl);
                client->fd_ctrl = -1;
index b24554016bc3b7c469c4d1fdb301e87d8b01517d..08ad3017c02c2a58b6600a135a9801c381449231 100644 (file)
@@ -242,15 +242,11 @@ static void client_destroy(struct client *client)
        io_remove(&client->ctrl_io);
        timeout_remove(&client->to_idle);
 
-       if (client->input != NULL)
-               i_stream_destroy(&client->input);
-       if (client->output != NULL)
-               o_stream_destroy(&client->output);
-
-       if (client->ctrl_input != NULL)
-               i_stream_destroy(&client->ctrl_input);
-       if (client->ctrl_output != NULL)
-               o_stream_destroy(&client->ctrl_output);
+       i_stream_destroy(&client->input);
+       o_stream_destroy(&client->output);
+
+       i_stream_destroy(&client->ctrl_input);
+       o_stream_destroy(&client->ctrl_output);
 
        fd_close_maybe_stdio(&client->fd_in, &client->fd_out);
        if (client->fd_ctrl >= 0)
index c67a20e1f46328f263105e861ad95c5648f24375..abe83a6cc8bcebfd929111585284939295fe7b97 100644 (file)
@@ -61,8 +61,7 @@ static void dns_client_disconnect(struct dns_client *client, const char *error)
 
        timeout_remove(&client->to_idle);
        io_remove(&client->io);
-       if (client->input != NULL)
-               i_stream_destroy(&client->input);
+       i_stream_destroy(&client->input);
        if (client->fd != -1) {
                if (close(client->fd) < 0)
                        i_error("close(%s) failed: %m", client->path);
index b70821f778037a9ede2ed6e4ace02bb5981b8c72..caf881241cdf6f6ecca7e2c6e12612e60d87adc0 100644 (file)
@@ -168,8 +168,7 @@ static int fs_test_write_stream_finish(struct fs_file *_file, bool success)
 {
        struct test_fs_file *file = (struct test_fs_file *)_file;
 
-       if (_file->output != NULL)
-               o_stream_destroy(&_file->output);
+       o_stream_destroy(&_file->output);
        if (file->wait_async) {
                fs_set_error_async(_file->fs);
                return 0;
index c0b2012e03b28625fbb3640640c5b4e951c345c6..ab1ff03bc214c912c7d7a52590ce5670ed610c75 100644 (file)
@@ -15,8 +15,7 @@ static void i_stream_fs_file_close(struct iostream_private *stream,
 {
        struct fs_file_istream *fstream = (struct fs_file_istream *)stream;
 
-       if (fstream->istream.parent != NULL)
-               i_stream_destroy(&fstream->istream.parent);
+       i_stream_destroy(&fstream->istream.parent);
        fs_file_deinit(&fstream->file);
 }
 
index f34115911295313092444b7ac31a89a781129bf0..ff62b7b96f815893da62801e7de2111dc96eda45 100644 (file)
@@ -533,8 +533,7 @@ static void astream_part_reset(struct attachment_istream *astream)
 {
        struct attachment_istream_part *part = &astream->part;
 
-       if (part->temp_output != NULL)
-               o_stream_destroy(&part->temp_output);
+       o_stream_destroy(&part->temp_output);
        i_close_fd(&part->temp_fd);
 
        i_free_and_null(part->content_type);
index ad6a14f1ba61d7465b1e2c7ca716977857b42ccf..cc18a1e06b861defb81d6a9222b7aba8918396f5 100644 (file)
@@ -108,10 +108,8 @@ void master_login_auth_disconnect(struct master_login_auth *auth)
        timeout_remove(&auth->to);
        io_remove(&auth->io);
        if (auth->fd != -1) {
-               if (auth->input != NULL)
-                       i_stream_destroy(&auth->input);
-               if (auth->output != NULL)
-                       o_stream_destroy(&auth->output);
+               i_stream_destroy(&auth->input);
+               o_stream_destroy(&auth->output);
 
                net_disconnect(auth->fd);
                auth->fd = -1;
index f8240fd4368e143a3b2f8f322ea629c6862cd829..788d478ba89490b4223dc6874cd3aa7c43ddeb97 100644 (file)
@@ -89,8 +89,7 @@ int program_client_close_output(struct program_client *pclient)
 {
        int ret;
 
-       if (pclient->program_output != NULL)
-               o_stream_destroy(&pclient->program_output);
+       o_stream_destroy(&pclient->program_output);
        if ((ret = pclient->close_output(pclient)) < 0)
                return -1;
        pclient->program_output = NULL;
@@ -126,8 +125,7 @@ void program_client_disconnected(struct program_client *pclient)
                else
                        i_stream_destroy(&pclient->program_input);
        }
-       if (pclient->program_output != NULL)
-               o_stream_destroy(&pclient->program_output);
+       o_stream_destroy(&pclient->program_output);
 
        io_remove(&pclient->io);
 
index 38260a5e350861ee5f6461085aeadb80754257f8..10112f7ae945235f3140c73b3c2a1f9e35ef328d 100644 (file)
@@ -125,8 +125,7 @@ void mbox_file_close_stream(struct mbox_mailbox *mbox)
        /* if we read anything, fix the atime if needed */
        mbox_file_fix_atime(mbox);
 
-       if (mbox->mbox_stream != NULL)
-               i_stream_destroy(&mbox->mbox_stream);
+       i_stream_destroy(&mbox->mbox_stream);
 
        if (mbox->mbox_file_stream != NULL) {
                if (mbox->mbox_fd == -1) {
index 21934e728bd59fdeff94131286033d6b6f2a2cbd..ef1759dbbbd5ff3d86792d26517d3ee68193b048 100644 (file)
@@ -705,8 +705,7 @@ void mbox_save_cancel(struct mail_save_context *_ctx)
 
 static void mbox_transaction_save_deinit(struct mbox_save_context *ctx)
 {
-       if (ctx->output != NULL)
-               o_stream_destroy(&ctx->output);
+       o_stream_destroy(&ctx->output);
        str_free(&ctx->headers);
 }
 
index 677854267d1e3b1bf84b20bf013edc85217dc4c2..808266bb1bbb2f80d6360913728d6b58bb72ec32 100644 (file)
@@ -616,8 +616,7 @@ static void mbox_mailbox_close(struct mailbox *box)
        timeout_remove(&mbox->keep_lock_to);
 
         mbox_file_close(mbox);
-       if (mbox->mbox_file_stream != NULL)
-               i_stream_destroy(&mbox->mbox_file_stream);
+       i_stream_destroy(&mbox->mbox_file_stream);
 
        index_storage_mailbox_close(box);
 }
index dbaef5591cba73f9a44fe2abb2272d0d7d696700..b51c622e42eae62a3eb9cf54e268bb33188ab28e 100644 (file)
@@ -201,10 +201,8 @@ static void pop3c_client_disconnect(struct pop3c_client *client)
                dns_lookup_abort(&client->dns_lookup);
        timeout_remove(&client->to);
        io_remove(&client->io);
-       if (client->input != NULL)
-               i_stream_destroy(&client->input);
-       if (client->output != NULL)
-               o_stream_destroy(&client->output);
+       i_stream_destroy(&client->input);
+       o_stream_destroy(&client->output);
        if (client->ssl_iostream != NULL)
                ssl_iostream_unref(&client->ssl_iostream);
        if (client->fd != -1) {
index 5ab4c08c44c30218150aecf162eebcea05314c6f..0634b81464c6302363cdfe8033b930794b430e18 100644 (file)
@@ -297,8 +297,7 @@ int subsfile_list_deinit(struct subsfile_list_context **_ctx)
 
        *_ctx = NULL;
 
-       if (ctx->input != NULL)
-               i_stream_destroy(&ctx->input);
+       i_stream_destroy(&ctx->input);
        str_free(&ctx->name);
        i_free(ctx->path);
        i_free(ctx);
index 860b27fa460d57977ca81e0f1db527b667a8e84c..f448e1368f8f27c5c9cb0f2539ef1215e06258b9 100644 (file)
@@ -478,10 +478,8 @@ static void login_proxy_disconnect(struct login_proxy *proxy)
        }
 
        io_remove(&proxy->server_io);
-       if (proxy->server_input != NULL)
-               i_stream_destroy(&proxy->server_input);
-       if (proxy->server_output != NULL)
-               o_stream_destroy(&proxy->server_output);
+       i_stream_destroy(&proxy->server_input);
+       o_stream_destroy(&proxy->server_output);
        if (proxy->server_fd != -1) {
                net_disconnect(proxy->server_fd);
                proxy->server_fd = -1;
@@ -500,10 +498,8 @@ static void login_proxy_free_final(struct login_proxy *proxy)
        }
 
        io_remove(&proxy->client_io);
-       if (proxy->client_input != NULL)
-               i_stream_destroy(&proxy->client_input);
-       if (proxy->client_output != NULL)
-               o_stream_destroy(&proxy->client_output);
+       i_stream_destroy(&proxy->client_input);
+       o_stream_destroy(&proxy->client_output);
        if (proxy->client_fd != -1)
                net_disconnect(proxy->client_fd);
        if (proxy->ssl_server_proxy != NULL) {
@@ -783,10 +779,8 @@ int login_proxy_starttls(struct login_proxy *proxy)
 {
        int fd;
 
-       if (proxy->server_input != NULL)
-               i_stream_destroy(&proxy->server_input);
-       if (proxy->server_output != NULL)
-               o_stream_destroy(&proxy->server_output);
+       i_stream_destroy(&proxy->server_input);
+       o_stream_destroy(&proxy->server_output);
        io_remove(&proxy->server_io);
 
        fd = ssl_proxy_client_alloc(proxy->server_fd, &proxy->client->ip,
index 87788411c4082f9d90b05e55ef3ad87672e9787f..7bca3d992c5fcef57419fa21f8ecb6063f74bc4b 100644 (file)
@@ -198,8 +198,7 @@ static int fs_compress_write_stream_finish(struct fs_file *_file, bool success)
                        o_stream_unref(&_file->output);
        }
        if (!success) {
-               if (file->temp_output != NULL)
-                       o_stream_destroy(&file->temp_output);
+               o_stream_destroy(&file->temp_output);
                if (file->super_output != NULL)
                        fs_write_stream_abort_parent(_file, &file->super_output);
                return -1;
index 058f060425e55fb6e293da8c06d01c4f259803f5..8a7cfa317f3654586fcab9c7561b0c8488b3541c 100644 (file)
@@ -337,7 +337,7 @@ static int fs_crypt_write_stream_finish(struct fs_file *_file, bool success)
                                                    "write(%s) failed: %s",
                                                    o_stream_get_name(file->super_output),
                                                    o_stream_get_error(file->super_output));
-               } else if (file->temp_output != NULL) {
+               } else {
                        o_stream_destroy(&file->temp_output);
                }
                return -1;
index a445a27eddd6317b5916c4a4e16ee5d1654fdab5..00a92ab8260a6cf38be2f750ac6016ee86655b5f 100644 (file)
@@ -27,10 +27,8 @@ i_stream_mail_filter_close(struct iostream_private *stream, bool close_parent)
        struct mail_filter_istream *mstream =
                (struct mail_filter_istream *)stream;
 
-       if (mstream->ext_in != NULL)
-               i_stream_destroy(&mstream->ext_in);
-       if (mstream->ext_out != NULL)
-               o_stream_destroy(&mstream->ext_out);
+       i_stream_destroy(&mstream->ext_in);
+       o_stream_destroy(&mstream->ext_out);
        if (mstream->fd != -1) {
                if (close(mstream->fd) < 0)
                        i_error("ext-filter: close() failed: %m");
index 9bd95d44cce95002a36bac5fbaa5fbe05b354030..9eccca6bcd3c7bc45130819738b24562c363897c 100644 (file)
@@ -26,10 +26,8 @@ o_stream_mail_filter_close(struct iostream_private *stream, bool close_parent)
        struct mail_filter_ostream *mstream =
                (struct mail_filter_ostream *)stream;
 
-       if (mstream->ext_in != NULL)
-               i_stream_destroy(&mstream->ext_in);
-       if (mstream->ext_out != NULL)
-               o_stream_destroy(&mstream->ext_out);
+       i_stream_destroy(&mstream->ext_in);
+       o_stream_destroy(&mstream->ext_out);
        if (mstream->fd != -1) {
                if (close(mstream->fd) < 0)
                        i_error("ext-filter: close() failed: %m");
index 51123578b99539c0cc6621ebd7d115498a1cc2c0..bc90cf312e461e00c4a14f1f9c24dc60ec089b8d 100644 (file)
@@ -125,8 +125,7 @@ static void notify_connection_unref(struct notify_connection *conn)
                return;
 
        i_stream_destroy(&conn->input);
-       if (conn->output != NULL)
-               o_stream_destroy(&conn->output);
+       o_stream_destroy(&conn->output);
        i_free(conn);
 }