]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix some logically dead code which was found by Coverity.
authorPeter Powell <petpow@saberuk.com>
Wed, 11 Dec 2013 05:05:36 +0000 (05:05 +0000)
committerAttila Molnar <attilamolnar@hush.com>
Mon, 20 Jan 2014 23:43:12 +0000 (00:43 +0100)
src/channels.cpp
src/modules/m_joinflood.cpp
src/users.cpp

index b5132c8b3de7b008a51ec0f5f6d36b4710429728..c546e68db0e91180fe4afb1756f8ce143f0b19f6 100644 (file)
@@ -116,16 +116,8 @@ int Channel::SetTopic(User *u, std::string &ntopic, bool forceset)
        }
 
        this->topic.assign(ntopic, 0, ServerInstance->Config->Limits.MaxTopic);
-       if (u)
-       {
-               this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128);
-               this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
-       }
-       else
-       {
-               this->setby.assign(ServerInstance->Config->ServerName);
-               this->WriteChannelWithServ(ServerInstance->Config->ServerName, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
-       }
+       this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128);
+       this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
 
        this->topicset = ServerInstance->Time();
 
index 40f7f1ba9865a7b246d8f20a9f122b824db12d37..4524a93c0ef4bc0e12bce72095385ed4e914dc40 100644 (file)
@@ -153,17 +153,10 @@ class JoinFlood : public ModeHandler
                                                else
                                                {
                                                        // new mode param, replace old with new
-                                                       if ((nsecs > 0) && (njoins > 0))
-                                                       {
-                                                               f = new joinfloodsettings(nsecs, njoins);
-                                                               ext.set(channel, f);
-                                                               channel->SetModeParam('j', parameter);
-                                                               return MODEACTION_ALLOW;
-                                                       }
-                                                       else
-                                                       {
-                                                               return MODEACTION_DENY;
-                                                       }
+                                                       f = new joinfloodsettings(nsecs, njoins);
+                                                       ext.set(channel, f);
+                                                       channel->SetModeParam('j', parameter);
+                                                       return MODEACTION_ALLOW;
                                                }
                                        }
                                }
index 6b2432cc4efd502434fdb50cbe3c5f1a1cc33fc7..573d4db904c40e48007506a5ef84044f5f26075a 100644 (file)
@@ -1549,7 +1549,7 @@ void User::SplitChanList(User* dest, const std::string &cl)
 {
        std::string line;
        std::ostringstream prefix;
-       std::string::size_type start, pos, length;
+       std::string::size_type start, pos;
 
        prefix << this->nick << " " << dest->nick << " :";
        line = prefix.str();
@@ -1557,23 +1557,13 @@ void User::SplitChanList(User* dest, const std::string &cl)
 
        for (start = 0; (pos = cl.find(' ', start)) != std::string::npos; start = pos+1)
        {
-               length = (pos == std::string::npos) ? cl.length() : pos;
-
-               if (line.length() + namelen + length - start > 510)
+               if (line.length() + namelen + pos - start > 510)
                {
                        ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
                        line = prefix.str();
                }
 
-               if(pos == std::string::npos)
-               {
-                       line.append(cl.substr(start, length - start));
-                       break;
-               }
-               else
-               {
-                       line.append(cl.substr(start, length - start + 1));
-               }
+               line.append(cl.substr(start, pos - start + 1));
        }
 
        if (line.length() != prefix.str().length())