diff options
author | James Booth <boothj5@gmail.com> | 2014-04-26 00:36:36 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-04-26 00:36:36 +0100 |
commit | d6e92f62dc907d5da66f477884a4c0c728b84127 (patch) | |
tree | e77d8ad400874baa5edd7dde9ce66b1847fd89e9 /src/xmpp | |
parent | ab4ea80a70803d8d6335d8f5a8a4248e6d5423a4 (diff) | |
download | profani-tty-d6e92f62dc907d5da66f477884a4c0c728b84127.tar.gz |
Fixed cppcheck warnings
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/connection.c | 3 | ||||
-rw-r--r-- | src/xmpp/iq.c | 13 | ||||
-rw-r--r-- | src/xmpp/message.c | 5 | ||||
-rw-r--r-- | src/xmpp/presence.c | 8 | ||||
-rw-r--r-- | src/xmpp/presence.h | 1 | ||||
-rw-r--r-- | src/xmpp/stanza.c | 60 | ||||
-rw-r--r-- | src/xmpp/stanza.h | 3 |
7 files changed, 10 insertions, 83 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 95c7fd82..e32ba4ed 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -206,7 +206,6 @@ static void _jabber_process_events(void) { int reconnect_sec; - int elapsed_sec; switch (jabber_conn.conn_status) { @@ -218,7 +217,7 @@ _jabber_process_events(void) case JABBER_DISCONNECTED: reconnect_sec = prefs_get_reconnect(); if ((reconnect_sec != 0) && (reconnect_timer != NULL)) { - elapsed_sec = g_timer_elapsed(reconnect_timer, NULL); + int elapsed_sec = g_timer_elapsed(reconnect_timer, NULL); if (elapsed_sec > reconnect_sec) { _jabber_reconnect(); } diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 7bf0d2d1..1c9ad0aa 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -439,13 +439,13 @@ _disco_info_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); if (g_strcmp0(id, "discoinforeq") == 0) { - GSList *identities = NULL; - GSList *features = NULL; xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query != NULL) { xmpp_stanza_t *child = xmpp_stanza_get_children(query); + GSList *identities = NULL; + GSList *features = NULL; while (child != NULL) { const char *stanza_name = xmpp_stanza_get_name(child); if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) { @@ -606,9 +606,6 @@ _disco_items_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan log_debug("Recieved diso#items response"); const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); - const char *stanza_name = NULL; - const char *item_jid = NULL; - const char *item_name = NULL; GSList *items = NULL; if ((g_strcmp0(id, "confreq") == 0) || (g_strcmp0(id, "discoitemsreq") == 0)) { @@ -618,13 +615,13 @@ _disco_items_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan if (query != NULL) { xmpp_stanza_t *child = xmpp_stanza_get_children(query); while (child != NULL) { - stanza_name = xmpp_stanza_get_name(child); + const char *stanza_name = xmpp_stanza_get_name(child); if ((stanza_name != NULL) && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) { - item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); + const char *item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID); if (item_jid != NULL) { DiscoItem *item = malloc(sizeof(struct disco_item_t)); item->jid = strdup(item_jid); - item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); + const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); if (item_name != NULL) { item->name = strdup(item_name); } else { diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 4fc71f63..f8e2e18b 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -237,8 +237,6 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); char *room = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); - char *invitor = NULL; - char *reason = NULL; if (room == NULL) { log_warning("Message received with no from attribute, ignoring"); @@ -258,8 +256,9 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, if (jidp == NULL) { return 1; } - invitor = jidp->barejid; + char *invitor = jidp->barejid; + char *reason = NULL; xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON); if (reason_st != NULL) { reason = xmpp_stanza_get_text(reason_st); diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 1cb86645..19ab3c03 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -140,12 +140,6 @@ _presence_sub_request_count(void) } void -presence_free_sub_requests(void) -{ - autocomplete_free(sub_requests_ac); -} - -void presence_clear_sub_requests(void) { autocomplete_clear(sub_requests_ac); @@ -625,7 +619,7 @@ _get_caps_key(xmpp_stanza_t * const stanza) if ((hash_type != NULL) && (strcmp(hash_type, "sha-1") == 0)) { log_debug("Hash type %s supported.", hash_type); caps_key = strdup(node); - char *id = generate_unique_id("caps"); + id = generate_unique_id("caps"); _send_caps_request(node, caps_key, id, from); diff --git a/src/xmpp/presence.h b/src/xmpp/presence.h index 037fb2fd..7fc85f5b 100644 --- a/src/xmpp/presence.h +++ b/src/xmpp/presence.h @@ -25,7 +25,6 @@ void presence_sub_requests_init(void); void presence_add_handlers(void); -void presence_free_sub_requests(void); void presence_clear_sub_requests(void); #endif diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 8000da62..3c3f47fb 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -830,62 +830,6 @@ stanza_contains_caps(xmpp_stanza_t * const stanza) return TRUE; } -gboolean -stanza_is_version_request(xmpp_stanza_t * const stanza) -{ - char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE); - - if (g_strcmp0(type, STANZA_TYPE_GET) != 0) { - return FALSE; - } - - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); - - if (query == NULL) { - return FALSE; - } - - char *ns = xmpp_stanza_get_ns(query); - - if (ns == NULL) { - return FALSE; - } - - if (strcmp(ns, STANZA_NS_VERSION) != 0) { - return FALSE; - } - - return TRUE; -} - -gboolean -stanza_is_caps_request(xmpp_stanza_t * const stanza) -{ - char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE); - - if (g_strcmp0(type, STANZA_TYPE_GET) != 0) { - return FALSE; - } - - xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); - - if (query == NULL) { - return FALSE; - } - - char *ns = xmpp_stanza_get_ns(query); - - if (ns == NULL) { - return FALSE; - } - - if (strcmp(ns, XMPP_NS_DISCO_INFO) != 0) { - return FALSE; - } - - return TRUE; -} - char * stanza_caps_get_hash(xmpp_stanza_t * const stanza) { @@ -957,8 +901,6 @@ stanza_get_error_message(xmpp_stanza_t *stanza) // otherwise check each defined-condition RFC-6120 8.3.3 } else { - xmpp_stanza_t *cond_stanza = NULL; - gchar *defined_conditions[] = { STANZA_NAME_BAD_REQUEST, STANZA_NAME_CONFLICT, @@ -985,7 +927,7 @@ stanza_get_error_message(xmpp_stanza_t *stanza) int i; for (i = 0; i < ARRAY_SIZE(defined_conditions); i++) { - cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]); + xmpp_stanza_t *cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]); if (cond_stanza != NULL) { char *result = strdup(xmpp_stanza_get_name(cond_stanza)); return result; diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 486421a2..cddc37ea 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -192,9 +192,6 @@ int stanza_get_idle_time(xmpp_stanza_t * const stanza); char * stanza_get_caps_str(xmpp_stanza_t * const stanza); gboolean stanza_contains_caps(xmpp_stanza_t * const stanza); char * stanza_caps_get_hash(xmpp_stanza_t * const stanza); -gboolean stanza_is_caps_request(xmpp_stanza_t * const stanza); - -gboolean stanza_is_version_request(xmpp_stanza_t * const stanza); DataForm * stanza_create_form(xmpp_stanza_t * const stanza); void stanza_destroy_form(DataForm *form); |