diff options
author | Peter Powell <petpow@saberuk.com> | 2013-12-11 05:05:36 +0000 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-01-21 00:43:12 +0100 |
commit | d0a472641b7c77fe5f40a6affb62de67be2ee888 (patch) | |
tree | 66fd6a7d57d2ca63f4251fb245d3d214d4210d75 | |
parent | b8f0e349ce8891d6236fc026c47139af1f05912c (diff) |
Fix some logically dead code which was found by Coverity.
-rw-r--r-- | src/channels.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_joinflood.cpp | 15 | ||||
-rw-r--r-- | src/users.cpp | 16 |
3 files changed, 9 insertions, 34 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index b5132c8b3..c546e68db 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -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(); diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index 40f7f1ba9..4524a93c0 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -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; } } } diff --git a/src/users.cpp b/src/users.cpp index 6b2432cc4..573d4db90 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -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()) |