From 45cfd196caaae7fabcea476a9a965f691431c3c3 Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Mon, 11 Dec 2017 17:08:21 +0100 Subject: [PATCH] global: start relying on timeout_remove(NULL) being a no-op Cleanup performed with the following semantic patch: @@ expression E; @@ - if (E != NULL) { - timeout_remove(&E); - } + timeout_remove(&E); --- src/lib-sieve/storage/ldap/sieve-ldap-db.c | 9 +++------ src/managesieve-login/client.c | 3 +-- src/managesieve/managesieve-client.c | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/lib-sieve/storage/ldap/sieve-ldap-db.c b/src/lib-sieve/storage/ldap/sieve-ldap-db.c index bf8cc69b8..a046aa580 100644 --- a/src/lib-sieve/storage/ldap/sieve-ldap-db.c +++ b/src/lib-sieve/storage/ldap/sieve-ldap-db.c @@ -322,8 +322,7 @@ static int db_ldap_connect_finish(struct ldap_connection *conn, int ret) return -1; } - if (conn->to != NULL) - timeout_remove(&conn->to); + timeout_remove(&conn->to); conn->conn_state = LDAP_CONN_STATE_BOUND; sieve_storage_sys_debug(storage, "db: " "Successfully bound (dn %s)", @@ -653,8 +652,7 @@ static int db_ldap_bind(struct ldap_connection *conn) conn->conn_state = LDAP_CONN_STATE_BINDING; conn->default_bind_msgid = msgid; - if (conn->to != NULL) - timeout_remove(&conn->to); + timeout_remove(&conn->to); conn->to = timeout_add(DB_LDAP_REQUEST_LOST_TIMEOUT_SECS*1000, ldap_connection_timeout, conn); return 0; @@ -934,8 +932,7 @@ static void db_ldap_conn_close(struct ldap_connection *conn) conn->conn_state = LDAP_CONN_STATE_DISCONNECTED; conn->default_bind_msgid = -1; - if (conn->to != NULL) - timeout_remove(&conn->to); + timeout_remove(&conn->to); if (conn->pending_count != 0) { requests = array_idx(&conn->request_array, 0); diff --git a/src/managesieve-login/client.c b/src/managesieve-login/client.c index affaf9f01..d0dd199b8 100644 --- a/src/managesieve-login/client.c +++ b/src/managesieve-login/client.c @@ -341,8 +341,7 @@ static void managesieve_client_input(struct client *client) /* FIXME: Can't do untagged responses with managesieve. Any other ways? client_send_ok(client, AUTH_SERVER_WAITING_MSG); */ - if (client->to_auth_waiting != NULL) - timeout_remove(&client->to_auth_waiting); + timeout_remove(&client->to_auth_waiting); client->input_blocked = TRUE; break; diff --git a/src/managesieve/managesieve-client.c b/src/managesieve/managesieve-client.c index 8f8c09e94..49a1346fe 100644 --- a/src/managesieve/managesieve-client.c +++ b/src/managesieve/managesieve-client.c @@ -252,8 +252,7 @@ void client_destroy(struct client *client, const char *reason) managesieve_parser_destroy(&client->parser); io_remove(&client->io); - if (client->to_idle_output != NULL) - timeout_remove(&client->to_idle_output); + timeout_remove(&client->to_idle_output); timeout_remove(&client->to_idle); /* i/ostreams are already closed at this stage, so fd can be closed */ @@ -304,8 +303,7 @@ void client_disconnect(struct client *client, const char *reason) i_stream_close(client->input); o_stream_close(client->output); - if (client->to_idle != NULL) - timeout_remove(&client->to_idle); + timeout_remove(&client->to_idle); client->to_idle = timeout_add(0, client_destroy_timeout, client); }