summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-06-02 19:10:05 +0200
committerattilamolnar <attilamolnar@hush.com>2013-06-04 01:49:14 +0200
commit3a01b55a118d4937b75541fbf385180f7106fa12 (patch)
tree8763f43fba9337b289a2dc3bc4fe26b88c461864
parent263c2efd960057f1cfafd40fce338605c39b0ad4 (diff)
Remove NULL checks from various Channel functions
Passing NULL to these functions are not permitted and must be avoided by the caller
-rw-r--r--src/channels.cpp36
-rw-r--r--src/modules/m_permchannels.cpp2
2 files changed, 3 insertions, 35 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 4010f819a..91f9b8072 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -94,8 +94,6 @@ std::string Channel::GetModeParameter(ModeHandler* mode)
int Channel::SetTopic(User *u, std::string &ntopic, bool forceset)
{
- if (!u)
- u = ServerInstance->FakeClient;
if (IS_LOCAL(u) && !forceset)
{
ModResult res;
@@ -119,17 +117,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();
FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic));
@@ -497,9 +486,6 @@ ModResult Channel::GetExtBanStatus(User *user, char type)
*/
void Channel::PartUser(User *user, std::string &reason)
{
- if (!user)
- return;
-
Membership* memb = GetUser(user);
if (memb)
@@ -518,9 +504,6 @@ void Channel::PartUser(User *user, std::string &reason)
void Channel::KickUser(User *src, User *user, const std::string& reason)
{
- if (!src || !user)
- return;
-
Membership* memb = GetUser(user);
if (IS_LOCAL(src))
{
@@ -580,9 +563,6 @@ void Channel::KickUser(User *src, User *user, const std::string& reason)
void Channel::WriteChannel(User* user, const char* text, ...)
{
- if (!user || !text)
- return;
-
std::string textbuffer;
VAFORMAT(textbuffer, text, text);
this->WriteChannel(user, textbuffer);
@@ -590,9 +570,6 @@ void Channel::WriteChannel(User* user, const char* text, ...)
void Channel::WriteChannel(User* user, const std::string &text)
{
- if (!user)
- return;
-
const std::string message = ":" + user->GetFullHost() + " " + text;
for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
@@ -604,9 +581,6 @@ void Channel::WriteChannel(User* user, const std::string &text)
void Channel::WriteChannelWithServ(const std::string& ServName, const char* text, ...)
{
- if (!text)
- return;
-
std::string textbuffer;
VAFORMAT(textbuffer, text, text);
this->WriteChannelWithServ(ServName, textbuffer);
@@ -627,9 +601,6 @@ void Channel::WriteChannelWithServ(const std::string& ServName, const std::strin
* for the sender (for privmsg etc) */
void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...)
{
- if (!text)
- return;
-
std::string textbuffer;
VAFORMAT(textbuffer, text, text);
this->WriteAllExceptSender(user, serversource, status, textbuffer);
@@ -637,9 +608,6 @@ void Channel::WriteAllExceptSender(User* user, bool serversource, char status, c
void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...)
{
- if (!text)
- return;
-
std::string textbuffer;
VAFORMAT(textbuffer, text, text);
textbuffer = ":" + (serversource ? ServerInstance->Config->ServerName : user->GetFullHost()) + " " + textbuffer;
diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp
index 0bf67ed76..8aa888485 100644
--- a/src/modules/m_permchannels.cpp
+++ b/src/modules/m_permchannels.cpp
@@ -232,7 +232,7 @@ public:
c = new Channel(channel, ServerInstance->Time());
if (!topic.empty())
{
- c->SetTopic(NULL, topic, true);
+ c->SetTopic(ServerInstance->FakeClient, topic, true);
/*
* Due to the way protocol works in 1.2, we need to hack the topic TS in such a way that this