]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: start relying on [io]_stream_close(NULL) being a no-op
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Fri, 22 Sep 2017 08:38:10 +0000 (11:38 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 1 Nov 2017 13:37:11 +0000 (15:37 +0200)
Cleanup performed with the following semantic patch (and a bit of
hand-editing):

@@
expression E;
@@

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

@@
expression E;
@@

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

src/auth/auth-master-connection.c
src/auth/auth-postfix-connection.c
src/lib-smtp/lmtp-client.c
src/lib/connection.c
src/lib/istream-seekable.c
src/lib/istream.c
src/lib/ostream.c
src/login-common/client-common.c
src/replication/aggregator/notify-connection.c

index 0f0c9eee9f00cdd40f4294ef383450bf15999207..2996f45c79a4bcd47e2c228732de049aafe65d05 100644 (file)
@@ -782,10 +782,8 @@ void auth_master_connection_destroy(struct auth_master_connection **_conn)
 
        if (conn->iter_ctx != NULL)
                master_input_list_finish(conn->iter_ctx);
-       if (conn->input != NULL)
-               i_stream_close(conn->input);
-       if (conn->output != NULL)
-               o_stream_close(conn->output);
+       i_stream_close(conn->input);
+       o_stream_close(conn->output);
        io_remove(&conn->io);
        i_close_fd_path(&conn->fd, conn->path);
 
index 0abe498b4a43ee146299edc4f363dd3ba2c9ed81..e5f9473d6e689a487db1a5a956551ee20098e04c 100644 (file)
@@ -196,10 +196,8 @@ auth_postfix_connection_destroy(struct auth_postfix_connection **_conn)
 
        DLLIST_REMOVE(&auth_postfix_connections, conn);
 
-       if (conn->input != NULL)
-               i_stream_close(conn->input);
-       if (conn->output != NULL)
-               o_stream_close(conn->output);
+       i_stream_close(conn->input);
+       o_stream_close(conn->output);
        io_remove(&conn->io);
        i_close_fd_path(&conn->fd, conn->path);
 
index ebf5a4b895e57622c0573058d8e5a71b53b1ea00..f1e4607fe435c957dcd6314d6dbafbb547db8af2 100644 (file)
@@ -120,10 +120,8 @@ void lmtp_client_close(struct lmtp_client *client)
                dns_lookup_abort(&client->dns_lookup);
        timeout_remove(&client->to);
        io_remove(&client->io);
-       if (client->input != NULL)
-               i_stream_close(client->input);
-       if (client->output != NULL)
-               o_stream_close(client->output);
+       i_stream_close(client->input);
+       o_stream_close(client->output);
        if (client->fd != -1) {
                net_disconnect(client->fd);
                client->fd = -1;
index f0a8c82fdd2eb8796894e0f7160226c9fa4936b9..dde4d6bec05e39f19e1521639995d7b4d23a531f 100644 (file)
@@ -313,14 +313,10 @@ void connection_disconnect(struct connection *conn)
        i_zero(&conn->last_input_tv);
        timeout_remove(&conn->to);
        io_remove(&conn->io);
-       if (conn->input != NULL) {
-               i_stream_close(conn->input);
-               i_stream_destroy(&conn->input);
-       }
-       if (conn->output != NULL) {
-               o_stream_close(conn->output);
-               o_stream_destroy(&conn->output);
-       }
+       i_stream_close(conn->input);
+       i_stream_destroy(&conn->input);
+       o_stream_close(conn->output);
+       o_stream_destroy(&conn->output);
        fd_close_maybe_stdio(&conn->fd_in, &conn->fd_out);
 }
 
index f4d4c9dd4df9375b3746bd68a5af76bb79c13169..cb972f1d4b52b380ca1f67b53bb9eecca9713537 100644 (file)
@@ -39,8 +39,7 @@ static void i_stream_seekable_close(struct iostream_private *stream,
        struct seekable_istream *sstream = (struct seekable_istream *)stream;
 
        sstream->fd = -1;
-       if (sstream->fd_input != NULL)
-               i_stream_close(sstream->fd_input);
+       i_stream_close(sstream->fd_input);
 }
 
 static void unref_streams(struct seekable_istream *sstream)
index 6f8a02b4b2703b842a8315acb87284f17b4a02ab..230542d00affc408393508658507370a66c3db1c 100644 (file)
@@ -953,7 +953,7 @@ static void i_stream_default_close(struct iostream_private *stream,
 {
        struct istream_private *_stream = (struct istream_private *)stream;
 
-       if (close_parent && _stream->parent != NULL)
+       if (close_parent)
                i_stream_close(_stream->parent);
 }
 
index e3af75aa6449eb42a3107b56ef92d8b03a57107b..03d33df273be71b0f43a4dbe39b3d38cf0eeb027 100644 (file)
@@ -490,7 +490,7 @@ static void o_stream_default_close(struct iostream_private *stream,
        struct ostream_private *_stream = (struct ostream_private *)stream;
 
        (void)o_stream_flush(&_stream->ostream);
-       if (close_parent && _stream->parent != NULL)
+       if (close_parent)
                o_stream_close(_stream->parent);
 }
 
index 57257706917e2b3bee262e96bcecde67712f0886..5c65aa5cd68c091045b931bbd395e7719c8911a3 100644 (file)
@@ -249,10 +249,8 @@ void client_destroy(struct client *client, const char *reason)
                o_stream_uncork(client->output);
        if (!client->login_success && client->ssl_proxy != NULL)
                ssl_proxy_destroy(client->ssl_proxy);
-       if (client->input != NULL)
-               i_stream_close(client->input);
-       if (client->output != NULL)
-               o_stream_close(client->output);
+       i_stream_close(client->input);
+       o_stream_close(client->output);
 
        if (client->master_tag != 0) {
                i_assert(client->auth_request == NULL);
index bc90cf312e461e00c4a14f1f9c24dc60ec089b8d..9147df17a75239292db76c3ba5c9887f9f295bbd 100644 (file)
@@ -140,8 +140,7 @@ static void notify_connection_destroy(struct notify_connection *conn)
 
        io_remove(&conn->io);
        i_stream_close(conn->input);
-       if (conn->output != NULL)
-               o_stream_close(conn->output);
+       o_stream_close(conn->output);
        net_disconnect(conn->fd);
        conn->fd = -1;