Skip to content

Commit

Permalink
global: start relying on timeout_remove(NULL) being a no-op
Browse files Browse the repository at this point in the history
Cleanup performed with the following semantic patch:

	@@
	expression E;
	@@

	- if (E != NULL) {
	- 	timeout_remove(&E);
	- }
	+ timeout_remove(&E);
  • Loading branch information
stephanbosch committed Dec 15, 2017
1 parent ca1773c commit 45cfd19
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
9 changes: 3 additions & 6 deletions src/lib-sieve/storage/ldap/sieve-ldap-db.c
Expand Up @@ -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)",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/managesieve-login/client.c
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/managesieve/managesieve-client.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 45cfd19

Please sign in to comment.