mirror of
https://github.com/anope/anope.git
synced 2026-06-29 03:06:37 +02:00
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
This commit is contained in:
+9
-10
@@ -421,19 +421,18 @@ class CoreExport Extensible
|
||||
/** Class with the ability to keep flags on items, they should extend from this
|
||||
* where T is an enum.
|
||||
*/
|
||||
template <class T>
|
||||
class CoreExport Flags
|
||||
template<typename T> class CoreExport Flags
|
||||
{
|
||||
protected:
|
||||
std::bitset<128> Flag_Values;
|
||||
std::bitset<128> Flag_Values;
|
||||
|
||||
public:
|
||||
/** Add a flag to this item
|
||||
/** Add a flag to this item
|
||||
* @param Value The flag
|
||||
*/
|
||||
void SetFlag(T Value)
|
||||
{
|
||||
Flag_Values[(size_t)Value] = true;
|
||||
Flag_Values[Value] = true;
|
||||
}
|
||||
|
||||
/** Remove a flag from this item
|
||||
@@ -441,22 +440,22 @@ class CoreExport Flags
|
||||
*/
|
||||
void UnsetFlag(T Value)
|
||||
{
|
||||
Flag_Values[(size_t)Value] = false;
|
||||
Flag_Values[Value] = false;
|
||||
}
|
||||
|
||||
/** Check if this item has a flag
|
||||
* @param Value The flag
|
||||
* @return true or false
|
||||
*/
|
||||
const bool HasFlag(T Value) const
|
||||
bool HasFlag(T Value) const
|
||||
{
|
||||
return Flag_Values[(size_t)Value];
|
||||
return Flag_Values[Value];
|
||||
}
|
||||
|
||||
/** Check how many flags are set
|
||||
* @return The number of flags set
|
||||
*/
|
||||
const size_t FlagCount() const
|
||||
size_t FlagCount() const
|
||||
{
|
||||
return Flag_Values.count();
|
||||
}
|
||||
@@ -1838,7 +1837,7 @@ class NickServRelease : public Timer
|
||||
* @param delay The delay before the nick is released
|
||||
*/
|
||||
NickServRelease(NickAlias *nickalias, time_t delay);
|
||||
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
~NickServRelease();
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+6
-6
@@ -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))
|
||||
{
|
||||
|
||||
+1
-3
@@ -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))))
|
||||
{
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
+5
-5
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
+15
-15
@@ -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;
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
|
||||
+3
-3
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user