]> jfr.im git - irc/gunnarbeutner/shroudbnc.git/commitdiff
Remove redundant null checks.
authorGunnar Beutner <redacted>
Thu, 6 Feb 2014 18:19:49 +0000 (19:19 +0100)
committerGunnar Beutner <redacted>
Fri, 7 Feb 2014 08:49:41 +0000 (09:49 +0100)
src/ClientConnection.cpp
src/Log.cpp

index 7cc2a738de9224f09c376188d72b1f17773df3f1..4f69f8a1dfda70be1622ba46884850d4fe23c7c8 100644 (file)
@@ -1818,6 +1818,13 @@ bool CClientConnection::ParseLineArgV(int argc, const char **argv) {
 
                                        if (Chan && Chan->HasNames() != 0) {
                                                char *Nicks = (char *)malloc(1);
+
+                                               if (Nicks == NULL) {
+                                                       Kill("CClientConnection::ParseLineArgV: malloc() failed. Please reconnect.");
+
+                                                       return false;
+                                               }
+
                                                Nicks[0] = '\0';
 
                                                const CHashtable<CNick *, false> *H = Chan->GetNames();
@@ -1848,7 +1855,7 @@ bool CClientConnection::ParseLineArgV(int argc, const char **argv) {
                                                                continue;
                                                        }
 
-                                                       Size = (Nicks ? strlen(Nicks) : 0) + strlen(outPref) + strlen(Nick) + 2;
+                                                       Size = strlen(Nicks) + strlen(outPref) + strlen(Nick) + 2;
                                                        Nicks = (char *)realloc(Nicks, Size);
 
                                                        if (Nicks == NULL) {
@@ -1918,6 +1925,13 @@ bool CClientConnection::ParseLineArgV(int argc, const char **argv) {
                                        }
 
                                        char *Feats = (char *)malloc(1);
+
+                                       if (Feats == NULL) {
+                                               Kill("CClientConnection::ParseLineArgV: malloc() failed. Please reconnect.");
+
+                                               return false;
+                                       }
+
                                        Feats[0] = '\0';
 
                                        int a = 0, i = 0;
@@ -1927,7 +1941,7 @@ bool CClientConnection::ParseLineArgV(int argc, const char **argv) {
                                                char *Name = Feat->Name;
                                                char *Value = Feat->Value;
 
-                                               Size = (Feats ? strlen(Feats) : 0) + strlen(Name) + 1 + strlen(Value) + 2;
+                                               Size = strlen(Feats) + strlen(Name) + 1 + strlen(Value) + 2;
                                                Feats = (char *)realloc(Feats, Size);
 
                                                if (Feats == NULL) {
@@ -1943,7 +1957,7 @@ bool CClientConnection::ParseLineArgV(int argc, const char **argv) {
 
                                                strmcat(Feats, Name, Size);
 
-                                               if (Value != NULL && Value[0] != '\0') {
+                                               if (Value[0] != '\0') {
                                                        strmcat(Feats, "=", Size);
                                                        strmcat(Feats, Value, Size);
                                                }
index 36056235fd4609f656e7d43534ffb5f1307dc54d..79ee28549fd595bc5514ca9c11b2ad1908af68c7 100644 (file)
@@ -115,7 +115,7 @@ void CLog::PlayToUser(CClientConnection *Client, LogType Type) const {
                                        Server = "bouncer.shroudbnc.info";
                                }
 
-                               if (Client != NULL) {
+                               if (Nick != NULL) {
                                        Client->WriteLine(":%s 372 %s :%s", Server, Nick, Line);
                                }
                        }
@@ -125,7 +125,7 @@ void CLog::PlayToUser(CClientConnection *Client, LogType Type) const {
                m_File = NULL;
        }
 
-       if (Type == Log_Motd && Client != NULL && Nick != NULL && Server != NULL) {
+       if (Type == Log_Motd && Nick != NULL && Server != NULL) {
                Client->WriteLine(":%s 376 %s :End of /MOTD command.", Server, Nick);
        }
 }