From 36f12984d3010bfad69de0c37a3203b0c471521c Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 9 Jan 2014 13:33:33 +0100 Subject: Stop null checking pointers that are always valid --- src/command_parse.cpp | 2 +- src/modules/m_alias.cpp | 2 +- src/modules/m_banexception.cpp | 48 ++++++++++++++++++------------------------ src/modules/m_override.cpp | 2 +- src/modules/m_silence.cpp | 9 +------- src/users.cpp | 2 +- 6 files changed, 25 insertions(+), 40 deletions(-) diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 85365c0c3..20977995b 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -337,7 +337,7 @@ Command::~Command() void CommandParser::ProcessBuffer(std::string &buffer,LocalUser *user) { - if (!user || buffer.empty()) + if (buffer.empty()) return; ServerInstance->Logs->Log("USERINPUT", LOG_RAWIO, "C[%s] I :%s %s", diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 5fea846da..065b9184e 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -181,7 +181,7 @@ class ModuleAlias : public Module } // fcommands are only for local users. Spanningtree will send them back out as their original cmd. - if (!user || !IS_LOCAL(user)) + if (!IS_LOCAL(user)) { return; } diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp index b10ed3604..b29b39747 100644 --- a/src/modules/m_banexception.cpp +++ b/src/modules/m_banexception.cpp @@ -58,23 +58,19 @@ class ModuleBanException : public Module ModResult OnExtBanCheck(User *user, Channel *chan, char type) CXX11_OVERRIDE { - if (chan != NULL) - { - ListModeBase::ModeList *list = be.GetList(chan); + ListModeBase::ModeList* list = be.GetList(chan); + if (!list) + return MOD_RES_PASSTHRU; - if (!list) - return MOD_RES_PASSTHRU; + for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++) + { + if (it->mask[0] != type || it->mask[1] != ':') + continue; - for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++) + if (chan->CheckBan(user, it->mask.substr(2))) { - if (it->mask[0] != type || it->mask[1] != ':') - continue; - - if (chan->CheckBan(user, it->mask.substr(2))) - { - // They match an entry on the list, so let them pass this. - return MOD_RES_ALLOW; - } + // They match an entry on the list, so let them pass this. + return MOD_RES_ALLOW; } } @@ -83,23 +79,19 @@ class ModuleBanException : public Module ModResult OnCheckChannelBan(User* user, Channel* chan) CXX11_OVERRIDE { - if (chan) + ListModeBase::ModeList* list = be.GetList(chan); + if (!list) { - ListModeBase::ModeList *list = be.GetList(chan); - - if (!list) - { - // No list, proceed normally - return MOD_RES_PASSTHRU; - } + // No list, proceed normally + return MOD_RES_PASSTHRU; + } - for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++) + for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++) + { + if (chan->CheckBan(user, it->mask)) { - if (chan->CheckBan(user, it->mask)) - { - // They match an entry on the list, so let them in. - return MOD_RES_ALLOW; - } + // They match an entry on the list, so let them in. + return MOD_RES_ALLOW; } } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 7e0d796d7..ce9ea17e2 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -103,7 +103,7 @@ class ModuleOverride : public Module ModResult OnPreMode(User* source,User* dest,Channel* channel, const std::vector& parameters) CXX11_OVERRIDE { - if (!source || !channel) + if (!channel) return MOD_RES_PASSTHRU; if (!source->IsOper() || !IS_LOCAL(source)) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 03d2b7953..fe7418621 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -338,10 +338,7 @@ class ModuleSilence : public Module else if (target_type == TYPE_CHANNEL) { Channel* chan = (Channel*)dest; - if (chan) - { - this->OnBuildExemptList(msgtype, chan, user, status, exempt_list, ""); - } + this->OnBuildExemptList(msgtype, chan, user, status, exempt_list, ""); } return MOD_RES_PASSTHRU; } @@ -353,10 +350,6 @@ class ModuleSilence : public Module ModResult MatchPattern(User* dest, User* source, int pattern) { - /* Server source */ - if (!source || !dest) - return MOD_RES_ALLOW; - silencelist* sl = cmdsilence.ext.get(dest); if (sl) { diff --git a/src/users.cpp b/src/users.cpp index 88ae0faf4..bf099ff98 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1088,7 +1088,7 @@ void User::SendText(const std::string& linePrefix, std::stringstream& textStream */ bool User::SharesChannelWith(User *other) { - if ((!other) || (this->registered != REG_ALL) || (other->registered != REG_ALL)) + if ((this->registered != REG_ALL) || (other->registered != REG_ALL)) return false; /* Outer loop */ -- cgit v1.2.3