From af75bc4be67422b7523707ec56db4a9cde59429b Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 4 May 2015 23:16:44 +0100 Subject: [PATCH] Use null check convention in connection.c --- src/xmpp/connection.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index f2596f14..70d49b7c 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -129,11 +129,11 @@ jabber_connect_with_account(const ProfAccount * const account) log_info("Connecting using account: %s", account->name); // save account name and password for reconnect - if (saved_account.name != NULL) { + if (saved_account.name) { free(saved_account.name); } saved_account.name = strdup(account->name); - if (saved_account.passwd != NULL) { + if (saved_account.passwd) { free(saved_account.passwd); } saved_account.passwd = strdup(account->password); @@ -157,7 +157,7 @@ jabber_connect_with_details(const char * const jid, // save details for reconnect, remember name for account creating on success saved_details.name = strdup(jid); saved_details.passwd = strdup(passwd); - if (altdomain != NULL) { + if (altdomain) { saved_details.altdomain = strdup(altdomain); } else { saved_details.altdomain = NULL; @@ -199,11 +199,11 @@ jabber_disconnect(void) _connection_free_saved_account(); _connection_free_saved_details(); _connection_free_session_data(); - if (jabber_conn.conn != NULL) { + if (jabber_conn.conn) { xmpp_conn_release(jabber_conn.conn); jabber_conn.conn = NULL; } - if (jabber_conn.ctx != NULL) { + if (jabber_conn.ctx) { xmpp_ctx_free(jabber_conn.ctx); jabber_conn.ctx = NULL; } @@ -238,7 +238,7 @@ jabber_process_events(void) break; case JABBER_DISCONNECTED: reconnect_sec = prefs_get_reconnect(); - if ((reconnect_sec != 0) && (reconnect_timer != NULL)) { + if ((reconnect_sec != 0) && reconnect_timer) { int elapsed_sec = g_timer_elapsed(reconnect_timer, NULL); if (elapsed_sec > reconnect_sec) { _jabber_reconnect(); @@ -302,7 +302,7 @@ void connection_set_presence_message(const char * const message) { FREE_SET_NULL(jabber_conn.presence_message); - if (message != NULL) { + if (message) { jabber_conn.presence_message = strdup(message); } } @@ -371,15 +371,15 @@ _jabber_connect(const char * const fulljid, const char * const passwd, jid_destroy(jid); log_info("Connecting as %s", fulljid); - if (jabber_conn.log != NULL) { + if (jabber_conn.log) { free(jabber_conn.log); } jabber_conn.log = _xmpp_get_file_logger(); - if (jabber_conn.conn != NULL) { + if (jabber_conn.conn) { xmpp_conn_release(jabber_conn.conn); } - if (jabber_conn.ctx != NULL) { + if (jabber_conn.ctx) { xmpp_ctx_free(jabber_conn.ctx); } jabber_conn.ctx = xmpp_ctx_new(NULL, jabber_conn.log); @@ -436,7 +436,7 @@ _connection_handler(xmpp_conn_t * const conn, log_debug("Connection handler: XMPP_CONN_CONNECT"); // logged in with account - if (saved_account.name != NULL) { + if (saved_account.name) { log_debug("Connection handler: logged in with account name: %s", saved_account.name); sv_ev_login_account_success(saved_account.name); @@ -474,7 +474,7 @@ _connection_handler(xmpp_conn_t * const conn, jabber_conn.conn_status = JABBER_CONNECTED; if (prefs_get_reconnect() != 0) { - if (reconnect_timer != NULL) { + if (reconnect_timer) { g_timer_destroy(reconnect_timer); reconnect_timer = NULL; }