diff options
Diffstat (limited to 'src')
38 files changed, 90 insertions, 79 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 1edc57693..1151fe0a5 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -267,7 +267,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co if (!limit.empty()) { FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan)); - if (!MOD_RESULT.check((chan->GetUserCounter() < atol(limit.c_str())))) + if (!MOD_RESULT.check(chan->GetUserCounter() < ConvToNum<size_t>(limit))) { user->WriteNumeric(ERR_CHANNELISFULL, chan->name, "Cannot join channel (Channel is full)"); return NULL; diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 3b3329261..61f59ac0b 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -359,7 +359,7 @@ CommandBase::~CommandBase() { } -void CommandBase::EncodeParameter(std::string& parameter, int index) +void CommandBase::EncodeParameter(std::string& parameter, unsigned int index) { } diff --git a/src/configreader.cpp b/src/configreader.cpp index 168bdd09b..18b62fb09 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -219,7 +219,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) } } - int blk_count = config_data.count("connect"); + size_t blk_count = config_data.count("connect"); if (blk_count == 0) { // No connect blocks found; make a trivial default block @@ -231,14 +231,14 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) } Classes.resize(blk_count); - std::map<std::string, int> names; + std::map<std::string, size_t> names; bool try_again = true; - for(int tries=0; try_again; tries++) + for(size_t tries = 0; try_again; tries++) { try_again = false; ConfigTagList tags = ConfTags("connect"); - int i=0; + size_t i = 0; for(ConfigIter it = tags.first; it != tags.second; ++it, ++i) { ConfigTag* tag = it->second; @@ -249,7 +249,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) std::string parentName = tag->getString("parent"); if (!parentName.empty()) { - std::map<std::string,int>::iterator parentIter = names.find(parentName); + std::map<std::string, size_t>::const_iterator parentIter = names.find(parentName); if (parentIter == names.end()) { try_again = true; @@ -311,7 +311,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) if (tag->readString("sendq", sendq)) { // attempt to guess a good hard/soft sendq from a single value - long value = atol(sendq.c_str()); + unsigned long value = strtoul(sendq.c_str(), NULL, 10); if (value > 16384) me->softsendqmax = value / 16; else @@ -444,8 +444,8 @@ void ServerConfig::Fill() PID = ConfValue("pid")->getString("file"); MaxChans = ConfValue("channels")->getInt("users", 20); OperMaxChans = ConfValue("channels")->getInt("opers"); - c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32); - c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128); + c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32, 1, 32); + c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128, 1, 128); Limits = ServerLimits(ConfValue("limits")); Paths = ServerPaths(ConfValue("path")); NoSnoticeStack = options->getBool("nosnoticestack", false); @@ -548,7 +548,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) /* The stuff in here may throw CoreException, be sure we're in a position to catch it. */ try { - for (int index = 0; index * sizeof(DeprecatedConfig) < sizeof(ChangedConfig); index++) + for (unsigned long index = 0; index * sizeof(DeprecatedConfig) < sizeof(ChangedConfig); index++) { std::string value; ConfigTagList tags = ConfTags(ChangedConfig[index].tag); diff --git a/src/coremods/core_info/cmd_modules.cpp b/src/coremods/core_info/cmd_modules.cpp index 47dd2dc92..fa8c2aebb 100644 --- a/src/coremods/core_info/cmd_modules.cpp +++ b/src/coremods/core_info/cmd_modules.cpp @@ -66,7 +66,7 @@ CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, Us if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex")) { std::string flags("VCO"); - int pos = 0; + size_t pos = 0; for (int mult = 2; mult <= VF_OPTCOMMON; mult *= 2, ++pos) if (!(V.Flags & mult)) flags[pos] = '-'; diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index 6a62d122f..3c29f7883 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -51,7 +51,7 @@ class CommandList : public Command */ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User *user) { - int minusers = 0, maxusers = 0; + size_t minusers = 0, maxusers = 0; user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name"); @@ -59,11 +59,11 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User { if (parameters[0][0] == '<') { - maxusers = atoi((parameters[0].c_str())+1); + maxusers = strtoul((parameters[0].c_str() + 1), NULL, 10); } else if (parameters[0][0] == '>') { - minusers = atoi((parameters[0].c_str())+1); + minusers = strtoul((parameters[0].c_str() + 1), NULL, 10); } } @@ -76,7 +76,7 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User Channel* const chan = i->second; // attempt to match a glob pattern - long users = chan->GetUserCounter(); + size_t users = chan->GetUserCounter(); bool too_few = (minusers && (users <= minusers)); bool too_many = (maxusers && (users >= maxusers)); diff --git a/src/coremods/core_oper/cmd_kill.cpp b/src/coremods/core_oper/cmd_kill.cpp index 8a453f7f1..20bbe5a26 100644 --- a/src/coremods/core_oper/cmd_kill.cpp +++ b/src/coremods/core_oper/cmd_kill.cpp @@ -136,7 +136,7 @@ RouteDescriptor CommandKill::GetRouting(User* user, const std::vector<std::strin } -void CommandKill::EncodeParameter(std::string& param, int index) +void CommandKill::EncodeParameter(std::string& param, unsigned int index) { // Manually translate the nick -> uuid (see above), and also the reason (params[1]) // because we decorate it if the oper is local and want remote servers to see the diff --git a/src/coremods/core_oper/core_oper.h b/src/coremods/core_oper/core_oper.h index 338a369f5..619fdf1fa 100644 --- a/src/coremods/core_oper/core_oper.h +++ b/src/coremods/core_oper/core_oper.h @@ -74,7 +74,7 @@ class CommandKill : public Command CmdResult Handle(const std::vector<std::string>& parameters, User* user); RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters); - void EncodeParameter(std::string& param, int index); + void EncodeParameter(std::string& param, unsigned int index); }; /** Handle /OPER. diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index 196bf0479..ba1883e77 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -146,10 +146,10 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext) match = InspIRCd::Match(user->awaymsg, matchtext); else if (opt_time) { - long seconds = InspIRCd::Duration(matchtext); + time_t seconds = ServerInstance->Time() - InspIRCd::Duration(matchtext); // Okay, so time matching, we want all users connected `seconds' ago - if (user->signon >= ServerInstance->Time() - seconds) + if (user->signon >= seconds) match = true; } diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index c2fac7577..d726b6b6c 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -55,7 +55,7 @@ class CommandWhois : public SplitCommand Events::ModuleEventProvider evprov; Events::ModuleEventProvider lineevprov; - void DoWhois(LocalUser* user, User* dest, unsigned long signon, unsigned long idle); + void DoWhois(LocalUser* user, User* dest, time_t signon, unsigned long idle); void SendChanList(WhoisContextImpl& whois); public: @@ -173,7 +173,7 @@ void CommandWhois::SendChanList(WhoisContextImpl& whois) chanlist.Flush(whois); } -void CommandWhois::DoWhois(LocalUser* user, User* dest, unsigned long signon, unsigned long idle) +void CommandWhois::DoWhois(LocalUser* user, User* dest, time_t signon, unsigned long idle) { WhoisContextImpl whois(user, dest, lineevprov); @@ -247,7 +247,7 @@ CmdResult CommandWhois::HandleRemote(const std::vector<std::string>& parameters, if (!localuser) return CMD_FAILURE; - unsigned long idle = ConvToInt(parameters.back()); + unsigned long idle = ConvToNum<unsigned long>(parameters.back()); DoWhois(localuser, target, target->signon, idle); return CMD_SUCCESS; @@ -256,8 +256,9 @@ CmdResult CommandWhois::HandleRemote(const std::vector<std::string>& parameters, CmdResult CommandWhois::HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) { User *dest; - int userindex = 0; - unsigned long idle = 0, signon = 0; + unsigned int userindex = 0; + unsigned long idle = 0; + time_t signon = 0; if (CommandParser::LoopCall(user, this, parameters, 0)) return CMD_SUCCESS; diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 7e992c4a6..ddcff5e55 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -393,13 +393,13 @@ std::string InspIRCd::TimeString(time_t curtime, const char* format, bool utc) return buffer; } -std::string InspIRCd::GenRandomStr(int length, bool printable) +std::string InspIRCd::GenRandomStr(unsigned int length, bool printable) { char* buf = new char[length]; GenRandom(buf, length); std::string rv; rv.resize(length); - for(int i=0; i < length; i++) + for(size_t i = 0; i < length; i++) rv[i] = printable ? 0x3F + (buf[i] & 0x3F) : buf[i]; delete[] buf; return rv; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 80d1df75d..6c45a1a0d 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -309,7 +309,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : /* Fall through to handle other weird values too */ std::cout << "Unknown parameter '" << argv[optind-1] << "'" << std::endl; std::cout << "Usage: " << argv[0] << " [--nofork] [--nolog] [--debug] [--config <config>]" << std::endl << - std::string(static_cast<int>(8+strlen(argv[0])), ' ') << "[--runasroot] [--version]" << std::endl; + std::string(static_cast<size_t>(8+strlen(argv[0])), ' ') << "[--runasroot] [--version]" << std::endl; Exit(EXIT_STATUS_ARGV); break; } diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 9bfc6a73e..a564d3eec 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -48,7 +48,7 @@ BufferedSocket::BufferedSocket(int newfd) SocketEngine::AddFd(this, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE); } -void BufferedSocket::DoConnect(const std::string &ipaddr, int aport, unsigned long maxtime, const std::string &connectbindip) +void BufferedSocket::DoConnect(const std::string& ipaddr, int aport, unsigned int maxtime, const std::string& connectbindip) { BufferedSocketError err = BeginConnect(ipaddr, aport, maxtime, connectbindip); if (err != I_ERR_NONE) @@ -59,7 +59,7 @@ void BufferedSocket::DoConnect(const std::string &ipaddr, int aport, unsigned lo } } -BufferedSocketError BufferedSocket::BeginConnect(const std::string &ipaddr, int aport, unsigned long maxtime, const std::string &connectbindip) +BufferedSocketError BufferedSocket::BeginConnect(const std::string& ipaddr, int aport, unsigned int maxtime, const std::string& connectbindip) { irc::sockets::sockaddrs addr, bind; if (!irc::sockets::aptosa(ipaddr, aport, addr)) @@ -80,7 +80,7 @@ BufferedSocketError BufferedSocket::BeginConnect(const std::string &ipaddr, int return BeginConnect(addr, bind, maxtime); } -BufferedSocketError BufferedSocket::BeginConnect(const irc::sockets::sockaddrs& dest, const irc::sockets::sockaddrs& bind, unsigned long timeout) +BufferedSocketError BufferedSocket::BeginConnect(const irc::sockets::sockaddrs& dest, const irc::sockets::sockaddrs& bind, unsigned int timeout) { if (fd < 0) fd = socket(dest.sa.sa_family, SOCK_STREAM, 0); 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)) diff --git a/src/socket.cpp b/src/socket.cpp index 91c7cdeca..6133d9ee4 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -178,7 +178,7 @@ std::string irc::sockets::sockaddrs::str() const return "<unknown>"; } -int irc::sockets::sockaddrs::sa_size() const +socklen_t irc::sockets::sockaddrs::sa_size() const { if (sa.sa_family == AF_INET) return sizeof(in4); @@ -198,7 +198,7 @@ bool irc::sockets::sockaddrs::operator==(const irc::sockets::sockaddrs& other) c return !memcmp(this, &other, sizeof(*this)); } -static void sa2cidr(irc::sockets::cidr_mask& cidr, const irc::sockets::sockaddrs& sa, int range) +static void sa2cidr(irc::sockets::cidr_mask& cidr, const irc::sockets::sockaddrs& sa, unsigned char range) { const unsigned char* base; unsigned char target_byte; @@ -239,7 +239,7 @@ static void sa2cidr(irc::sockets::cidr_mask& cidr, const irc::sockets::sockaddrs } } -irc::sockets::cidr_mask::cidr_mask(const irc::sockets::sockaddrs& sa, int range) +irc::sockets::cidr_mask::cidr_mask(const irc::sockets::sockaddrs& sa, unsigned char range) { sa2cidr(*this, sa, range); } @@ -267,7 +267,7 @@ std::string irc::sockets::cidr_mask::str() const irc::sockets::sockaddrs sa; sa.sa.sa_family = type; unsigned char* base; - int len; + size_t len; if (type == AF_INET) { base = (unsigned char*)&sa.in4.sin_addr; diff --git a/src/timer.cpp b/src/timer.cpp index 0b0d8bac3..48ad79df7 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -22,7 +22,7 @@ #include "inspircd.h" -void Timer::SetInterval(time_t newinterval) +void Timer::SetInterval(unsigned int newinterval) { ServerInstance->Timers.DelTimer(this); secs = newinterval; diff --git a/src/users.cpp b/src/users.cpp index f7cd00a07..c2ff9c5be 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -63,7 +63,7 @@ std::string User::GetModeLetters(bool includeparams) const return ret; } -User::User(const std::string& uid, Server* srv, int type) +User::User(const std::string& uid, Server* srv, UserType type) : age(ServerInstance->Time()) , signon(0) , uuid(uid) @@ -688,7 +688,7 @@ const std::string& User::GetRealHost() const irc::sockets::cidr_mask User::GetCIDRMask() { - int range = 0; + unsigned char range = 0; switch (client_sa.sa.sa_family) { case AF_INET6: |