summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-11-17 00:02:03 +0000
committerPeter Powell <petpow@saberuk.com>2017-11-17 15:33:01 +0000
commit36040be2952186d56a6646ee7d972aaafdd4e31a (patch)
tree72be7108a94dd6bd0ea2842c53ba8890c44d12d8 /src/modules
parent3b51dfb1d611a874c3f1138d1c1ec1bb8984334c (diff)
Fix a ton of -Wsign-conversion warnings.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_alias.cpp2
-rw-r--r--src/modules/m_banredirect.cpp2
-rw-r--r--src/modules/m_callerid.cpp2
-rw-r--r--src/modules/m_chanhistory.cpp4
-rw-r--r--src/modules/m_cloaking.cpp8
-rw-r--r--src/modules/m_clones.cpp2
-rw-r--r--src/modules/m_connectban.cpp2
-rw-r--r--src/modules/m_dccallow.cpp13
-rw-r--r--src/modules/m_dnsbl.cpp4
-rw-r--r--src/modules/m_httpd.cpp8
-rw-r--r--src/modules/m_httpd_acl.cpp4
-rw-r--r--src/modules/m_ircv3_sts.cpp2
-rw-r--r--src/modules/m_messageflood.cpp5
-rw-r--r--src/modules/m_override.cpp2
-rw-r--r--src/modules/m_redirect.cpp2
-rw-r--r--src/modules/m_spanningtree/link.h2
-rw-r--r--src/modules/m_spanningtree/main.cpp8
-rw-r--r--src/modules/m_spanningtree/server.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp4
-rw-r--r--src/modules/m_spanningtree/utils.cpp4
-rw-r--r--src/modules/m_spanningtree/utils.h6
-rw-r--r--src/modules/m_timedbans.cpp2
-rw-r--r--src/modules/m_userip.cpp2
23 files changed, 51 insertions, 41 deletions
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index bdb242938..791186414 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -284,7 +284,7 @@ class ModuleAlias : public Module
{
if (isdigit(newline[i+1]))
{
- int len = ((i + 2 < newline.length()) && (newline[i+2] == '-')) ? 3 : 2;
+ size_t len = ((i + 2 < newline.length()) && (newline[i+2] == '-')) ? 3 : 2;
std::string var = newline.substr(i, len);
result.append(GetVar(var, original_line));
i += len - 1;
diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp
index 5202051f3..4c5d53d35 100644
--- a/src/modules/m_banredirect.cpp
+++ b/src/modules/m_banredirect.cpp
@@ -308,7 +308,7 @@ class ModuleBanRedirect : public Module
if (destchan)
destlimit = destchan->GetModeParameter(limitmode);
- if(destchan && destchan->IsModeSet(redirectmode) && !destlimit.empty() && (destchan->GetUserCounter() >= atoi(destlimit.c_str())))
+ if(destchan && destchan->IsModeSet(redirectmode) && !destlimit.empty() && (destchan->GetUserCounter() >= ConvToNum<size_t>(destlimit)))
{
user->WriteNumeric(ERR_BANNEDFROMCHAN, chan->name, "Cannot join channel (You are banned)");
return MOD_RES_DENY;
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index 7b56ffce4..74334cd24 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -182,7 +182,7 @@ public:
TRANSLATE1(TR_CUSTOM);
}
- void EncodeParameter(std::string& parameter, int index)
+ void EncodeParameter(std::string& parameter, unsigned int index)
{
// Send lists as-is (part of 2.0 compat)
if (parameter.find(',') != std::string::npos)
diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp
index a0929a0d0..a969ab2e2 100644
--- a/src/modules/m_chanhistory.cpp
+++ b/src/modules/m_chanhistory.cpp
@@ -70,8 +70,8 @@ class HistoryMode : public ParamMode<HistoryMode, SimpleExtItem<HistoryList> >
return MODEACTION_DENY;
unsigned int len = ConvToInt(parameter.substr(0, colon));
- int time = InspIRCd::Duration(duration);
- if (len == 0 || time < 0)
+ unsigned int time = InspIRCd::Duration(duration);
+ if (len == 0 || time == 0)
return MODEACTION_DENY;
if (len > maxlines && IS_LOCAL(source))
return MODEACTION_DENY;
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index f9a7fa380..1cfd9516c 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -187,7 +187,7 @@ class ModuleCloaking : public Module
* @param id A unique ID for this type of item (to make it unique if the item matches)
* @param len The length of the output. Maximum for MD5 is 16 characters.
*/
- std::string SegmentCloak(const std::string& item, char id, int len)
+ std::string SegmentCloak(const std::string& item, char id, size_t len)
{
std::string input;
input.reserve(key.length() + 3 + item.length());
@@ -197,7 +197,7 @@ class ModuleCloaking : public Module
input.append(item);
std::string rv = Hash->GenerateRaw(input).substr(0,len);
- for(int i=0; i < len; i++)
+ for(size_t i = 0; i < len; i++)
{
// this discards 3 bits per byte. We have an
// overabundance of bits in the hash output, doesn't
@@ -210,8 +210,8 @@ class ModuleCloaking : public Module
std::string SegmentIP(const irc::sockets::sockaddrs& ip, bool full)
{
std::string bindata;
- int hop1, hop2, hop3;
- int len1, len2;
+ size_t hop1, hop2, hop3;
+ size_t len1, len2;
std::string rv;
if (ip.sa.sa_family == AF_INET6)
{
diff --git a/src/modules/m_clones.cpp b/src/modules/m_clones.cpp
index b3e695bfd..3084b32a8 100644
--- a/src/modules/m_clones.cpp
+++ b/src/modules/m_clones.cpp
@@ -36,7 +36,7 @@ class CommandClones : public Command
std::string clonesstr = "CLONES ";
- unsigned long limit = atoi(parameters[0].c_str());
+ unsigned long limit = strtoul(parameters[0].c_str(), NULL, 10);
/*
* Syntax of a /clones reply:
diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp
index e0f9717c4..58b3bfeda 100644
--- a/src/modules/m_connectban.cpp
+++ b/src/modules/m_connectban.cpp
@@ -52,7 +52,7 @@ class ModuleConnectBan : public Module
if (u->exempt)
return;
- int range = 32;
+ unsigned char range = 32;
switch (u->client_sa.sa.sa_family)
{
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index e687e1341..12955d709 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -61,11 +61,17 @@ class DCCAllow
std::string nickname;
std::string hostmask;
time_t set_on;
- long length;
+ unsigned long length;
DCCAllow() { }
- DCCAllow(const std::string &nick, const std::string &hm, const time_t so, const long ln) : nickname(nick), hostmask(hm), set_on(so), length(ln) { }
+ DCCAllow(const std::string& nick, const std::string& hm, time_t so, unsigned long ln)
+ : nickname(nick)
+ , hostmask(hm)
+ , set_on(so)
+ , length(ln)
+ {
+ }
};
typedef std::vector<User *> userlist;
@@ -412,7 +418,8 @@ class ModuleDCCAllow : public Module
dccallowlist::iterator iter2 = dl->begin();
while (iter2 != dl->end())
{
- if (iter2->length != 0 && (iter2->set_on + iter2->length) <= ServerInstance->Time())
+ time_t expires = iter2->set_on + iter2->length;
+ if (iter2->length != 0 && expires <= ServerInstance->Time())
{
u->WriteNumeric(997, u->nick, InspIRCd::Format("DCCALLOW entry for %s has expired", iter2->nickname.c_str()));
iter2 = dl->erase(iter2);
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index b2b9c30ff..732717ff3 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -35,7 +35,7 @@ class DNSBLConfEntry : public refcountbase
EnumBanaction banaction;
EnumType type;
long duration;
- int bitmask;
+ unsigned int bitmask;
unsigned char records[256];
unsigned long stats_hits, stats_misses;
DNSBLConfEntry(): type(A_BITMASK),duration(86400),bitmask(0),stats_hits(0), stats_misses(0) {}
@@ -279,7 +279,7 @@ class ModuleDNSBL : public Module
if (tag->getString("type") == "bitmask")
{
e->type = DNSBLConfEntry::A_BITMASK;
- e->bitmask = tag->getInt("bitmask");
+ e->bitmask = tag->getInt("bitmask", 0, 0, UINT_MAX);
}
else
{
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index 05112eb9c..a20b85f9d 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -100,7 +100,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
AddToCull();
}
- std::string Response(int response)
+ std::string Response(unsigned int response)
{
switch (response)
{
@@ -191,7 +191,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
}
}
- void SendHTTPError(int response)
+ void SendHTTPError(unsigned int response)
{
HTTPHeaders empty;
std::string data = "<html><head></head><body>Server error "+ConvToStr(response)+": "+Response(response)+"<br>"+
@@ -201,7 +201,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
WriteData(data);
}
- void SendHeaders(unsigned long size, int response, HTTPHeaders &rheaders)
+ void SendHeaders(unsigned long size, unsigned int response, HTTPHeaders &rheaders)
{
WriteData(http_version + " "+ConvToStr(response)+" "+Response(response)+"\r\n");
@@ -345,7 +345,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
}
}
- void Page(std::stringstream* n, int response, HTTPHeaders *hheaders)
+ void Page(std::stringstream* n, unsigned int response, HTTPHeaders *hheaders)
{
SendHeaders(n->str().length(), response, *hheaders);
WriteData(n->str());
diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp
index 00a50d7a1..3f67fffca 100644
--- a/src/modules/m_httpd_acl.cpp
+++ b/src/modules/m_httpd_acl.cpp
@@ -93,9 +93,9 @@ class ModuleHTTPAccessList : public Module, public HTTPACLEventListener
}
}
- void BlockAccess(HTTPRequest* http, int returnval, const std::string &extraheaderkey = "", const std::string &extraheaderval="")
+ void BlockAccess(HTTPRequest* http, unsigned int returnval, const std::string &extraheaderkey = "", const std::string &extraheaderval="")
{
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "BlockAccess (%d)", returnval);
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "BlockAccess (%u)", returnval);
std::stringstream data("Access to this resource is denied by an access control list. Please contact your IRC administrator.");
HTTPDocumentResponse response(this, *http, &data, returnval);
diff --git a/src/modules/m_ircv3_sts.cpp b/src/modules/m_ircv3_sts.cpp
index ee619903a..f3b936b41 100644
--- a/src/modules/m_ircv3_sts.cpp
+++ b/src/modules/m_ircv3_sts.cpp
@@ -163,7 +163,7 @@ class ModuleIRCv3STS : public Module
if (host.empty())
throw ModuleException("<sts:host> must contain a hostname, at " + tag->getTagLocation());
- int port = tag->getInt("port");
+ unsigned int port = tag->getInt("port", 0, 0, UINT16_MAX);
if (!HasValidSSLPort(port))
throw ModuleException("<sts:port> must be a TLS port, at " + tag->getTagLocation());
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index fa929294c..bf651bb65 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -37,7 +37,10 @@ class floodsettings
time_t reset;
insp::flat_map<User*, unsigned int> counters;
- floodsettings(bool a, int b, int c) : ban(a), secs(b), lines(c)
+ floodsettings(bool a, unsigned int b, unsigned int c)
+ : ban(a)
+ , secs(b)
+ , lines(c)
{
reset = ServerInstance->Time() + secs;
}
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 2094d3c96..cb36b3f51 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -189,7 +189,7 @@ class ModuleOverride : public Module
if (chan->IsModeSet(key) && (CanOverride(user,"KEY")) && keygiven != chan->GetModeParameter(key))
return HandleJoinOverride(user, chan, keygiven, "the channel key", "+k");
- if (chan->IsModeSet(limit) && (chan->GetUserCounter() >= ConvToInt(chan->GetModeParameter(limit))) && (CanOverride(user,"LIMIT")))
+ if (chan->IsModeSet(limit) && (chan->GetUserCounter() >= ConvToNum<size_t>(chan->GetModeParameter(limit))) && (CanOverride(user,"LIMIT")))
return HandleJoinOverride(user, chan, keygiven, "the channel limit", "+l");
if (chan->IsBanned(user) && CanOverride(user,"BANWALK"))
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
index b14de9ff9..77a4925fc 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -111,7 +111,7 @@ class ModuleRedirect : public Module
{
if (chan->IsModeSet(re) && chan->IsModeSet(limitmode))
{
- if (chan->GetUserCounter() >= ConvToInt(chan->GetModeParameter(limitmode)))
+ if (chan->GetUserCounter() >= ConvToNum<size_t>(chan->GetModeParameter(limitmode)))
{
const std::string& channel = *re.ext.get(chan);
diff --git a/src/modules/m_spanningtree/link.h b/src/modules/m_spanningtree/link.h
index 632982623..465e65ff8 100644
--- a/src/modules/m_spanningtree/link.h
+++ b/src/modules/m_spanningtree/link.h
@@ -33,7 +33,7 @@ class Link : public refcountbase
std::vector<std::string> AllowMasks;
bool HiddenFromStats;
std::string Hook;
- int Timeout;
+ unsigned int Timeout;
std::string Bind;
bool Hidden;
Link(ConfigTag* Tag) : tag(Tag) {}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 2d76102bc..4acd15d62 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -273,12 +273,12 @@ void ModuleSpanningTree::AutoConnectServers(time_t curtime)
void ModuleSpanningTree::DoConnectTimeout(time_t curtime)
{
- std::map<TreeSocket*, std::pair<std::string, int> >::iterator i = Utils->timeoutlist.begin();
+ SpanningTreeUtilities::TimeoutList::iterator i = Utils->timeoutlist.begin();
while (i != Utils->timeoutlist.end())
{
TreeSocket* s = i->first;
- std::pair<std::string, int> p = i->second;
- std::map<TreeSocket*, std::pair<std::string, int> >::iterator me = i;
+ std::pair<std::string, unsigned int> p = i->second;
+ SpanningTreeUtilities::TimeoutList::iterator me = i;
i++;
if (s->GetLinkState() == DYING)
{
@@ -287,7 +287,7 @@ void ModuleSpanningTree::DoConnectTimeout(time_t curtime)
}
else if (curtime > s->age + p.second)
{
- ServerInstance->SNO->WriteToSnoMask('l',"CONNECT: Error connecting \002%s\002 (timeout of %d seconds)",p.first.c_str(),p.second);
+ ServerInstance->SNO->WriteToSnoMask('l',"CONNECT: Error connecting \002%s\002 (timeout of %u seconds)",p.first.c_str(),p.second);
Utils->timeoutlist.erase(me);
s->Close();
}
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index 50f63e117..ecdad87f8 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -86,7 +86,7 @@ void CommandServer::HandleExtra(TreeServer* newserver, const std::vector<std::st
}
if (key == "burst")
- newserver->BeginBurst(ConvToUInt64(val));
+ newserver->BeginBurst(ConvToNum<uint64_t>(val));
}
}
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 370c38d2c..f9dccf7ce 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -46,7 +46,7 @@ TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const std::string& ipaddr)
capab->capab_phase = 0;
DoConnect(ipaddr, link->Port, link->Timeout, link->Bind);
- Utils->timeoutlist[this] = std::pair<std::string, int>(linkID, link->Timeout);
+ Utils->timeoutlist[this] = std::pair<std::string, unsigned int>(linkID, link->Timeout);
SendCapabilities(1);
}
@@ -77,7 +77,7 @@ TreeSocket::TreeSocket(int newfd, ListenSocket* via, irc::sockets::sockaddrs* cl
SendCapabilities(1);
- Utils->timeoutlist[this] = std::pair<std::string, int>(linkID, 30);
+ Utils->timeoutlist[this] = std::pair<std::string, unsigned int>(linkID, 30);
}
void TreeSocket::CleanNegotiationInfo()
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 79dc24e6a..0a96ecfcd 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -118,7 +118,7 @@ CullResult SpanningTreeUtilities::cull()
sock->Close();
}
- for(std::map<TreeSocket*, std::pair<std::string, int> >::iterator i = timeoutlist.begin(); i != timeoutlist.end(); ++i)
+ for(TimeoutList::iterator i = timeoutlist.begin(); i != timeoutlist.end(); ++i)
{
TreeSocket* s = i->first;
s->Close();
@@ -235,7 +235,7 @@ void SpanningTreeUtilities::ReadConfiguration()
if (PingFreq == 0)
PingFreq = 60;
- if (PingWarnTime < 0 || PingWarnTime > PingFreq - 1)
+ if (PingWarnTime > PingFreq - 1)
PingWarnTime = 0;
AutoconnectBlocks.clear();
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index f262f9a48..3d34b93a6 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -48,7 +48,7 @@ class SpanningTreeUtilities : public classbase
public:
typedef std::set<TreeSocket*> TreeSocketSet;
- typedef std::map<TreeSocket*, std::pair<std::string, int> > TimeoutList;
+ typedef std::map<TreeSocket*, std::pair<std::string, unsigned int> > TimeoutList;
/** Creator module
*/
@@ -75,7 +75,7 @@ class SpanningTreeUtilities : public classbase
/* Number of seconds that a server can go without ping
* before opers are warned of high latency.
*/
- int PingWarnTime;
+ unsigned int PingWarnTime;
/** This variable represents the root of the server tree
*/
TreeServer *TreeRoot;
@@ -100,7 +100,7 @@ class SpanningTreeUtilities : public classbase
/** Ping frequency of server to server links
*/
- int PingFreq;
+ unsigned int PingFreq;
/** Initialise utility class
*/
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index 8c1454d7e..1898ea88a 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -74,7 +74,7 @@ class CommandTban : public Command
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CMD_FAILURE;
}
- int cm = channel->GetPrefixValue(user);
+ unsigned int cm = channel->GetPrefixValue(user);
if (cm < HALFOP_VALUE)
{
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You do not have permission to set bans on this channel");
diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp
index 6fa367bff..7853c35af 100644
--- a/src/modules/m_userip.cpp
+++ b/src/modules/m_userip.cpp
@@ -38,7 +38,7 @@ class CommandUserip : public Command
bool checked_privs = false;
bool has_privs = false;
- for (int i = 0; i < (int)parameters.size(); i++)
+ for (size_t i = 0; i < parameters.size(); i++)
{
User *u = ServerInstance->FindNickOnly(parameters[i]);
if ((u) && (u->registered == REG_ALL))