summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-11-17 04:04:24 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-11-17 04:04:24 +0000
commite10fe1cd767cf479837eecc1e1b26615d63ea5ac (patch)
treed1fbb79219d5598cd2370eb54f8a75aa5b9f25ef /src
parent88330c07adc5bb3b085cf6ede1d30c0c48afcfb6 (diff)
Removed some unnecessary casts, used C++-style casts over C-style casts, fixed a few warnings (one possibly fatal one).
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2655 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r--src/botserv.c2
-rw-r--r--src/channels.c12
-rw-r--r--src/core/cs_list.c4
-rw-r--r--src/core/os_akill.c2
-rw-r--r--src/core/os_news.c6
-rw-r--r--src/modulemanager.cpp4
-rw-r--r--src/nickcore.cpp4
-rw-r--r--src/operserv.c10
-rw-r--r--src/process.c2
-rw-r--r--src/protocol/bahamut.c6
-rw-r--r--src/protocol/inspircd11.c6
-rw-r--r--src/protocol/inspircd12.cpp8
-rw-r--r--src/protocol/ratbox.c4
-rw-r--r--src/protocol/unreal32.c6
-rw-r--r--src/regchannel.cpp30
-rw-r--r--src/slist.c4
-rw-r--r--src/users.c6
-rw-r--r--src/wildcard.cpp6
18 files changed, 60 insertions, 62 deletions
diff --git a/src/botserv.c b/src/botserv.c
index e56e75d40..7c1657187 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -348,7 +348,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
if (BSGentleBWReason)
bot_kick(ci, u, BOT_REASON_BADWORD_GENTLE);
else
- bot_kick(ci, u, BOT_REASON_BADWORD, bw->word);
+ bot_kick(ci, u, BOT_REASON_BADWORD, bw->word.c_str());
/* free the normalized buffer before return (#850) */
delete [] nbuf;
diff --git a/src/channels.c b/src/channels.c
index 57c9917e1..ef5e225f6 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -62,7 +62,7 @@ Channel::Channel(const std::string &name, time_t ts)
if (serv_uplink && is_sync(serv_uplink) && (!(this->topic_sync)))
restore_topic(name.c_str());
-
+
FOREACH_MOD(I_OnChannelCreate, OnChannelCreate(this));
}
@@ -76,7 +76,7 @@ Channel::~Channel()
if (debug)
alog("debug: Deleting channel %s", this->name);
-
+
for (bd = this->bd; bd; bd = next)
{
if (bd->mask)
@@ -130,7 +130,7 @@ Channel::~Channel()
*/
bool Channel::HasMode(ChannelModeName Name)
{
- return modes[(size_t)Name];
+ return modes[Name];
}
/**
@@ -139,7 +139,7 @@ bool Channel::HasMode(ChannelModeName Name)
*/
void Channel::SetMode(ChannelModeName Name)
{
- modes[(size_t)Name] = true;
+ modes[Name] = true;
/* Channel mode +P or so was set, mark this channel as persistant */
if (Name == CMODE_PERM && ci)
@@ -170,7 +170,7 @@ void Channel::SetMode(char Mode)
*/
void Channel::RemoveMode(ChannelModeName Name)
{
- modes[(size_t)Name] = false;
+ modes[Name] = false;
if (Name == CMODE_PERM && ci)
{
@@ -271,7 +271,7 @@ void Channel::ClearModes(char *client)
for (size_t n = CMODE_BEGIN + 1; n != CMODE_END; ++n)
{
- cm = ModeManager::FindChannelModeByName((ChannelModeName)n);
+ cm = ModeManager::FindChannelModeByName(static_cast<ChannelModeName>(n));
if (cm && this->HasMode(cm->Name))
{
diff --git a/src/core/cs_list.c b/src/core/cs_list.c
index 68975cadf..93ffeffa5 100644
--- a/src/core/cs_list.c
+++ b/src/core/cs_list.c
@@ -36,9 +36,7 @@ public:
int count = 0, from = 0, to = 0, tofree = 0;
char *tmp = NULL;
char *s = NULL;
- bool forbidden, suspended, channoexpire;
-
- forbidden = suspended = noexpire = false;
+ bool forbidden = false, suspended = false, channoexpire = false;
if (!(!CSListOpersOnly || (is_oper(u))))
{
diff --git a/src/core/os_akill.c b/src/core/os_akill.c
index d7f2cddbd..32169e2d4 100644
--- a/src/core/os_akill.c
+++ b/src/core/os_akill.c
@@ -176,7 +176,7 @@ class CommandOSAKill : public Command
}
else
{
- if ((res = slist_indexof(&akills, (void *)mask)) == -1)
+ if ((res = slist_indexof(&akills, const_cast<void *>(static_cast<const void *>(mask)))) == -1) // XXX: possibly unsafe cast
{
notice_lang(s_OperServ, u, OPER_AKILL_NOT_FOUND, mask);
return MOD_CONT;
diff --git a/src/core/os_news.c b/src/core/os_news.c
index e06be7223..6720dd026 100644
--- a/src/core/os_news.c
+++ b/src/core/os_news.c
@@ -109,7 +109,7 @@ void load_news()
news = new NewsItem;
SAFE(read_int16(&type, f));
- news->type = (NewsType)type;
+ news->type = static_cast<NewsType>(type);
SAFE(read_int32(&news->num, f));
SAFE(read_string(&text, f));
news->Text = text;
@@ -219,7 +219,7 @@ static void DisplayNews(User *u, NewsType Type)
static int add_newsitem(User * u, const char *text, NewsType type)
{
int num = 0;
-
+
for (unsigned i = News.size(); i > 0; --i)
{
if (News[i - 1]->type == type)
@@ -228,7 +228,7 @@ static int add_newsitem(User * u, const char *text, NewsType type)
break;
}
}
-
+
NewsItem *news = new NewsItem;
news->type = type;
news->num = num + 1;
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index e3a93b680..738c2f4ec 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -346,13 +346,13 @@ void ModuleManager::Attach(Implementation* i, Module* mod, size_t sz)
void ModuleManager::DetachAll(Module* mod)
{
for (size_t n = I_BEGIN + 1; n != I_END; ++n)
- Detach((Implementation)n, mod);
+ Detach(static_cast<Implementation>(n), mod);
}
bool ModuleManager::SetPriority(Module* mod, Priority s)
{
for (size_t n = I_BEGIN + 1; n != I_END; ++n)
- SetPriority(mod, (Implementation)n, s);
+ SetPriority(mod, static_cast<Implementation>(n), s);
return true;
}
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index c607fffba..425cb0d93 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -25,8 +25,8 @@ NickCore::NickCore(const std::string &coredisplay)
/* Set default nick core flags */
for (size_t t = NI_BEGIN + 1; t != NI_END; ++t)
- if (NSDefFlags.HasFlag((NickCoreFlag)t))
- SetFlag((NickCoreFlag)t);
+ if (NSDefFlags.HasFlag(static_cast<NickCoreFlag>(t)))
+ SetFlag(static_cast<NickCoreFlag>(t));
}
/** Default destructor
diff --git a/src/operserv.c b/src/operserv.c
index 4acedbbd9..a875769cd 100644
--- a/src/operserv.c
+++ b/src/operserv.c
@@ -51,7 +51,7 @@ bool SetDefConParam(ChannelModeName Name, std::string &buf)
bool GetDefConParam(ChannelModeName Name, std::string *buf)
{
std::map<ChannelModeName, std::string>::iterator it = DefConModesOnParams.find(Name);
-
+
buf->clear();
if (it != DefConModesOnParams.end())
@@ -1203,7 +1203,7 @@ static int is_szline_entry_equal(SList * slist, void *item1, void *item2)
bool CheckDefCon(DefconLevel Level)
{
if (DefConLevel)
- return DefCon[DefConLevel][(size_t)Level];
+ return DefCon[DefConLevel][Level];
return false;
}
@@ -1214,7 +1214,7 @@ bool CheckDefCon(DefconLevel Level)
*/
bool CheckDefCon(int level, DefconLevel Level)
{
- return DefCon[level][(size_t)Level];
+ return DefCon[level][Level];
}
/** Add a defcon level option to a defcon level
@@ -1223,7 +1223,7 @@ bool CheckDefCon(int level, DefconLevel Level)
*/
void AddDefCon(int level, DefconLevel Level)
{
- DefCon[level][(size_t)Level] = true;
+ DefCon[level][Level] = true;
}
/** Remove a defcon level option from a defcon level
@@ -1232,6 +1232,6 @@ void AddDefCon(int level, DefconLevel Level)
*/
void DelDefCon(int level, DefconLevel Level)
{
- DefCon[level][(size_t)Level] = false;
+ DefCon[level][Level] = false;
}
diff --git a/src/process.c b/src/process.c
index b0a4bd728..861f44beb 100644
--- a/src/process.c
+++ b/src/process.c
@@ -262,7 +262,7 @@ int split_buf(char *buf, const char ***argv, int colon_special)
}
if (*buf == ':') {
(*argv)[argc++] = buf + 1;
- buf = (char *)""; // XXX: unsafe cast.
+ buf = const_cast<char *>(""); // XXX: unsafe cast.
} else {
s = strpbrk(buf, " ");
if (s) {
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c
index 709b1a67e..b89bce40a 100644
--- a/src/protocol/bahamut.c
+++ b/src/protocol/bahamut.c
@@ -765,9 +765,9 @@ class ProtoBahamut : public Module
moduleAddModes();
- ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
- ircd->DefMLock[(size_t)CMODE_REGISTERED] = true;
+ ircd->DefMLock[CMODE_NOEXTERNAL] = true;
+ ircd->DefMLock[CMODE_TOPIC] = true;
+ ircd->DefMLock[CMODE_REGISTERED] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c
index ff71d233d..9742a9c81 100644
--- a/src/protocol/inspircd11.c
+++ b/src/protocol/inspircd11.c
@@ -1108,9 +1108,9 @@ class ProtoInspIRCd : public Module
moduleAddModes();
- ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
- ircd->DefMLock[(size_t)CMODE_REGISTERED] = true;
+ ircd->DefMLock[CMODE_NOEXTERNAL] = true;
+ ircd->DefMLock[CMODE_TOPIC] = true;
+ ircd->DefMLock[CMODE_REGISTERED] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp
index fb6d5db2a..bad484010 100644
--- a/src/protocol/inspircd12.cpp
+++ b/src/protocol/inspircd12.cpp
@@ -150,7 +150,7 @@ int anope_event_idle(const char *source, int ac, const char **av)
if (!bi)
return MOD_CONT;
- send_cmd(bi->uid, "IDLE %s %ld %ld", source, start_time, time(NULL) - bi->lastmsg);
+ send_cmd(bi->uid, "IDLE %s %ld %ld", source, static_cast<long>(start_time), static_cast<long>(time(NULL) - bi->lastmsg));
return MOD_CONT;
}
@@ -1296,9 +1296,9 @@ class ProtoInspIRCd : public Module
moduleAddModes();
- ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
- ircd->DefMLock[(size_t)CMODE_REGISTERED] = true;
+ ircd->DefMLock[CMODE_NOEXTERNAL] = true;
+ ircd->DefMLock[CMODE_TOPIC] = true;
+ ircd->DefMLock[CMODE_REGISTERED] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c
index 29aa8ef23..097f47f8d 100644
--- a/src/protocol/ratbox.c
+++ b/src/protocol/ratbox.c
@@ -899,8 +899,8 @@ class ProtoRatbox : public Module
moduleAddModes();
- ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
+ ircd->DefMLock[CMODE_NOEXTERNAL] = true;
+ ircd->DefMLock[CMODE_TOPIC] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c
index 46a94cbf8..9e46ea6e4 100644
--- a/src/protocol/unreal32.c
+++ b/src/protocol/unreal32.c
@@ -1235,9 +1235,9 @@ class ProtoUnreal : public Module
moduleAddModes();
- ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
- ircd->DefMLock[(size_t)CMODE_REGISTERED] = true;
+ ircd->DefMLock[CMODE_NOEXTERNAL] = true;
+ ircd->DefMLock[CMODE_TOPIC] = true;
+ ircd->DefMLock[CMODE_REGISTERED] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 2b1dee411..1ecb97697 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -40,18 +40,18 @@ ChannelInfo::ChannelInfo(const std::string &chname)
/* If ircd doesn't exist, this is from DB load and mlock is set later */
if (ircd)
mlock_on = ircd->DefMLock;
-
+
size_t t;
/* Set default channel flags */
for (t = CI_BEGIN + 1; t != CI_END - 1; ++t)
- if (CSDefFlags.HasFlag((ChannelInfoFlag)t))
- this->SetFlag((ChannelInfoFlag)t);
+ if (CSDefFlags.HasFlag(static_cast<ChannelInfoFlag>(t)))
+ this->SetFlag(static_cast<ChannelInfoFlag>(t));
/* Set default bot flags */
for (t = BI_BEGIN + 1; t != BI_END; ++t)
- if (BSDefFlags.HasFlag((BotServFlag)t))
- this->botflags.SetFlag((BotServFlag)t);
-
+ if (BSDefFlags.HasFlag(static_cast<BotServFlag>(t)))
+ this->botflags.SetFlag(static_cast<BotServFlag>(t));
+
bantype = CSDefBantype;
memos.memomax = MSMaxMemos;
last_used = time_registered = time(NULL);
@@ -59,7 +59,7 @@ ChannelInfo::ChannelInfo(const std::string &chname)
this->ttb = new int16[2 * TTB_SIZE];
for (int i = 0; i < TTB_SIZE; i++)
this->ttb[i] = 0;
-
+
reset_levels(this);
alpha_insert_chan(this);
}
@@ -174,7 +174,7 @@ ChanAccess *ChannelInfo::GetAccess(unsigned index)
* @param level Optional channel access level to compare the access entries to
* @return A ChanAccess struct corresponding to the NickCore, or NULL if not found
*
- * Retrieves an entry from the access list that matches the given NickCore, optionally also matching a
+ * Retrieves an entry from the access list that matches the given NickCore, optionally also matching a
certain level.
*/
@@ -286,7 +286,7 @@ AutoKick *ChannelInfo::GetAkick(unsigned index)
{
if (akick.empty() || index >= akick.size())
return NULL;
-
+
return akick[index];
}
@@ -332,7 +332,7 @@ BadWord *ChannelInfo::AddBadWord(const std::string &word, BadWordType type)
BadWord *bw = new BadWord;
bw->word = word;
bw->type = type;
-
+
badwords.push_back(bw);
return bw;
}
@@ -345,7 +345,7 @@ BadWord *ChannelInfo::GetBadWord(unsigned index)
{
if (badwords.empty() || index >= badwords.size())
return NULL;
-
+
return badwords[index];
}
@@ -389,9 +389,9 @@ void ChannelInfo::ClearBadWords()
const bool ChannelInfo::HasMLock(ChannelModeName Name, bool status)
{
if (status)
- return mlock_on[(size_t)Name];
+ return mlock_on[Name];
else
- return mlock_off[(size_t)Name];
+ return mlock_off[Name];
}
/** Set a mlock
@@ -400,7 +400,7 @@ const bool ChannelInfo::HasMLock(ChannelModeName Name, bool status)
*/
void ChannelInfo::SetMLock(ChannelModeName Name, bool status)
{
- size_t value = (size_t)Name;
+ size_t value = Name;
if (status)
mlock_on[value] = true;
@@ -414,7 +414,7 @@ void ChannelInfo::SetMLock(ChannelModeName Name, bool status)
*/
void ChannelInfo::RemoveMLock(ChannelModeName Name, bool status)
{
- size_t value = (size_t)Name;
+ size_t value = Name;
if (status)
mlock_on[value] = false;
diff --git a/src/slist.c b/src/slist.c
index 8fcbd9e0c..a88c1a3dd 100644
--- a/src/slist.c
+++ b/src/slist.c
@@ -131,7 +131,7 @@ int slist_delete_range(SList * slist, const char *crange, slist_delcheckcb_t cb,
{
int count = 0, i, n1, n2;
va_list args, preserve;
- char *range = (char *)crange;
+ char *range = const_cast<char *>(crange); // XXX: unsafe cast
va_start(args, cb);
@@ -205,7 +205,7 @@ int slist_enum(SList * slist, const char *crange, slist_enumcb_t cb, ...)
{
int count = 0, i, res;
va_list args, preserve;
- char *range = (char *)crange;
+ char *range = const_cast<char *>(crange); // XXX: unsafe cast
va_start(args, cb);
diff --git a/src/users.c b/src/users.c
index bdbb552d3..a54506f8c 100644
--- a/src/users.c
+++ b/src/users.c
@@ -466,7 +466,7 @@ User *finduser(const char *nick)
*/
const bool User::HasMode(UserModeName Name) const
{
- return modes[(size_t)Name];
+ return modes[Name];
}
/** Set a mode on the user
@@ -474,7 +474,7 @@ const bool User::HasMode(UserModeName Name) const
*/
void User::SetMode(UserModeName Name)
{
- modes[(size_t)Name] = true;
+ modes[Name] = true;
FOREACH_MOD(I_OnUserModeSet, OnUserModeSet(this, Name));
}
@@ -496,7 +496,7 @@ void User::SetMode(char ModeChar)
*/
void User::RemoveMode(UserModeName Name)
{
- modes[(size_t)Name] = false;
+ modes[Name] = false;
FOREACH_MOD(I_OnUserModeUnset, OnUserModeUnset(this, Name));
}
diff --git a/src/wildcard.cpp b/src/wildcard.cpp
index b66b8b29c..59f2cc8e7 100644
--- a/src/wildcard.cpp
+++ b/src/wildcard.cpp
@@ -3,8 +3,8 @@
static bool match_internal(const unsigned char *str, const unsigned char *mask, bool case_sensitive)
{
unsigned char *cp = NULL, *mp = NULL;
- unsigned char* string = (unsigned char*)str;
- unsigned char* wild = (unsigned char*)mask;
+ unsigned char *string = const_cast<unsigned char *>(str); // XXX: unsafe cast
+ unsigned char *wild = const_cast<unsigned char *>(mask); // XXX: unsafe cast
while ((*string) && (*wild != '*'))
{
@@ -77,5 +77,5 @@ static bool match_internal(const unsigned char *str, const unsigned char *mask,
CoreExport bool Anope::Match(const std::string &str, const std::string &mask, bool case_sensitive)
{
- return match_internal((const unsigned char *)str.c_str(), (const unsigned char *)mask.c_str(), case_sensitive);
+ return match_internal(reinterpret_cast<const unsigned char *>(str.c_str()), reinterpret_cast<const unsigned char *>(mask.c_str()), case_sensitive);
}