]> jfr.im git - irc/unrealircd/unrealircd.git/commitdiff
Get rid of a number of clang warnings.
authorBram Matthys <redacted>
Sun, 22 Apr 2018 15:06:31 +0000 (17:06 +0200)
committerBram Matthys <redacted>
Sun, 22 Apr 2018 15:06:31 +0000 (17:06 +0200)
src/ircd.c
src/modules/m_message.c
src/modules/websocket.c
src/s_debug.c
src/s_extra.c
src/scache.c

index 133b7017bca562215d31dab96fa5305169b4f77f..0e40997138d51e50a750c09d87dd6ffdf8453a46 100644 (file)
@@ -1231,7 +1231,11 @@ int InitUnrealIRCd(int argc, char *argv[])
                          exit(0);
 #endif
                  case 'U':
-                     chdir(CONFDIR);
+                     if (chdir(CONFDIR) < 0)
+                     {
+                       fprintf(stderr, "Unable to change to '%s' directory\n", CONFDIR);
+                       exit(1);
+                     }
                      update_conf();
                      exit(0);
                  case 'R':
index 3cf68f71912cf982dd9c3715edb25f945f355aab..4b5f9bc7021875ed37e2470064fd20274da77e50 100644 (file)
@@ -581,7 +581,7 @@ int size_string, ret;
                        me.name, sptr->name);
                return 0;
        }
-       for (; (*ctcp == ' '); ctcp++); /* skip leading spaces */
+       for (; *ctcp == ' '; ctcp++); /* skip leading spaces */
 
        if (*ctcp == '"' && *(ctcp+1))
                end = index(ctcp+1, '"');
index 485684d3f4254b8ed0a387923300674c418f3baf..28f77282d8f098f88f96ce2065a5dee54b6cb860 100644 (file)
@@ -266,7 +266,7 @@ int websocket_handshake_helper(char *buffer, int len, char **key, char **value,
        /* First check if the line contains a terminating \n. If not, don't process it
         * as it may have been a cut header.
         */
-       for (p; *p; p++)
+       for (; *p; p++)
        {
                if (*p == '\n')
                {
@@ -284,7 +284,7 @@ int websocket_handshake_helper(char *buffer, int len, char **key, char **value,
        
        p = k;
        
-       for (p; *p; p++)
+       for (; *p; p++)
        {
                if ((*p == '\n') || (*p == '\r'))
                {
index e627028aba64538f75d86c737202059bb5f0a364..4528eb73ecf98d1a7912d1060e353134d13ec462 100644 (file)
@@ -196,7 +196,11 @@ void debug(int level, char *form, ...)
 
 #ifndef _WIN32
                strlcat(debugbuf, "\n", sizeof(debugbuf));
-               write(debugfd, debugbuf, strlen(debugbuf));
+               if (write(debugfd, debugbuf, strlen(debugbuf)) < 0)
+               {
+                       /* Yeah.. what can we do if output isn't working? Outputting an error makes no sense */
+                       ;
+               }
 #else
                strlcat(debugbuf, "\r\n", sizeof(debugbuf));
                OutputDebugString(debugbuf);
index d5d24fc995fac08a304ac6d286439060431c81fa..b927135dead3bdc62099db8f4cac487d5261d312 100644 (file)
@@ -142,7 +142,7 @@ void dcc_wipe_services(void)
        for (dconf = conf_deny_dcc; dconf; dconf = next)
        {
                next = dconf->next;
-               if ((dconf->flag.type2 == CONF_BAN_TYPE_AKILL))
+               if (dconf->flag.type2 == CONF_BAN_TYPE_AKILL)
                {
                        DelListItem(dconf, conf_deny_dcc);
                        if (dconf->filename)
@@ -333,7 +333,13 @@ static char recursion_trap=0;
                                }
                                if (logs->logfd != -1)
                                {
-                                       write(logs->logfd, "Max file size reached, starting new log file\n", 45);
+                                       if (write(logs->logfd, "Max file size reached, starting new log file\n", 45) < 0)
+                                       {
+                                               /* We already handle the unable to write to log file case for normal data.
+                                                * I think we can get away with not handling this one.
+                                                */
+                                               ;
+                                       }
                                        fd_close(logs->logfd);
                                }
                                
@@ -370,7 +376,11 @@ static char recursion_trap=0;
                        /* this shouldn't happen, but lets not waste unnecessary syscalls... */
                        if (logs->logfd == -1)
                                continue;
-                       write(logs->logfd, timebuf, strlen(timebuf));
+                       if (write(logs->logfd, timebuf, strlen(timebuf)) < 0)
+                       {
+                               /* Let's ignore any write errors for this one. Next write() will catch it... */
+                               ;
+                       }
                        n = write(logs->logfd, buf, strlen(buf));
                        if (n == strlen(buf))
                        {
index 0f0f73879d6937ebc264d266e1c3bfa84298ee14..7b6facc75f3f40c27e982923d6685283ca43033c 100644 (file)
@@ -140,26 +140,3 @@ void count_scache(int *number_servers_cached, u_long *mem_servers_cached)
                }
        }
 }
-/*
- * list all server names in scache very verbose 
- */
-
-void list_scache(aClient *sptr)
-{
-       int  hash_index;
-       SCACHE *ptr;
-
-       for (hash_index = 0; hash_index < SCACHE_HASH_SIZE; hash_index++)
-       {
-               ptr = scache_hash[hash_index];
-               while (ptr)
-               {
-                       if (ptr->name)
-                               sendto_one(sptr,
-                                   ":%s NOTICE %s :server=%s hash=%i",
-                                   me.name, sptr->name, ptr->name, hash_index);
-                       ptr = ptr->next;
-               }
-       }
-
-}