From 02340285c564a7e82105137192d46d554a6fce3a Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Sun, 30 May 2021 20:37:54 +0100 Subject: Added -Wshorten-64-to-32 and fixed all warnings. --- src/modules/m_spanningtree/link.h | 2 +- src/modules/m_spanningtree/override_map.cpp | 14 +++++++------- src/modules/m_spanningtree/pingtimer.cpp | 2 +- src/modules/m_spanningtree/treeserver.cpp | 8 ++++---- src/modules/m_spanningtree/treeserver.h | 6 +++--- src/modules/m_spanningtree/utils.cpp | 2 +- src/modules/m_spanningtree/utils.h | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/modules/m_spanningtree') diff --git a/src/modules/m_spanningtree/link.h b/src/modules/m_spanningtree/link.h index 87fd2560f..7ca868fcf 100644 --- a/src/modules/m_spanningtree/link.h +++ b/src/modules/m_spanningtree/link.h @@ -39,7 +39,7 @@ class Link std::vector AllowMasks; bool HiddenFromStats; std::string Hook; - unsigned int Timeout; + unsigned long Timeout; std::string Bind; bool Hidden; Link(std::shared_ptr Tag) diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index 6801a47fe..55d9674bd 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -55,7 +55,7 @@ static inline bool IsHidden(User* user, TreeServer* server) } // Calculate the map depth the servers go, and the longest server name -static void GetDepthAndLen(TreeServer* current, unsigned int depth, unsigned int& max_depth, unsigned int& max_len, unsigned int& max_version) +static void GetDepthAndLen(TreeServer* current, unsigned int depth, unsigned int& max_depth, size_t& max_len, size_t& max_version) { if (depth > max_depth) max_depth = depth; @@ -70,7 +70,7 @@ static void GetDepthAndLen(TreeServer* current, unsigned int depth, unsigned int GetDepthAndLen(child, depth + 1, max_depth, max_len, max_version); } -static std::vector GetMap(User* user, TreeServer* current, unsigned int max_len, unsigned int max_version_len, unsigned int depth) +static std::vector GetMap(User* user, TreeServer* current, size_t max_len, size_t max_version_len, unsigned int depth) { float percent = 0; @@ -98,7 +98,7 @@ static std::vector GetMap(User* user, TreeServer* current, unsigned // Pad with spaces until its at max len, max_len must always be >= my names length buffer.append(max_len - current->GetName().length(), ' '); - buffer += InspIRCd::Format("%5d [%5.2f%%]", current->UserCount, percent); + buffer += InspIRCd::Format("%5zu [%5.2f%%]", current->UserCount, percent); if (user->IsOper()) { @@ -122,7 +122,7 @@ static std::vector GetMap(User* user, TreeServer* current, unsigned if (!IsHidden(user, *j)) last = false; - unsigned int next_len; + size_t next_len; if (user->IsOper() || !Utils->FlatLinks) { @@ -196,11 +196,11 @@ CmdResult CommandMap::Handle(User* user, const Params& parameters) // Max depth and max server name length unsigned int max_depth = 0; - unsigned int max_len = 0; - unsigned int max_version = 0; + size_t max_len = 0; + size_t max_version = 0; GetDepthAndLen(Utils->TreeRoot, 0, max_depth, max_len, max_version); - unsigned int max; + size_t max; if (user->IsOper() || !Utils->FlatLinks) { // Each level of the map is indented by 2 characters, making the max possible line (max_depth * 2) + max_len diff --git a/src/modules/m_spanningtree/pingtimer.cpp b/src/modules/m_spanningtree/pingtimer.cpp index fce90bfa4..0187532bd 100644 --- a/src/modules/m_spanningtree/pingtimer.cpp +++ b/src/modules/m_spanningtree/pingtimer.cpp @@ -48,7 +48,7 @@ PingTimer::State PingTimer::TickInternal() else if (state == PS_WARN) { // No pong arrived in PingWarnTime seconds, send a warning to opers - ServerInstance->SNO.WriteToSnoMask('l', "Server \002%s\002 has not responded to PING for %d seconds, high latency.", server->GetName().c_str(), GetInterval()); + ServerInstance->SNO.WriteToSnoMask('l', "Server \002%s\002 has not responded to PING for %lu seconds, high latency.", server->GetName().c_str(), GetInterval()); return PS_TIMEOUT; } else // PS_TIMEOUT diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index f0e85828c..dfe7edb3d 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -185,9 +185,9 @@ void TreeServer::SQuitChild(TreeServer* server, const std::string& reason, bool server->SQuitInternal(num_lost_servers, error); const std::string quitreason = GetName() + " " + server->GetName(); - unsigned int num_lost_users = QuitUsers(quitreason); + size_t num_lost_users = QuitUsers(quitreason); - ServerInstance->SNO.WriteToSnoMask(IsRoot() ? 'l' : 'L', "Netsplit complete, lost \002%u\002 user%s on \002%u\002 server%s.", + ServerInstance->SNO.WriteToSnoMask(IsRoot() ? 'l' : 'L', "Netsplit complete, lost \002%zu\002 user%s on \002%u\002 server%s.", num_lost_users, num_lost_users != 1 ? "s" : "", num_lost_servers, num_lost_servers != 1 ? "s" : ""); // No-op if the socket is already closed (i.e. it called us) @@ -214,12 +214,12 @@ void TreeServer::SQuitInternal(unsigned int& num_lost_servers, bool error) Utils->Creator->linkeventprov.Call(&ServerProtocol::LinkEventListener::OnServerSplit, this, error); } -unsigned int TreeServer::QuitUsers(const std::string& reason) +size_t TreeServer::QuitUsers(const std::string& reason) { std::string publicreason = Utils->HideSplits ? "*.net *.split" : reason; const user_hash& users = ServerInstance->Users.GetUsers(); - unsigned int original_size = users.size(); + size_t original_size = users.size(); for (user_hash::const_iterator i = users.begin(); i != users.end(); ) { User* user = i->second; diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 8b09f3817..2ea983555 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -90,8 +90,8 @@ class TreeServer : public Server FakeUser* const ServerUser; /* User representing this server */ const time_t age; - unsigned int UserCount; /* How many users are on this server? [note: doesn't care about +i] */ - unsigned int OperCount = 0; /* How many opers are on this server? */ + size_t UserCount; /* How many users are on this server? [note: doesn't care about +i] */ + size_t OperCount = 0; /* How many opers are on this server? */ /** We use this constructor only to create the 'root' item, Utils->TreeRoot, which * represents our own server. Therefore, it has no route, no parent, and @@ -121,7 +121,7 @@ class TreeServer : public Server GetParent()->SQuitChild(this, reason, error); } - static unsigned int QuitUsers(const std::string& reason); + static size_t QuitUsers(const std::string& reason); /** Get route. * The 'route' is defined as the locally- diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 80fd26ed4..50735dc1f 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -258,7 +258,7 @@ void SpanningTreeUtilities::ReadConfiguration() L->Name = tag->getString("name"); L->IPAddr = tag->getString("ipaddr"); - L->Port = tag->getUInt("port", 0); + L->Port = static_cast(tag->getUInt("port", 0, 0, UINT16_MAX)); L->SendPass = tag->getString("sendpass", tag->getString("password")); L->RecvPass = tag->getString("recvpass", tag->getString("password")); L->Fingerprint = tag->getString("fingerprint"); diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 8058a83c0..0181cade6 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -83,7 +83,7 @@ class SpanningTreeUtilities : public Cullable /* Number of seconds that a server can go without ping * before opers are warned of high latency. */ - unsigned int PingWarnTime; + unsigned long PingWarnTime; /** This variable represents the root of the server tree */ TreeServer *TreeRoot = nullptr; @@ -108,7 +108,7 @@ class SpanningTreeUtilities : public Cullable /** Ping frequency of server to server links */ - unsigned int PingFreq = 60; + unsigned long PingFreq = 60; /** Initialise utility class */ -- cgit v1.3.1-10-gc9f91