about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@openmailbox.org>2015-10-09 10:34:58 +0200
committerMichael Vetter <jubalh@openmailbox.org>2015-10-09 10:34:58 +0200
commit8dfa41ea8e05262225c83e38ccba1ea83f10e4b8 (patch)
treef4f3587a2ec1fc48bd19d5cc34e08cf20e02242d
parentde15d47be4bb43f039a27bbd39dc41fd7e10ad59 (diff)
downloadprofani-tty-8dfa41ea8e05262225c83e38ccba1ea83f10e4b8.tar.gz
Remove double declaration and reduce scope of pcontact
In command/commands.c you declare pcontact at the top of the function.
Later in one case you declare it again and use it in a small scope. And
in the same function you use it again this time from the first
declaration. I think you intended only declaring it one time. At first I
thought about top of the function because its easier to find. Then I saw
that you declare "Jid jid" not at the top too, and I think for the sake
of reducing scope it is better. So I went for this approach.
-rw-r--r--src/command/commands.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index eb4aa03f..4fe77f90 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2012,7 +2012,6 @@ cmd_info(ProfWin *window, const char * const command, gchar **args)
     char *usr = args[0];
 
     jabber_conn_status_t conn_status = jabber_get_connection_status();
-    PContact pcontact = NULL;
 
     if (conn_status != JABBER_CONNECTED) {
         cons_show("You are not currently connected.");
@@ -2075,7 +2074,7 @@ cmd_info(ProfWin *window, const char * const command, gchar **args)
                 if (usr_jid == NULL) {
                     usr_jid = usr;
                 }
-                pcontact = roster_get_contact(usr_jid);
+                PContact pcontact = roster_get_contact(usr_jid);
                 if (pcontact) {
                     cons_show_info(pcontact);
                 } else {
@@ -2096,7 +2095,6 @@ gboolean
 cmd_caps(ProfWin *window, const char * const command, gchar **args)
 {
     jabber_conn_status_t conn_status = jabber_get_connection_status();
-    PContact pcontact = NULL;
     Occupant *occupant = NULL;
 
     if (conn_status != JABBER_CONNECTED) {
@@ -2130,7 +2128,7 @@ cmd_caps(ProfWin *window, const char * const command, gchar **args)
                 if (jid->fulljid == NULL) {
                     cons_show("You must provide a full jid to the /caps command.");
                 } else {
-                    pcontact = roster_get_contact(jid->barejid);
+                    PContact pcontact = roster_get_contact(jid->barejid);
                     if (pcontact == NULL) {
                         cons_show("Contact not found in roster: %s", jid->barejid);
                     } else {
@@ -2173,7 +2171,6 @@ gboolean
 cmd_software(ProfWin *window, const char * const command, gchar **args)
 {
     jabber_conn_status_t conn_status = jabber_get_connection_status();
-    Occupant *occupant = NULL;
 
     if (conn_status != JABBER_CONNECTED) {
         cons_show("You are not currently connected.");
@@ -2186,7 +2183,7 @@ cmd_software(ProfWin *window, const char * const command, gchar **args)
             if (args[0]) {
                 ProfMucWin *mucwin = (ProfMucWin*)window;
                 assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
-                occupant = muc_roster_item(mucwin->roomjid, args[0]);
+                Occupant *occupant = muc_roster_item(mucwin->roomjid, args[0]);
                 if (occupant) {
                     Jid *jid = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]);
                     iq_send_software_version(jid->fulljid);