diff options
author | Peter Powell <petpow@saberuk.com> | 2018-12-12 20:34:46 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-12-12 21:43:24 +0000 |
commit | 0f7cfd46ef2d277f5f82e34a2852c75212d75261 (patch) | |
tree | 73445b54ad2ce50ae75999ec9f939ff1097b057a /src/modules/m_spanningtree | |
parent | 4e0cb28c1913c4ef76dd06b04fe321afe310f232 (diff) |
Fix conversion issues by replacing ConvToInt with ConvToNum<T>.
The former was a thin wrapper around atol and brought with it all
of the weird parsing logic of atol which is almost never what is
actually wanted. It also almost never returned the numeric type
which is actually wanted which can cause weird issues when casting.
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/addline.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/away.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/capab.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/compat.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/num.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/servercommand.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/svsnick.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket.h | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 2 |
10 files changed, 13 insertions, 13 deletions
diff --git a/src/modules/m_spanningtree/addline.cpp b/src/modules/m_spanningtree/addline.cpp index 00ef5b8d1..623942d95 100644 --- a/src/modules/m_spanningtree/addline.cpp +++ b/src/modules/m_spanningtree/addline.cpp @@ -38,14 +38,14 @@ CmdResult CommandAddLine::Handle(User* usr, Params& params) XLine* xl = NULL; try { - xl = xlf->Generate(ServerInstance->Time(), ConvToInt(params[4]), params[2], params[5], params[1]); + xl = xlf->Generate(ServerInstance->Time(), ConvToNum<long>(params[4]), params[2], params[5], params[1]); } catch (ModuleException &e) { ServerInstance->SNO->WriteToSnoMask('x',"Unable to ADDLINE type %s from %s: %s", params[0].c_str(), setter.c_str(), e.GetReason().c_str()); return CMD_FAILURE; } - xl->SetCreateTime(ConvToInt(params[3])); + xl->SetCreateTime(ConvToNum<time_t>(params[3])); if (ServerInstance->XLines->AddLine(xl, NULL)) { if (xl->duration) diff --git a/src/modules/m_spanningtree/away.cpp b/src/modules/m_spanningtree/away.cpp index 282f52a35..13972589b 100644 --- a/src/modules/m_spanningtree/away.cpp +++ b/src/modules/m_spanningtree/away.cpp @@ -28,7 +28,7 @@ CmdResult CommandAway::HandleRemote(::RemoteUser* u, Params& params) if (!params.empty()) { if (params.size() > 1) - u->awaytime = ConvToInt(params[0]); + u->awaytime = ConvToNum<time_t>(params[0]); else u->awaytime = ServerInstance->Time(); diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp index 5daea5202..c29330516 100644 --- a/src/modules/m_spanningtree/capab.cpp +++ b/src/modules/m_spanningtree/capab.cpp @@ -249,7 +249,7 @@ bool TreeSocket::Capab(const CommandBase::Params& params) capab->OptModuleList.clear(); capab->CapKeys.clear(); if (params.size() > 1) - proto_version = ConvToInt(params[1]); + proto_version = ConvToNum<unsigned int>(params[1]); if (proto_version < MinCompatProtocol) { diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp index b2967af3b..8e5361b16 100644 --- a/src/modules/m_spanningtree/compat.cpp +++ b/src/modules/m_spanningtree/compat.cpp @@ -521,7 +521,7 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, Comm // See if it's a numeric being sent to the target via PUSH unsigned int numeric_number = 0; if (token.length() == 3) - numeric_number = ConvToInt(token); + numeric_number = ConvToNum<unsigned int>(token); if ((numeric_number > 0) && (numeric_number < 1000)) { diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index d619c43bc..4f8875a02 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -40,8 +40,8 @@ * Failure to document your protocol changes will result in a painfully * painful death by pain. You have been warned. */ -const long ProtocolVersion = 1205; -const long MinCompatProtocol = 1202; +const unsigned int ProtocolVersion = 1205; +const unsigned int MinCompatProtocol = 1202; /** Forward declarations */ diff --git a/src/modules/m_spanningtree/num.cpp b/src/modules/m_spanningtree/num.cpp index f83f91286..564b808fd 100644 --- a/src/modules/m_spanningtree/num.cpp +++ b/src/modules/m_spanningtree/num.cpp @@ -33,7 +33,7 @@ CmdResult CommandNum::HandleServer(TreeServer* server, CommandBase::Params& para if (!localtarget) return CMD_SUCCESS; - Numeric::Numeric numeric(ConvToInt(params[2])); + Numeric::Numeric numeric(ConvToNum<unsigned int>(params[2])); // Passing NULL is ok, in that case the numeric source becomes this server numeric.SetServer(Utils->FindServerID(params[0])); numeric.GetParams().insert(numeric.GetParams().end(), params.begin()+3, params.end()); diff --git a/src/modules/m_spanningtree/servercommand.cpp b/src/modules/m_spanningtree/servercommand.cpp index 5b8152846..2f5c7ea3e 100644 --- a/src/modules/m_spanningtree/servercommand.cpp +++ b/src/modules/m_spanningtree/servercommand.cpp @@ -40,7 +40,7 @@ RouteDescriptor ServerCommand::GetRouting(User* user, const Params& parameters) time_t ServerCommand::ExtractTS(const std::string& tsstr) { - time_t TS = ConvToInt(tsstr); + time_t TS = ConvToNum<time_t>(tsstr); if (!TS) throw ProtocolException("Invalid TS"); return TS; diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp index 2514dfd6f..a734dc8ed 100644 --- a/src/modules/m_spanningtree/svsnick.cpp +++ b/src/modules/m_spanningtree/svsnick.cpp @@ -47,7 +47,7 @@ CmdResult CommandSVSNick::Handle(User* user, Params& parameters) // won't happen because the timestamps won't match. if (parameters.size() > 3) { - time_t ExpectedTS = ConvToInt(parameters[3]); + time_t ExpectedTS = ConvToNum<time_t>(parameters[3]); if (u->age != ExpectedTS) return CMD_FAILURE; // Ignore SVSNICK } @@ -56,7 +56,7 @@ CmdResult CommandSVSNick::Handle(User* user, Params& parameters) if (isdigit(nick[0])) nick = u->uuid; - time_t NickTS = ConvToInt(parameters[2]); + time_t NickTS = ConvToNum<time_t>(parameters[2]); if (NickTS <= 0) return CMD_FAILURE; diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index e8dbfd7cf..36dd8bb93 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -95,7 +95,7 @@ class TreeSocket : public BufferedSocket ServerState LinkState; /* Link state */ CapabData* capab; /* Link setup data (held until burst is sent) */ TreeServer* MyRoot; /* The server we are talking to */ - int proto_version; /* Remote protocol version */ + unsigned int proto_version; /* Remote protocol version */ /** True if we've sent our burst. * This only changes the behavior of message translation for 1202 protocol servers and it can be diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 513fa6dbf..293cdd695 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -148,7 +148,7 @@ void TreeSocket::ProcessLine(std::string &line) { if (params.size()) { - time_t them = ConvToInt(params[0]); + time_t them = ConvToNum<time_t>(params[0]); time_t delta = them - ServerInstance->Time(); if ((delta < -600) || (delta > 600)) { |