diff main.c @ 431:a9b20b31cae1

More code cleanups, this time using clang with excessive warnings enabled. Also re-added util.h, that was missing. Oops.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 24 May 2012 20:57:06 +0300
parents aaadf6cea6be
children 966c521e0954
line wrap: on
line diff
--- a/main.c	Thu May 24 14:10:47 2012 +0300
+++ b/main.c	Thu May 24 20:57:06 2012 +0300
@@ -841,19 +841,19 @@
 typedef struct
 {
     char *cmd;
-    ssize_t len;
+    size_t len;
     int (*handler)(nn_conn_t *);
 } nn_protocolcmd_t;
 
 
 static nn_protocolcmd_t protoCmds[] =
 {
-    { "<USER>",         -1, nnproto_parse_user },
-    { "<LOGIN_",        -1, nnproto_parse_login },
-    { "<DELETE_USER>",  -1, nnproto_parse_delete_user },
-    { "<ADD_USER>",     -1, nnproto_parse_add_user },
-    { "<NUMCLIENTS>",   -1, nnproto_parse_num_clients },
-    { "<BOOT />",       -1, nnproto_parse_boot },
+    { "<USER>",         0, nnproto_parse_user },
+    { "<LOGIN_",        0, nnproto_parse_login },
+    { "<DELETE_USER>",  0, nnproto_parse_delete_user },
+    { "<ADD_USER>",     0, nnproto_parse_add_user },
+    { "<NUMCLIENTS>",   0, nnproto_parse_num_clients },
+    { "<BOOT />",       0, nnproto_parse_boot },
 };
 
 static const int nprotoCmds = sizeof(protoCmds) / sizeof(protoCmds[0]);
@@ -964,7 +964,7 @@
     {
         // Just list whomever is in ignore now
         qlist_t *user = setIgnoreList;
-        ssize_t nuser = th_llist_length(setIgnoreList);
+        size_t nuser = th_llist_length(setIgnoreList);
         char *result = th_strdup_printf("Users ignored (%d): ", nuser);
         while (user != NULL)
         {
@@ -1149,7 +1149,7 @@
 {
     char *cmd;
     int flags;
-    ssize_t len;
+    size_t len;
     int (*handler)(nn_conn_t *, char *buf);
 } nn_usercmd_t;
 
@@ -1157,24 +1157,24 @@
 static nn_usercmd_t userCmds[] =
 {
     // Server side commands, we just implement completion
-    { "me",       CMDARG_STRING,   -1, NULL },
-    { "status",   CMDARG_STRING,   -1, NULL },
-    { "list",     CMDARG_NONE,     -1, nncmd_list_all_users },
+    { "me",       CMDARG_STRING,   0, NULL },
+    { "status",   CMDARG_STRING,   0, NULL },
+    { "list",     CMDARG_NONE,     0, nncmd_list_all_users },
 
     // List internal username list
-    { "who",      CMDARG_NONE,     -1, nncmd_names },
-    { "names",    CMDARG_NONE,     -1, nncmd_names },
+    { "who",      CMDARG_NONE,     0, nncmd_names },
+    { "names",    CMDARG_NONE,     0, nncmd_names },
 
-    { "w",        CMDARG_NICK,     -1, nncmd_open_profile },
-    { "profile",  CMDARG_NICK,     -1, nncmd_open_profile },
+    { "w",        CMDARG_NICK,     0, nncmd_open_profile },
+    { "profile",  CMDARG_NICK,     0, nncmd_open_profile },
 
-    { "query",    CMDARG_NICK,     -1, nncmd_open_query },
-    { "close",    CMDARG_OPTIONAL, -1, nncmd_close_query },
-    { "win",      CMDARG_OPTIONAL, -1, nncmd_window_info },
+    { "query",    CMDARG_NICK,     0, nncmd_open_query },
+    { "close",    CMDARG_OPTIONAL, 0, nncmd_close_query },
+    { "win",      CMDARG_OPTIONAL, 0, nncmd_window_info },
 
-    { "ignore",   CMDARG_NICK,     -1, nncmd_ignore },
-    { "color",    CMDARG_STRING,   -1, nncmd_set_color },
-    { "save",     CMDARG_NONE,     -1, nncmd_save_config },
+    { "ignore",   CMDARG_NICK,     0, nncmd_ignore },
+    { "color",    CMDARG_STRING,   0, nncmd_set_color },
+    { "save",     CMDARG_NONE,     0, nncmd_save_config },
 };
 
 static const int nuserCmds = sizeof(userCmds) / sizeof(userCmds[0]);
@@ -1274,7 +1274,7 @@
     {
         if (currWin->id != NULL)
         {
-            char *tmp, *msg = th_strdup_printf("/prv -to %s -msg %s", currWin->id, buf);
+            char *msg = th_strdup_printf("/prv -to %s -msg %s", currWin->id, buf);
             if (msg == NULL) return -3;
             tmp = nn_dblencode_str(msg);
             if (tmp == NULL)
@@ -1345,7 +1345,7 @@
          newPattern = FALSE, hasSpace = FALSE, isCommand;
     char *str = buf->data;
     int mode = 0;
-    ssize_t endPos, startPos = buf->pos;
+    size_t endPos, startPos = buf->pos;
 
     // previous word
     if (startPos >= 2 && str[startPos - 1] == ' ' && str[startPos - 2] != ' ')
@@ -1448,7 +1448,7 @@
 
         if (user)
         {
-            int i;
+            size_t i;
             char *c = user->name;
             if (optDebug)
                 printMsg(currWin, "match='%s' / prev='%s'\n", user->name, previous);
@@ -1562,7 +1562,7 @@
 char *promptRequester(WINDOW *win, const char *info, BOOL allowEmpty)
 {
     char tmpBuf[512], *ptr;
-    ssize_t pos;
+    size_t pos;
     int curVis = curs_set(1);
 
     echo();