aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-09-03 22:52:53 +0100
committerGravatar Sadie Powell2022-09-03 23:17:05 +0100
commit9203f40f41e4a735d379d13867d277c696fb28c5 (patch)
tree93a171344e801b44918229fdd6b8778293ab88aa
parentFix some warnings noticed by the bugprone-* clang-tidy checkers. (diff)
Fix some warnings noticed by the readability-* clang-tidy checkers.
-rw-r--r--include/clientprotocol.h2
-rw-r--r--include/configparser.h2
-rw-r--r--include/configreader.h4
-rw-r--r--include/hashcomp.h2
-rw-r--r--include/inspircd.h6
-rw-r--r--include/mode.h4
-rw-r--r--include/usermanager.h2
-rw-r--r--include/users.h2
-rw-r--r--include/xline.h2
-rw-r--r--src/clientprotocol.cpp2
-rw-r--r--src/configparser.cpp2
-rw-r--r--src/configreader.cpp4
-rw-r--r--src/coremods/core_channel/core_channel.cpp3
-rw-r--r--src/coremods/core_channel/extban.cpp6
-rw-r--r--src/coremods/core_dns.cpp7
-rw-r--r--src/coremods/core_info/cmd_admin.cpp2
-rw-r--r--src/coremods/core_info/cmd_motd.cpp2
-rw-r--r--src/coremods/core_info/cmd_time.cpp2
-rw-r--r--src/coremods/core_info/core_info.h2
-rw-r--r--src/coremods/core_list.cpp2
-rw-r--r--src/coremods/core_message.cpp4
-rw-r--r--src/coremods/core_mode.cpp4
-rw-r--r--src/coremods/core_oper/cmd_rehash.cpp3
-rw-r--r--src/coremods/core_stats.cpp5
-rw-r--r--src/coremods/core_who.cpp2
-rw-r--r--src/coremods/core_xline/cmd_eline.cpp2
-rw-r--r--src/coremods/core_xline/cmd_gline.cpp2
-rw-r--r--src/coremods/core_xline/cmd_kline.cpp2
-rw-r--r--src/coremods/core_xline/cmd_qline.cpp2
-rw-r--r--src/coremods/core_xline/cmd_zline.cpp2
-rw-r--r--src/hashcomp.cpp2
-rw-r--r--src/helperfuncs.cpp14
-rw-r--r--src/inspsocket.cpp2
-rw-r--r--src/mode.cpp4
-rw-r--r--src/modulemanager.cpp2
-rw-r--r--src/modules/extra/m_argon2.cpp6
-rw-r--r--src/modules/extra/m_log_syslog.cpp2
-rw-r--r--src/modules/extra/m_mysql.cpp6
-rw-r--r--src/modules/extra/m_pgsql.cpp8
-rw-r--r--src/modules/extra/m_regex_posix.cpp6
-rw-r--r--src/modules/extra/m_regex_re2.cpp4
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp8
-rw-r--r--src/modules/m_abbreviation.cpp3
-rw-r--r--src/modules/m_alias.cpp7
-rw-r--r--src/modules/m_anticaps.cpp8
-rw-r--r--src/modules/m_auditorium.cpp5
-rw-r--r--src/modules/m_autoop.cpp2
-rw-r--r--src/modules/m_banexception.cpp3
-rw-r--r--src/modules/m_bcrypt.cpp2
-rw-r--r--src/modules/m_cban.cpp2
-rw-r--r--src/modules/m_check.cpp2
-rw-r--r--src/modules/m_cloaking.cpp9
-rw-r--r--src/modules/m_codepage.cpp4
-rw-r--r--src/modules/m_connectban.cpp2
-rw-r--r--src/modules/m_dccallow.cpp17
-rw-r--r--src/modules/m_disable.cpp4
-rw-r--r--src/modules/m_dnsbl.cpp9
-rw-r--r--src/modules/m_filter.cpp16
-rw-r--r--src/modules/m_globalload.cpp8
-rw-r--r--src/modules/m_ident.cpp2
-rw-r--r--src/modules/m_ircv3_capnotify.cpp4
-rw-r--r--src/modules/m_ircv3_sts.cpp2
-rw-r--r--src/modules/m_joinflood.cpp2
-rw-r--r--src/modules/m_log_sql.cpp1
-rw-r--r--src/modules/m_md5.cpp4
-rw-r--r--src/modules/m_nickflood.cpp2
-rw-r--r--src/modules/m_override.cpp2
-rw-r--r--src/modules/m_pbkdf2.cpp8
-rw-r--r--src/modules/m_repeat.cpp2
-rw-r--r--src/modules/m_restrictmsg.cpp2
-rw-r--r--src/modules/m_rline.cpp4
-rw-r--r--src/modules/m_sasl.cpp4
-rw-r--r--src/modules/m_sha2.cpp4
-rw-r--r--src/modules/m_showwhois.cpp2
-rw-r--r--src/modules/m_shun.cpp4
-rw-r--r--src/modules/m_spanningtree/capab.cpp12
-rw-r--r--src/modules/m_spanningtree/commands.h2
-rw-r--r--src/modules/m_spanningtree/compat.cpp1
-rw-r--r--src/modules/m_spanningtree/main.h8
-rw-r--r--src/modules/m_spanningtree/override_map.cpp2
-rw-r--r--src/modules/m_spanningtree/ping.cpp1
-rw-r--r--src/modules/m_spanningtree/pong.cpp1
-rw-r--r--src/modules/m_spanningtree/precommand.cpp2
-rw-r--r--src/modules/m_spanningtree/server.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket.h10
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp2
-rw-r--r--src/modules/m_spanningtree/utils.cpp4
-rw-r--r--src/modules/m_spanningtree/utils.h12
-rw-r--r--src/modules/m_sslinfo.cpp2
-rw-r--r--src/modules/m_svshold.cpp6
-rw-r--r--src/server.cpp6
-rw-r--r--src/socketengines/epoll.cpp2
-rw-r--r--src/usermanager.cpp2
-rw-r--r--src/users.cpp2
-rw-r--r--src/xline.cpp30
95 files changed, 201 insertions, 212 deletions
diff --git a/include/clientprotocol.h b/include/clientprotocol.h
index 83b1aa907..b3e85fd8f 100644
--- a/include/clientprotocol.h
+++ b/include/clientprotocol.h
@@ -693,7 +693,7 @@ private:
* @param tagmap Tag map that contains all possible tags.
* @return Whitelist of tags to send to the user.
*/
- TagSelection MakeTagWhitelist(LocalUser* user, const TagMap& tagmap) const;
+ static TagSelection MakeTagWhitelist(LocalUser* user, const TagMap& tagmap);
public:
/** Constructor.
diff --git a/include/configparser.h b/include/configparser.h
index ca87ef0f7..a80dd1fb5 100644
--- a/include/configparser.h
+++ b/include/configparser.h
@@ -36,5 +36,5 @@ struct ParseStack final
bool ParseFile(const std::string& name, int flags, const std::string& mandatory_tag = std::string(), bool isexec = false);
void DoInclude(std::shared_ptr<ConfigTag> includeTag, int flags);
void DoReadFile(const std::string& key, const std::string& file, int flags, bool exec);
- FilePtr DoOpenFile(const std::string& name, bool isexec);
+ static FilePtr DoOpenFile(const std::string& name, bool isexec);
};
diff --git a/include/configreader.h b/include/configreader.h
index 998249292..ca1bba5d7 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -349,14 +349,14 @@ public:
* @param def The value to return if the tag doesn't exist.
* @returns Either a tag from the config or EmptyTag.
*/
- std::shared_ptr<ConfigTag> ConfValue(const std::string& tag, std::shared_ptr<ConfigTag> def = nullptr);
+ std::shared_ptr<ConfigTag> ConfValue(const std::string& tag, std::shared_ptr<ConfigTag> def = nullptr) const;
/** Get a list of configuration tags by name.
* @param tag The name of the tags to get.
* @param def The value to return if the tag doesn't exist.
* @returns Either a list of tags from the config or an empty TagList.
*/
- TagList ConfTags(const std::string& tag, std::optional<TagList> def = std::nullopt);
+ TagList ConfTags(const std::string& tag, std::optional<TagList> def = std::nullopt) const;
/** An empty configuration tag. */
std::shared_ptr<ConfigTag> EmptyTag;
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 217fb2697..8b8c8f482 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -150,7 +150,7 @@ namespace irc
/** Fetch the entire remaining stream, without tokenizing
* @return The remaining part of the stream
*/
- const std::string GetRemaining();
+ std::string GetRemaining();
/** Returns true if the end of the stream has been reached
* @return True if the end of the stream has been reached, otherwise false
diff --git a/include/inspircd.h b/include/inspircd.h
index 461a20678..8fc89e528 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -298,11 +298,11 @@ public:
* @param printable if false, the string will use characters 0-255; otherwise,
* it will be limited to 0x30-0x7E ('0'-'~', nonspace printable characters)
*/
- std::string GenRandomStr(size_t length, bool printable = true);
+ std::string GenRandomStr(size_t length, bool printable = true) const;
/** Generate a random integer.
* This is generally more secure than rand()
*/
- unsigned long GenRandomInt(unsigned long max);
+ unsigned long GenRandomInt(unsigned long max) const;
/** Fill a buffer with random bits */
std::function<void(char*, size_t)> GenRandom;
@@ -475,7 +475,7 @@ public:
* @param hashtype The hash from the config file
* @return True if the strings match, false if they do not
*/
- bool PassCompare(Extensible* ex, const std::string& data, const std::string& input, const std::string& hashtype);
+ static bool PassCompare(Extensible* ex, const std::string& data, const std::string& input, const std::string& hashtype);
/** Attempt to write the process id to a given file
*/
diff --git a/include/mode.h b/include/mode.h
index d7d4dd2e9..55ee5072d 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -785,14 +785,14 @@ public:
* @param rank The rank to search for prefix modes near.
* @return A pointer to the PrefixMode or NULL if a prefix mode wasn't found.
*/
- PrefixMode* FindNearestPrefixMode(ModeHandler::Rank rank);
+ PrefixMode* FindNearestPrefixMode(ModeHandler::Rank rank) const;
/** Find a mode handler by its prefix.
* If there is no mode handler with the given prefix, NULL will be returned.
* @param pfxletter The prefix to find, e.g. '@'
* @return The mode handler which handles this prefix, or NULL if there is none.
*/
- PrefixMode* FindPrefix(unsigned char pfxletter);
+ PrefixMode* FindPrefix(unsigned char pfxletter) const;
/** Get a list of all mode handlers that inherit from ListModeBase
* @return A list containing ListModeBase modes
diff --git a/include/usermanager.h b/include/usermanager.h
index be3dca18e..cec2b0e76 100644
--- a/include/usermanager.h
+++ b/include/usermanager.h
@@ -188,7 +188,7 @@ public:
* @param text The text format string to send
* @param ... The format arguments
*/
- void ServerNoticeAll(const char* text, ...) ATTR_PRINTF(2, 3);
+ void ServerNoticeAll(const char* text, ...) const ATTR_PRINTF(2, 3);
/** Retrieves the next already sent id, guaranteed to be not equal to any user's already_sent field
* @return Next already_sent id
diff --git a/include/users.h b/include/users.h
index ce8ffd662..c94317937 100644
--- a/include/users.h
+++ b/include/users.h
@@ -340,7 +340,7 @@ public:
/** Get CIDR mask, using default range, for this user
*/
- irc::sockets::cidr_mask GetCIDRMask();
+ irc::sockets::cidr_mask GetCIDRMask() const;
/** Changes the remote socket address for this user.
* @param sa The new socket address.
diff --git a/include/xline.h b/include/xline.h
index 0827adbd3..9e4864071 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -413,7 +413,7 @@ public:
/** Split an ident and host into two separate strings.
* This allows for faster matching.
*/
- IdentHostPair IdentSplit(const std::string &ident_and_host);
+ static IdentHostPair IdentSplit(const std::string &ident_and_host);
/** Checks what users match E-lines and sets their ban exempt flag accordingly.
*/
diff --git a/src/clientprotocol.cpp b/src/clientprotocol.cpp
index 91317640c..f3838e468 100644
--- a/src/clientprotocol.cpp
+++ b/src/clientprotocol.cpp
@@ -46,7 +46,7 @@ bool ClientProtocol::Serializer::HandleTag(LocalUser* user, const std::string& t
return true;
}
-ClientProtocol::TagSelection ClientProtocol::Serializer::MakeTagWhitelist(LocalUser* user, const TagMap& tagmap) const
+ClientProtocol::TagSelection ClientProtocol::Serializer::MakeTagWhitelist(LocalUser* user, const TagMap& tagmap)
{
TagSelection tagwl;
for (TagMap::const_iterator i = tagmap.begin(); i != tagmap.end(); ++i)
diff --git a/src/configparser.cpp b/src/configparser.cpp
index 7dc603569..08cd88c7d 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -112,7 +112,7 @@ struct Parser final
}
}
- bool wordchar(char ch)
+ static bool wordchar(char ch)
{
return isalnum(ch)
|| ch == '-'
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 176a1d6c6..efe3af94d 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -554,7 +554,7 @@ void ServerConfig::ApplyModules(User* user)
}
}
-std::shared_ptr<ConfigTag> ServerConfig::ConfValue(const std::string& tag, std::shared_ptr<ConfigTag> def)
+std::shared_ptr<ConfigTag> ServerConfig::ConfValue(const std::string& tag, std::shared_ptr<ConfigTag> def) const
{
auto tags = insp::equal_range(config_data, tag);
if (tags.empty())
@@ -568,7 +568,7 @@ std::shared_ptr<ConfigTag> ServerConfig::ConfValue(const std::string& tag, std::
return tags.begin()->second;
}
-ServerConfig::TagList ServerConfig::ConfTags(const std::string& tag, std::optional<TagList> def)
+ServerConfig::TagList ServerConfig::ConfTags(const std::string& tag, std::optional<TagList> def) const
{
auto range = insp::equal_range(config_data, tag);
return range.empty() && def ? *def : range;
diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp
index f9e156d80..631b8d9d4 100644
--- a/src/coremods/core_channel/core_channel.cpp
+++ b/src/coremods/core_channel/core_channel.cpp
@@ -351,7 +351,8 @@ public:
ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask) override
{
bool inverted;
- std::string name, value;
+ std::string name;
+ std::string value;
if (!ExtBan::Parse(mask, name, value, inverted))
return MOD_RES_PASSTHRU;
diff --git a/src/coremods/core_channel/extban.cpp b/src/coremods/core_channel/extban.cpp
index f42e49b68..2e36cf6d9 100644
--- a/src/coremods/core_channel/extban.cpp
+++ b/src/coremods/core_channel/extban.cpp
@@ -29,7 +29,8 @@ void ExtBanManager::AddExtBan(ExtBan::Base* extban)
bool ExtBanManager::Canonicalize(std::string& text) const
{
bool inverted; // Intentionally unused
- std::string xbname, xbvalue;
+ std::string xbname;
+ std::string xbvalue;
if (!ExtBan::Parse(text, xbname, xbvalue, inverted))
return false; // Not an extban.
@@ -88,7 +89,8 @@ ModResult ExtBanManager::GetStatus(ExtBan::Acting* extban, User* user, Channel*
for (const ListModeBase::ListItem& ban : *list)
{
bool inverted;
- std::string xbname, xbvalue;
+ std::string xbname;
+ std::string xbvalue;
if (!ExtBan::Parse(ban.mask, xbname, xbvalue, inverted))
continue;
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index d94199a8d..a3018ac75 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -71,7 +71,8 @@ private:
std::string UnpackName(const unsigned char* input, unsigned short input_size, unsigned short& pos)
{
std::string name;
- unsigned short pos_ptr = pos, lowest_ptr = input_size;
+ unsigned short pos_ptr = pos;
+ unsigned short lowest_ptr = input_size;
bool compressed = false;
if (pos_ptr >= input_size)
@@ -89,7 +90,7 @@ private:
throw Exception(creator, "Unable to unpack name - bogus compression header");
/* Place pos at the second byte of the first (farthest) compression pointer */
- if (compressed == false)
+ if (!compressed)
{
++pos;
compressed = true;
@@ -112,7 +113,7 @@ private:
name += input[pos_ptr + i];
pos_ptr += offset + 1;
- if (compressed == false)
+ if (!compressed)
/* Move up pos */
pos = pos_ptr;
}
diff --git a/src/coremods/core_info/cmd_admin.cpp b/src/coremods/core_info/cmd_admin.cpp
index 955f83075..823384519 100644
--- a/src/coremods/core_info/cmd_admin.cpp
+++ b/src/coremods/core_info/cmd_admin.cpp
@@ -44,7 +44,7 @@ CommandAdmin::CommandAdmin(Module* parent)
CmdResult CommandAdmin::Handle(User* user, const Params& parameters)
{
- if (parameters.size() > 0 && !irc::equals(parameters[0], ServerInstance->Config->ServerName))
+ if (!parameters.empty() && !irc::equals(parameters[0], ServerInstance->Config->ServerName))
return CmdResult::SUCCESS;
user->WriteRemoteNumeric(RPL_ADMINME, ServerInstance->Config->GetServerName(), "Administrative info");
diff --git a/src/coremods/core_info/cmd_motd.cpp b/src/coremods/core_info/cmd_motd.cpp
index 7ce5419f1..25cf7bac7 100644
--- a/src/coremods/core_info/cmd_motd.cpp
+++ b/src/coremods/core_info/cmd_motd.cpp
@@ -42,7 +42,7 @@ CommandMotd::CommandMotd(Module* parent)
CmdResult CommandMotd::Handle(User* user, const Params& parameters)
{
- if (parameters.size() > 0 && !irc::equals(parameters[0], ServerInstance->Config->ServerName))
+ if (!parameters.empty() && !irc::equals(parameters[0], ServerInstance->Config->ServerName))
{
// Give extra penalty if a non-oper queries the /MOTD of a remote server
LocalUser* localuser = IS_LOCAL(user);
diff --git a/src/coremods/core_info/cmd_time.cpp b/src/coremods/core_info/cmd_time.cpp
index 9713d4ef9..e8fa6ec3d 100644
--- a/src/coremods/core_info/cmd_time.cpp
+++ b/src/coremods/core_info/cmd_time.cpp
@@ -40,7 +40,7 @@ CommandTime::CommandTime(Module* parent)
CmdResult CommandTime::Handle(User* user, const Params& parameters)
{
- if (parameters.size() > 0 && !irc::equals(parameters[0], ServerInstance->Config->ServerName))
+ if (!parameters.empty() && !irc::equals(parameters[0], ServerInstance->Config->ServerName))
return CmdResult::SUCCESS;
user->WriteRemoteNumeric(RPL_TIME, ServerInstance->Config->GetServerName(), InspIRCd::TimeString(ServerInstance->Time()));
diff --git a/src/coremods/core_info/core_info.h b/src/coremods/core_info/core_info.h
index 64c8df426..29cf7c8f5 100644
--- a/src/coremods/core_info/core_info.h
+++ b/src/coremods/core_info/core_info.h
@@ -42,7 +42,7 @@ private:
* @param buffer The buffer to append to.
* @param value An ISUPPORT token value.
*/
- void AppendValue(std::string& buffer, const std::string& value);
+ static void AppendValue(std::string& buffer, const std::string& value);
/** Builds the ISUPPORT numerics from a list of tokens.
* @param tokens The tokens to build from.
diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp
index dd45d4343..6b30957f8 100644
--- a/src/coremods/core_list.cpp
+++ b/src/coremods/core_list.cpp
@@ -38,7 +38,7 @@ private:
* @param value The parameter containing a minute count.
* @return The UNIX time at \p value minutes ago.
*/
- time_t ParseMinutes(const std::string& value)
+ static time_t ParseMinutes(const std::string& value)
{
time_t minutes = ConvToNum<time_t>(value.c_str() + 2);
if (!minutes)
diff --git a/src/coremods/core_message.cpp b/src/coremods/core_message.cpp
index 89cb4bdd3..481f4e325 100644
--- a/src/coremods/core_message.cpp
+++ b/src/coremods/core_message.cpp
@@ -102,7 +102,7 @@ class CommandMessage final
private:
const MessageType msgtype;
- bool FirePreEvents(User* source, MessageTarget& msgtarget, MessageDetails& msgdetails)
+ static bool FirePreEvents(User* source, MessageTarget& msgtarget, MessageDetails& msgdetails)
{
// Inform modules that a message wants to be sent.
ModResult modres;
@@ -126,7 +126,7 @@ private:
return true;
}
- CmdResult FirePostEvent(User* source, const MessageTarget& msgtarget, const MessageDetails& msgdetails)
+ static CmdResult FirePostEvent(User* source, const MessageTarget& msgtarget, const MessageDetails& msgdetails)
{
// If the source is local and was not sending a CTCP reply then update their idle time.
LocalUser* lsource = IS_LOCAL(source);
diff --git a/src/coremods/core_mode.cpp b/src/coremods/core_mode.cpp
index 6fc377707..e6fba59bd 100644
--- a/src/coremods/core_mode.cpp
+++ b/src/coremods/core_mode.cpp
@@ -294,7 +294,7 @@ class CoreModMode final
private:
CommandMode cmdmode;
- std::string GenerateModeList(ModeType mt)
+ static std::string GenerateModeList(ModeType mt)
{
// Type A: Modes that add or remove an address to or from a list. These
// modes MUST always have a parameter when sent from the server to a
@@ -351,7 +351,7 @@ private:
return InspIRCd::Format("%s,%s,%s,%s", type1.c_str(), type2.c_str(), type3.c_str(), type4.c_str());
}
- std::string GeneratePrefixList(bool includemodechars)
+ static std::string GeneratePrefixList(bool includemodechars)
{
std::vector<PrefixMode*> prefixes;
for (const auto& pm : ServerInstance->Modes.GetPrefixModes())
diff --git a/src/coremods/core_oper/cmd_rehash.cpp b/src/coremods/core_oper/cmd_rehash.cpp
index 7242d4b85..b3684f0c7 100644
--- a/src/coremods/core_oper/cmd_rehash.cpp
+++ b/src/coremods/core_oper/cmd_rehash.cpp
@@ -46,8 +46,7 @@ CommandRehash::CommandRehash(Module* parent)
CmdResult CommandRehash::Handle(User* user, const Params& parameters)
{
- std::string param = parameters.size() ? parameters[0] : "";
-
+ std::string param = parameters.empty() ? "" : parameters[0];
FOREACH_MOD(OnPreRehash, (user, param));
if (param.empty())
diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp
index c43ccbd69..727fc1569 100644
--- a/src/coremods/core_stats.cpp
+++ b/src/coremods/core_stats.cpp
@@ -232,7 +232,9 @@ void CommandStats::DoStats(Stats::Context& stats)
stats.AddRow(249, "Channels: "+ConvToStr(ServerInstance->Channels.GetChans().size()));
stats.AddRow(249, "Commands: "+ConvToStr(ServerInstance->Parser.GetCommands().size()));
- float kbitpersec_in, kbitpersec_out, kbitpersec_total;
+ float kbitpersec_in;
+ float kbitpersec_out;
+ float kbitpersec_total;
SocketEngine::GetStats().GetBandwidth(kbitpersec_in, kbitpersec_out, kbitpersec_total);
stats.AddRow(249, InspIRCd::Format("Bandwidth total: %03.5f kilobits/sec", kbitpersec_total));
@@ -372,7 +374,6 @@ void CommandStats::DoStats(Stats::Context& stats)
stats.AddRow(219, statschar, "End of /STATS report");
ServerInstance->SNO.WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)",
(IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->GetRealHost().c_str());
- return;
}
CmdResult CommandStats::Handle(User* user, const Params& parameters)
diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp
index 0386abca8..f211b522d 100644
--- a/src/coremods/core_who.cpp
+++ b/src/coremods/core_who.cpp
@@ -176,7 +176,7 @@ private:
}
/** Determines whether WHO flags match a specific channel user. */
- bool MatchChannel(LocalUser* source, Membership* memb, WhoData& data);
+ static bool MatchChannel(LocalUser* source, Membership* memb, WhoData& data);
/** Determines whether WHO flags match a specific user. */
bool MatchUser(LocalUser* source, User* target, WhoData& data);
diff --git a/src/coremods/core_xline/cmd_eline.cpp b/src/coremods/core_xline/cmd_eline.cpp
index b285d687a..41a5031e8 100644
--- a/src/coremods/core_xline/cmd_eline.cpp
+++ b/src/coremods/core_xline/cmd_eline.cpp
@@ -69,7 +69,7 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters)
user->WriteNotice("*** Invalid duration for E-line.");
return CmdResult::FAILURE;
}
- ELine* el = new ELine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
+ ELine* el = new ELine(ServerInstance->Time(), duration, user->nick, parameters[2], ih.first, ih.second);
if (ServerInstance->XLines->AddLine(el, user))
{
if (!duration)
diff --git a/src/coremods/core_xline/cmd_gline.cpp b/src/coremods/core_xline/cmd_gline.cpp
index b9da576c2..634f3efa6 100644
--- a/src/coremods/core_xline/cmd_gline.cpp
+++ b/src/coremods/core_xline/cmd_gline.cpp
@@ -76,7 +76,7 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters)
user->WriteNotice("*** Invalid duration for G-line.");
return CmdResult::FAILURE;
}
- GLine* gl = new GLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
+ GLine* gl = new GLine(ServerInstance->Time(), duration, user->nick, parameters[2], ih.first, ih.second);
if (ServerInstance->XLines->AddLine(gl, user))
{
if (!duration)
diff --git a/src/coremods/core_xline/cmd_kline.cpp b/src/coremods/core_xline/cmd_kline.cpp
index 70ba6e020..b130fe567 100644
--- a/src/coremods/core_xline/cmd_kline.cpp
+++ b/src/coremods/core_xline/cmd_kline.cpp
@@ -76,7 +76,7 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters)
user->WriteNotice("*** Invalid duration for K-line.");
return CmdResult::FAILURE;
}
- KLine* kl = new KLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
+ KLine* kl = new KLine(ServerInstance->Time(), duration, user->nick, parameters[2], ih.first, ih.second);
if (ServerInstance->XLines->AddLine(kl,user))
{
if (!duration)
diff --git a/src/coremods/core_xline/cmd_qline.cpp b/src/coremods/core_xline/cmd_qline.cpp
index c0eef5def..7d79f32e7 100644
--- a/src/coremods/core_xline/cmd_qline.cpp
+++ b/src/coremods/core_xline/cmd_qline.cpp
@@ -58,7 +58,7 @@ CmdResult CommandQline::Handle(User* user, const Params& parameters)
user->WriteNotice("*** Invalid duration for Q-line.");
return CmdResult::FAILURE;
}
- QLine* ql = new QLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
+ QLine* ql = new QLine(ServerInstance->Time(), duration, user->nick, parameters[2], parameters[0]);
if (ServerInstance->XLines->AddLine(ql,user))
{
if (!duration)
diff --git a/src/coremods/core_xline/cmd_zline.cpp b/src/coremods/core_xline/cmd_zline.cpp
index c400f098b..8eb07c4be 100644
--- a/src/coremods/core_xline/cmd_zline.cpp
+++ b/src/coremods/core_xline/cmd_zline.cpp
@@ -76,7 +76,7 @@ CmdResult CommandZline::Handle(User* user, const Params& parameters)
user->WriteNotice("*** Invalid duration for Z-line.");
return CmdResult::FAILURE;
}
- ZLine* zl = new ZLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ipaddr);
+ ZLine* zl = new ZLine(ServerInstance->Time(), duration, user->nick, parameters[2], ipaddr);
if (ServerInstance->XLines->AddLine(zl,user))
{
if (!duration)
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 2f18d14d4..03ba05103 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -253,7 +253,7 @@ bool irc::sepstream::GetToken(std::string &token)
return true;
}
-const std::string irc::sepstream::GetRemaining()
+std::string irc::sepstream::GetRemaining()
{
return !this->StreamEnd() ? this->tokens.substr(this->pos) : "";
}
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index ac2293722..236f2e9de 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -130,7 +130,7 @@ void InspIRCd::ProcessColors(std::vector<std::string>& input)
for (auto& ret : input)
{
- for(int i = 0; special[i].character.empty() == false; ++i)
+ for(int i = 0; !special[i].character.empty(); ++i)
{
std::string::size_type pos = ret.find(special[i].character);
if(pos == std::string::npos) // Couldn't find the character, skip this line
@@ -400,7 +400,7 @@ std::string InspIRCd::Format(va_list& vaList, const char* formatString)
va_list dst;
va_copy(dst, vaList);
- int vsnret = vsnprintf(&formatBuffer[0], formatBuffer.size(), formatString, dst);
+ int vsnret = vsnprintf(formatBuffer.data(), formatBuffer.size(), formatString, dst);
va_end(dst);
if (vsnret > 0 && static_cast<unsigned>(vsnret) < formatBuffer.size())
@@ -411,7 +411,7 @@ std::string InspIRCd::Format(va_list& vaList, const char* formatString)
formatBuffer.resize(formatBuffer.size() * 2);
}
- return std::string(&formatBuffer[0]);
+ return std::string(formatBuffer.data());
}
std::string InspIRCd::Format(const char* formatString, ...)
@@ -453,19 +453,19 @@ std::string InspIRCd::TimeString(time_t curtime, const char* format, bool utc)
return buffer;
}
-std::string InspIRCd::GenRandomStr(size_t length, bool printable)
+std::string InspIRCd::GenRandomStr(size_t length, bool printable) const
{
std::vector<char> str(length);
- GenRandom(&str[0], length);
+ GenRandom(str.data(), length);
if (printable)
for (size_t i = 0; i < length; i++)
str[i] = 0x3F + (str[i] & 0x3F);
- return std::string(&str[0], str.size());
+ return std::string(str.data(), str.size());
}
// NOTE: this has a slight bias for lower values if max is not a power of 2.
// Don't use it if that matters.
-unsigned long InspIRCd::GenRandomInt(unsigned long max)
+unsigned long InspIRCd::GenRandomInt(unsigned long max) const
{
unsigned long rv;
GenRandom(reinterpret_cast<char*>(&rv), sizeof(rv));
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 71fb493ec..acf2816e2 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -403,7 +403,7 @@ bool SocketTimeout::Tick()
}
void BufferedSocket::OnConnected() { }
-void BufferedSocket::OnTimeout() { return; }
+void BufferedSocket::OnTimeout() { }
void BufferedSocket::OnEventHandlerWrite()
{
diff --git a/src/mode.cpp b/src/mode.cpp
index 2b8e70f42..5eca116cb 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -711,7 +711,7 @@ PrefixMode* ModeParser::FindPrefixMode(unsigned char modeletter)
}
-PrefixMode* ModeParser::FindNearestPrefixMode(ModeHandler::Rank rank)
+PrefixMode* ModeParser::FindNearestPrefixMode(ModeHandler::Rank rank) const
{
PrefixMode* pm = nullptr;
for (const auto& thispm : GetPrefixModes())
@@ -727,7 +727,7 @@ PrefixMode* ModeParser::FindNearestPrefixMode(ModeHandler::Rank rank)
return pm;
}
-PrefixMode* ModeParser::FindPrefix(unsigned char pfxletter)
+PrefixMode* ModeParser::FindPrefix(unsigned char pfxletter) const
{
for (const auto& pm : GetPrefixModes())
{
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 67b5ec2a5..fe5e806af 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -60,7 +60,7 @@ bool ModuleManager::Load(const std::string& modname, bool defer)
}
Module* newmod = nullptr;
- DLLManager* newhandle = new DLLManager(moduleFile.c_str());
+ DLLManager* newhandle = new DLLManager(moduleFile);
ServiceList newservices;
if (!defer)
this->NewServices = &newservices;
diff --git a/src/modules/extra/m_argon2.cpp b/src/modules/extra/m_argon2.cpp
index 57e2d895d..e972939fe 100644
--- a/src/modules/extra/m_argon2.cpp
+++ b/src/modules/extra/m_argon2.cpp
@@ -137,9 +137,9 @@ public:
data.length(),
salt.c_str(),
salt.length(),
- &raw_data[0],
+ raw_data.data(),
raw_data.size(),
- &encoded_data[0],
+ encoded_data.data(),
encoded_data.size(),
argon2Type,
config.version);
@@ -152,7 +152,7 @@ public:
// to do anything useful with them if we don't encode them.
// So we pretend this is the raw version, and instead make
// ToPrintable return its input.
- return std::string(&encoded_data[0], encoded_data.size());
+ return std::string(encoded_data.data(), encoded_data.size());
}
std::string ToPrintable(const std::string& raw) override
diff --git a/src/modules/extra/m_log_syslog.cpp b/src/modules/extra/m_log_syslog.cpp
index a3cf23ec6..62d08e45e 100644
--- a/src/modules/extra/m_log_syslog.cpp
+++ b/src/modules/extra/m_log_syslog.cpp
@@ -26,7 +26,7 @@ class SyslogMethod final
{
private:
// Converts an InspIRCd log level to syslog priority.
- int LevelToPriority(Log::Level level)
+ static int LevelToPriority(Log::Level level)
{
switch (level)
{
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index c76034cc1..51fdef06c 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -269,7 +269,7 @@ class SQLConnection final
: public SQL::Provider
{
private:
- bool EscapeString(SQL::Query* query, const std::string& in, std::string& out)
+ bool EscapeString(SQL::Query* query, const std::string& in, std::string& out) const
{
// In the worst case each character may need to be encoded as using two bytes and one
// byte is the NUL terminator.
@@ -281,7 +281,7 @@ private:
// Unfortunately, someone genius decided that mysql_escape_string should return an
// unsigned type even though -1 is returned on error so checking whether an error
// happened is a bit cursed.
- unsigned long escapedsize = mysql_escape_string(&buffer[0], in.c_str(), in.length());
+ unsigned long escapedsize = mysql_escape_string(buffer.data(), in.c_str(), in.length());
if (escapedsize == static_cast<unsigned long>(-1))
{
SQL::Error err(SQL::QSEND_FAIL, InspIRCd::Format("%u: %s", mysql_errno(connection), mysql_error(connection)));
@@ -289,7 +289,7 @@ private:
return false;
}
- out.append(&buffer[0], escapedsize);
+ out.append(buffer.data(), escapedsize);
return true;
}
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index ad3743ad9..e388f377f 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -446,10 +446,10 @@ restart:
std::string parm = p[param++];
std::vector<char> buffer(parm.length() * 2 + 1);
int error;
- size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error);
+ size_t escapedsize = PQescapeStringConn(sql, buffer.data(), parm.data(), parm.length(), &error);
if (error)
ServerInstance->Logs.Debug(MODNAME, "BUG: Apparently PQescapeStringConn() failed");
- res.append(&buffer[0], escapedsize);
+ res.append(buffer.data(), escapedsize);
}
}
}
@@ -477,10 +477,10 @@ restart:
std::string parm = it->second;
std::vector<char> buffer(parm.length() * 2 + 1);
int error;
- size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error);
+ size_t escapedsize = PQescapeStringConn(sql, buffer.data(), parm.data(), parm.length(), &error);
if (error)
ServerInstance->Logs.Debug(MODNAME, "BUG: Apparently PQescapeStringConn() failed");
- res.append(&buffer[0], escapedsize);
+ res.append(buffer.data(), escapedsize);
}
}
}
diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp
index 819046e2b..7476039cd 100644
--- a/src/modules/extra/m_regex_posix.cpp
+++ b/src/modules/extra/m_regex_posix.cpp
@@ -51,10 +51,10 @@ public:
std::vector<char> errormsg(errorsize);
// Retrieve the error message and free the buffer.
- regerror(error, &regex, &errormsg[0], errormsg.size());
+ regerror(error, &regex, errormsg.data(), errormsg.size());
regfree(&regex);
- throw Regex::Exception(mod, pattern, std::string(&errormsg[0], errormsg.size() - 1));
+ throw Regex::Exception(mod, pattern, std::string(errormsg.data(), errormsg.size() - 1));
}
~POSIXPattern() override
@@ -70,7 +70,7 @@ public:
std::optional<Regex::MatchCollection> Matches(const std::string& text) override
{
std::vector<regmatch_t> matches(32);
- int result = regexec(&regex, text.c_str(), matches.size(), &matches[0], 0);
+ int result = regexec(&regex, text.c_str(), matches.size(), matches.data(), 0);
if (result)
return std::nullopt;
diff --git a/src/modules/extra/m_regex_re2.cpp b/src/modules/extra/m_regex_re2.cpp
index 068be5049..7874564cc 100644
--- a/src/modules/extra/m_regex_re2.cpp
+++ b/src/modules/extra/m_regex_re2.cpp
@@ -37,7 +37,7 @@ class RE2Pattern final
private:
RE2 regex;
- RE2::Options BuildOptions(uint8_t options)
+ static RE2::Options BuildOptions(uint8_t options)
{
RE2::Options re2options;
re2options.set_case_sensitive(!(options & Regex::OPT_CASE_INSENSITIVE));
@@ -62,7 +62,7 @@ public:
std::optional<Regex::MatchCollection> Matches(const std::string& text) override
{
std::vector<re2::StringPiece> re2captures(regex.NumberOfCapturingGroups() + 1);
- bool result = regex.Match(text, 0, text.length(), RE2::ANCHOR_BOTH, &re2captures[0], static_cast<int>(re2captures.size()));
+ bool result = regex.Match(text, 0, text.length(), RE2::ANCHOR_BOTH, re2captures.data(), static_cast<int>(re2captures.size()));
if (!result)
return std::nullopt;
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index b21ce982f..d1f31817c 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -229,7 +229,7 @@ namespace GnuTLS
gnutls_x509_crt_deinit(cert);
}
- gnutls_x509_crt_t* raw() { return &certs[0]; }
+ gnutls_x509_crt_t* raw() { return certs.data(); }
size_t size() const { return certs.size(); }
};
@@ -983,15 +983,15 @@ public:
unsigned int nameType = GNUTLS_NAME_DNS;
// First, determine the size of the hostname.
- if (gnutls_server_name_get(sess, &nameBuffer[0], &nameLength, &nameType, 0) != GNUTLS_E_SHORT_MEMORY_BUFFER)
+ if (gnutls_server_name_get(sess, nameBuffer.data(), &nameLength, &nameType, 0) != GNUTLS_E_SHORT_MEMORY_BUFFER)
return false;
// Then retrieve the hostname.
nameBuffer.resize(nameLength);
- if (gnutls_server_name_get(sess, &nameBuffer[0], &nameLength, &nameType, 0) != GNUTLS_E_SUCCESS)
+ if (gnutls_server_name_get(sess, nameBuffer.data(), &nameLength, &nameType, 0) != GNUTLS_E_SUCCESS)
return false;
- out.append(&nameBuffer[0]);
+ out.append(nameBuffer.data());
return true;
}
diff --git a/src/modules/m_abbreviation.cpp b/src/modules/m_abbreviation.cpp
index dfed73020..4517e6a45 100644
--- a/src/modules/m_abbreviation.cpp
+++ b/src/modules/m_abbreviation.cpp
@@ -51,7 +51,8 @@ public:
/* Look for any command that starts with the same characters, if it does, replace the command string with it */
size_t clen = command.length() - 1;
- std::string foundcommand, matchlist;
+ std::string foundcommand;
+ std::string matchlist;
bool foundmatch = false;
for (const auto& [cmdname, _] : ServerInstance->Parser.GetCommands())
{
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 621fa4f04..ea8be2c41 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -119,7 +119,7 @@ public:
{
}
- std::string GetVar(std::string varname, const std::string &original_line)
+ static std::string GetVar(std::string varname, const std::string &original_line)
{
irc::spacesepstream ss(original_line);
varname.erase(varname.begin());
@@ -144,7 +144,7 @@ public:
return word;
}
- std::string CreateRFCMessage(const std::string& command, CommandBase::Params& parameters)
+ static std::string CreateRFCMessage(const std::string& command, CommandBase::Params& parameters)
{
std::string message(command);
for (CommandBase::Params::const_iterator iter = parameters.begin(); iter != parameters.end();)
@@ -377,7 +377,8 @@ public:
irc::tokenstream ss(result);
CommandBase::Params pars;
- std::string command, token;
+ std::string command;
+ std::string token;
ss.GetMiddle(command);
while (ss.GetTrailing(token))
diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp
index e9bd3d45e..beb29f2ec 100644
--- a/src/modules/m_anticaps.cpp
+++ b/src/modules/m_anticaps.cpp
@@ -52,7 +52,7 @@ class AntiCapsMode final
: public ParamMode<AntiCapsMode, SimpleExtItem<AntiCapsSettings>>
{
private:
- bool ParseMethod(irc::sepstream& stream, AntiCapsMethod& method)
+ static bool ParseMethod(irc::sepstream& stream, AntiCapsMethod& method)
{
std::string methodstr;
if (!stream.GetToken(methodstr))
@@ -74,7 +74,7 @@ private:
return true;
}
- bool ParseMinimumLength(irc::sepstream& stream, uint16_t& minlen)
+ static bool ParseMinimumLength(irc::sepstream& stream, uint16_t& minlen)
{
std::string minlenstr;
if (!stream.GetToken(minlenstr))
@@ -88,7 +88,7 @@ private:
return true;
}
- bool ParsePercent(irc::sepstream& stream, uint8_t& percent)
+ static bool ParsePercent(irc::sepstream& stream, uint8_t& percent)
{
std::string percentstr;
if (!stream.GetToken(percentstr))
@@ -176,7 +176,7 @@ private:
ServerInstance->Modes.Process(ServerInstance->FakeClient, channel, nullptr, changelist);
}
- void InformUser(Channel* channel, User* user, const std::string& message)
+ static void InformUser(Channel* channel, User* user, const std::string& message)
{
user->WriteNumeric(Numerics::CannotSendTo(channel, message + " and was blocked."));
}
diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp
index a7b3d0804..566171fe5 100644
--- a/src/modules/m_auditorium.cpp
+++ b/src/modules/m_auditorium.cpp
@@ -118,10 +118,7 @@ public:
// Can you see the list by permission?
ModResult res = CheckExemption::Call(exemptionprov, issuer, memb->chan, "auditorium-see");
- if (res.check(OpsCanSee && memb->chan->GetPrefixValue(issuer) >= OP_VALUE))
- return true;
-
- return false;
+ return res.check(OpsCanSee && memb->chan->GetPrefixValue(issuer) >= OP_VALUE);
}
ModResult OnNamesListItem(LocalUser* issuer, Membership* memb, std::string& prefixes, std::string& nick) override
diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp
index dca983b3e..dc03eddb2 100644
--- a/src/modules/m_autoop.cpp
+++ b/src/modules/m_autoop.cpp
@@ -42,7 +42,7 @@ public:
syntax = "<prefix>:<mask>";
}
- PrefixMode* FindMode(const std::string& mid)
+ static PrefixMode* FindMode(const std::string& mid)
{
if (mid.length() == 1)
return ServerInstance->Modes.FindPrefixMode(mid[0]);
diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp
index 9234c1b6f..b9bfab626 100644
--- a/src/modules/m_banexception.cpp
+++ b/src/modules/m_banexception.cpp
@@ -89,7 +89,8 @@ public:
for (const ListModeBase::ListItem& ban : *list)
{
bool inverted;
- std::string name, value;
+ std::string name;
+ std::string value;
if (!ExtBan::Parse(ban.mask, name, value, inverted))
continue;
diff --git a/src/modules/m_bcrypt.cpp b/src/modules/m_bcrypt.cpp
index 0e464081c..62e50db07 100644
--- a/src/modules/m_bcrypt.cpp
+++ b/src/modules/m_bcrypt.cpp
@@ -43,7 +43,7 @@ private:
public:
unsigned long rounds = 10;
- std::string Generate(const std::string& data, const std::string& salt)
+ static std::string Generate(const std::string& data, const std::string& salt)
{
char hash[64];
_crypt_blowfish_rn(data.c_str(), salt.c_str(), hash, sizeof(hash));
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index e810aed2c..57099b257 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -127,7 +127,7 @@ public:
return CmdResult::FAILURE;
}
const char *reason = (parameters.size() > 2) ? parameters[2].c_str() : "No reason supplied";
- CBan* r = new CBan(ServerInstance->Time(), duration, user->nick.c_str(), reason, parameters[0].c_str());
+ CBan* r = new CBan(ServerInstance->Time(), duration, user->nick, reason, parameters[0]);
if (ServerInstance->XLines->AddLine(r, user))
{
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index ede792d42..ea3243272 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -41,7 +41,7 @@ private:
User* const user;
const std::string& target;
- std::string FormatTime(time_t ts)
+ static std::string FormatTime(time_t ts)
{
std::string timestr(InspIRCd::TimeString(ts, "%Y-%m-%d %H:%M:%S UTC (", true));
timestr.append(ConvToStr(ts));
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index c8a8cfaa2..c8766478f 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -241,7 +241,7 @@ public:
* @param domainparts The number of domain labels that should be visible.
* @return The visible segment of the hostname.
*/
- std::string VisibleDomainParts(const std::string& host, unsigned int domainparts)
+ static std::string VisibleDomainParts(const std::string& host, unsigned int domainparts)
{
// The position at which we found the last dot.
std::string::const_reverse_iterator dotpos;
@@ -302,8 +302,11 @@ public:
std::string SegmentIP(const CloakInfo& info, const irc::sockets::sockaddrs& ip, bool full)
{
std::string bindata;
- size_t hop1, hop2, hop3;
- size_t len1, len2;
+ size_t hop1;
+ size_t hop2;
+ size_t hop3;
+ size_t len1;
+ size_t len2;
std::string rv;
if (ip.family() == AF_INET6)
{
diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp
index f72907bcf..e6ff7a919 100644
--- a/src/modules/m_codepage.cpp
+++ b/src/modules/m_codepage.cpp
@@ -198,7 +198,7 @@ private:
hashmap.swap(newhash);
}
- void CheckDuplicateNick()
+ static void CheckDuplicateNick()
{
insp::flat_set<std::string, irc::insensitive_swo> duplicates;
for (auto* user : ServerInstance->Users.GetLocalUsers())
@@ -211,7 +211,7 @@ private:
}
}
- void CheckInvalidNick()
+ static void CheckInvalidNick()
{
for (auto* user : ServerInstance->Users.GetLocalUsers())
{
diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp
index cf11e299e..535702101 100644
--- a/src/modules/m_connectban.cpp
+++ b/src/modules/m_connectban.cpp
@@ -47,7 +47,7 @@ private:
time_t ignoreuntil = 0;
std::string banmessage;
- unsigned char GetRange(LocalUser* user)
+ unsigned char GetRange(LocalUser* user) const
{
int family = user->client_sa.family();
switch (family)
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index f113215f7..3384741f3 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -194,6 +194,7 @@ public:
: Command(parent, "DCCALLOW", 0)
, ext(Ext)
{
+ allow_empty_last_param = false;
syntax = { "[(+|-)<nick> [<time>]]", "LIST", "HELP" };
/* XXX we need to fix this so it can work with translation stuff (i.e. move +- into a seperate param */
}
@@ -201,15 +202,15 @@ public:
CmdResult Handle(User* user, const Params& parameters) override
{
/* syntax: DCCALLOW [(+|-)<nick> [<time>]]|[LIST|HELP] */
- if (!parameters.size())
+ if (parameters.empty())
{
// display current DCCALLOW list
DisplayDCCAllowList(user);
return CmdResult::FAILURE;
}
- else if (parameters.size() > 0)
+ else
{
- char action = *parameters[0].c_str();
+ char action = parameters[0][0];
// if they didn't specify an action, this is probably a command
if (action != '+' && action != '-')
@@ -344,7 +345,7 @@ public:
return ROUTE_BROADCAST;
}
- void DisplayHelp(User* user)
+ static void DisplayHelp(User* user)
{
user->WriteNumeric(RPL_HELPSTART, "*", "DCCALLOW [(+|-)<nick> [<time>]]|[LIST|HELP]");
for (const auto& helpline : helptext)
@@ -436,7 +437,7 @@ public:
if (irc::equals(ctcpname, "DCC") && !ctcpbody.empty())
{
dl = ext.Get(u);
- if (dl && dl->size())
+ if (dl && !dl->empty())
{
for (const auto& dccallow : *dl)
{
@@ -524,7 +525,7 @@ public:
dl = ext.Get(u);
if (dl)
{
- if (dl->size())
+ if (!dl->empty())
{
dccallowlist::iterator iter2 = dl->begin();
while (iter2 != dl->end())
@@ -559,7 +560,7 @@ public:
dl = ext.Get(u);
if (dl)
{
- if (dl->size())
+ if (!dl->empty())
{
for (dccallowlist::iterator i = dl->begin(); i != dl->end(); ++i)
{
@@ -582,7 +583,7 @@ public:
}
}
- void RemoveFromUserlist(User *user)
+ static void RemoveFromUserlist(User *user)
{
// remove user from userlist
for (userlist::iterator j = ul.begin(); j != ul.end(); ++j)
diff --git a/src/modules/m_disable.cpp b/src/modules/m_disable.cpp
index 774ecb278..57f471d13 100644
--- a/src/modules/m_disable.cpp
+++ b/src/modules/m_disable.cpp
@@ -64,7 +64,7 @@ private:
}
}
- void WriteLog(const char* message, ...) ATTR_PRINTF(2, 3)
+ void WriteLog(const char* message, ...) const ATTR_PRINTF(2, 3)
{
std::string buffer;
VAFORMAT(buffer, message, message);
@@ -127,7 +127,7 @@ public:
ModResult OnNumeric(User* user, const Numeric::Numeric& numeric) override
{
- if (numeric.GetNumeric() != RPL_COMMANDS || numeric.GetParams().size() < 1)
+ if (numeric.GetNumeric() != RPL_COMMANDS || numeric.GetParams().empty())
return MOD_RES_PASSTHRU; // The numeric isn't the one we care about.
if (!fakenonexistent || !IS_LOCAL(user))
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index 5530f0fde..d1e55238f 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -411,11 +411,10 @@ public:
std::string reversedip;
if (user->client_sa.family() == AF_INET)
{
- unsigned int a, b, c, d;
- d = (unsigned int) (user->client_sa.in4.sin_addr.s_addr >> 24) & 0xFF;
- c = (unsigned int) (user->client_sa.in4.sin_addr.s_addr >> 16) & 0xFF;
- b = (unsigned int) (user->client_sa.in4.sin_addr.s_addr >> 8) & 0xFF;
- a = (unsigned int) user->client_sa.in4.sin_addr.s_addr & 0xFF;
+ unsigned int a = (unsigned int) user->client_sa.in4.sin_addr.s_addr & 0xFF;
+ unsigned int b = (unsigned int) (user->client_sa.in4.sin_addr.s_addr >> 8) & 0xFF;
+ unsigned int c = (unsigned int) (user->client_sa.in4.sin_addr.s_addr >> 16) & 0xFF;
+ unsigned int d = (unsigned int) (user->client_sa.in4.sin_addr.s_addr >> 24) & 0xFF;
reversedip = ConvToStr(d) + "." + ConvToStr(c) + "." + ConvToStr(b) + "." + ConvToStr(a);
}
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 51c13c07a..cb1d6a893 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -229,7 +229,7 @@ public:
std::pair<bool, std::string> AddFilter(const std::string& freeform, FilterAction type, const std::string& reason, unsigned long duration, const std::string& flags, bool config = false);
void ReadConfig(ConfigStatus& status) override;
void GetLinkData(LinkData& data, std::string& compatdata) override;
- std::string EncodeFilter(const FilterResult& filter);
+ static std::string EncodeFilter(const FilterResult& filter);
FilterResult DecodeFilter(const std::string &data);
void OnSyncNetwork(ProtocolInterface::Server& server) override;
void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata) override;
@@ -465,7 +465,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
}
else if (f->action == FA_SHUN && (ServerInstance->XLines->GetFactory("SHUN")))
{
- Shun* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), user->GetIPString());
+ Shun* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString());
ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was shunned for %s (expires on %s) because their message to %s matched %s (%s)",
user->nick.c_str(), sh->Displayable().c_str(), InspIRCd::DurationString(f->duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(),
@@ -479,7 +479,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
}
else if (f->action == FA_GLINE)
{
- GLine* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), "*", user->GetIPString());
+ GLine* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString());
ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was G-lined for %s (expires on %s) because their message to %s matched %s (%s)",
user->nick.c_str(), gl->Displayable().c_str(), InspIRCd::DurationString(f->duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(),
@@ -493,7 +493,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
}
else if (f->action == FA_ZLINE)
{
- ZLine* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), user->GetIPString());
+ ZLine* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString());
ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was Z-lined for %s (expires on %s) because their message to %s matched %s (%s)",
user->nick.c_str(), zl->Displayable().c_str(), InspIRCd::DurationString(f->duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(),
@@ -522,7 +522,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params&
if (command == "QUIT")
{
/* QUIT with no reason: nothing to do */
- if (parameters.size() < 1)
+ if (parameters.empty())
return MOD_RES_PASSTHRU;
parting = false;
@@ -570,7 +570,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params&
if (f->action == FA_GLINE)
{
/* Note: We G-line *@IP so that if their host doesn't resolve the G-line still applies. */
- GLine* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), "*", user->GetIPString());
+ GLine* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString());
ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was G-lined for %s (expires on %s) because their %s message matched %s (%s)",
user->nick.c_str(), gl->Displayable().c_str(),
InspIRCd::DurationString(f->duration).c_str(),
@@ -586,7 +586,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params&
}
if (f->action == FA_ZLINE)
{
- ZLine* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), user->GetIPString());
+ ZLine* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString());
ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was Z-lined for %s (expires on %s) because their %s message matched %s (%s)",
user->nick.c_str(), zl->Displayable().c_str(),
InspIRCd::DurationString(f->duration).c_str(),
@@ -603,7 +603,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params&
else if (f->action == FA_SHUN && (ServerInstance->XLines->GetFactory("SHUN")))
{
/* Note: We shun *!*@IP so that if their host doesnt resolve the shun still applies. */
- Shun* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), user->GetIPString());
+ Shun* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString());
ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was shunned for %s (expires on %s) because their %s message matched %s (%s)",
user->nick.c_str(), sh->Displayable().c_str(),
InspIRCd::DurationString(f->duration).c_str(),
diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp
index 6e9a0f861..e1f5e7292 100644
--- a/src/modules/m_globalload.cpp
+++ b/src/modules/m_globalload.cpp
@@ -42,9 +42,9 @@ public:
{
std::string servername = parameters.size() > 1 ? parameters[1] : "*";
- if (InspIRCd::Match(ServerInstance->Config->ServerName.c_str(), servername))
+ if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
{
- if (ServerInstance->Modules.Load(parameters[0].c_str()))
+ if (ServerInstance->Modules.Load(parameters[0]))
{
ServerInstance->SNO.WriteToSnoMask('a', "NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
user->WriteRemoteNumeric(RPL_LOADEDMODULE, parameters[0], "Module successfully loaded.");
@@ -88,7 +88,7 @@ public:
std::string servername = parameters.size() > 1 ? parameters[1] : "*";
- if (InspIRCd::Match(ServerInstance->Config->ServerName.c_str(), servername))
+ if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
{
Module* m = ServerInstance->Modules.Find(parameters[0]);
if (m)
@@ -134,7 +134,7 @@ public:
{
std::string servername = parameters.size() > 1 ? parameters[1] : "*";
- if (InspIRCd::Match(ServerInstance->Config->ServerName.c_str(), servername))
+ if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
{
Module* m = ServerInstance->Modules.Find(parameters[0]);
if (m)
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 17b5c4c24..b923e6371 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -192,7 +192,7 @@ public:
}
}
- bool HasResult()
+ bool HasResult() const
{
return done;
}
diff --git a/src/modules/m_ircv3_capnotify.cpp b/src/modules/m_ircv3_capnotify.cpp
index 9a06189fa..0706ba88b 100644
--- a/src/modules/m_ircv3_capnotify.cpp
+++ b/src/modules/m_ircv3_capnotify.cpp
@@ -28,9 +28,7 @@ class CapNotify final
bool OnRequest(LocalUser* user, bool add) override
{
// Users using the negotiation protocol v3.2 or newer may not turn off cap-notify
- if ((!add) && (GetProtocol(user) != Cap::CAP_LEGACY))
- return false;
- return true;
+ return add || GetProtocol(user) == Cap::CAP_LEGACY;
}
bool OnList(LocalUser* user) override
diff --git a/src/modules/m_ircv3_sts.cpp b/src/modules/m_ircv3_sts.cpp
index d2823f895..2f5287248 100644
--- a/src/modules/m_ircv3_sts.cpp
+++ b/src/modules/m_ircv3_sts.cpp
@@ -132,7 +132,7 @@ private:
STSCap cap;
// The IRCv3 STS specification requires that the server is listening using TLS using a valid certificate.
- bool HasValidSSLPort(unsigned int port)
+ static bool HasValidSSLPort(unsigned int port)
{
for (const auto& ls : ServerInstance->ports)
{
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp
index f7e4aaa1d..4aca441e1 100644
--- a/src/modules/m_joinflood.cpp
+++ b/src/modules/m_joinflood.cpp
@@ -59,7 +59,7 @@ public:
counter++;
}
- bool shouldlock()
+ bool shouldlock() const
{
return (counter >= this->joins);
}
diff --git a/src/modules/m_log_sql.cpp b/src/modules/m_log_sql.cpp
index 4ffe6784a..7e02d43f9 100644
--- a/src/modules/m_log_sql.cpp
+++ b/src/modules/m_log_sql.cpp
@@ -87,7 +87,6 @@ public:
{
}
-public:
Log::MethodPtr Create(std::shared_ptr<ConfigTag> tag) override
{
dynamic_reference<SQL::Provider> sql(creator, "SQL");
diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp
index 7386041c4..8a1c9eb3b 100644
--- a/src/modules/m_md5.cpp
+++ b/src/modules/m_md5.cpp
@@ -43,8 +43,8 @@ public:
MD5_Update(&context, reinterpret_cast<const unsigned char*>(data.data()), data.length());
std::vector<unsigned char> bytes(16);
- MD5_Final(&bytes[0], &context);
- return std::string(reinterpret_cast<const char*>(&bytes[0]), bytes.size());
+ MD5_Final(bytes.data(), &context);
+ return std::string(reinterpret_cast<const char*>(bytes.data()), bytes.size());
}
MD5Provider(Module* parent)
diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp
index e2970e073..9e13975d1 100644
--- a/src/modules/m_nickflood.cpp
+++ b/src/modules/m_nickflood.cpp
@@ -58,7 +58,7 @@ public:
counter++;
}
- bool shouldlock()
+ bool shouldlock() const
{
return ((ServerInstance->Time() <= reset) && (counter == this->nicks));
}
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 72fa45817..fa9ae2fe5 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -109,7 +109,7 @@ private:
return false;
}
- ModResult HandleJoinOverride(LocalUser* user, Channel* chan, const std::string& keygiven, const char* bypasswhat, const char* mode)
+ ModResult HandleJoinOverride(LocalUser* user, Channel* chan, const std::string& keygiven, const char* bypasswhat, const char* mode) const
{
if (RequireKey && keygiven != "override")
{
diff --git a/src/modules/m_pbkdf2.cpp b/src/modules/m_pbkdf2.cpp
index 3811ccff8..259f326ad 100644
--- a/src/modules/m_pbkdf2.cpp
+++ b/src/modules/m_pbkdf2.cpp
@@ -66,11 +66,9 @@ public:
return ConvToStr(this->iterations) + ":" + Base64::Encode(this->hash) + ":" + Base64::Encode(this->salt);
}
- bool IsValid()
+ bool IsValid() const
{
- if (!this->iterations || !this->length || this->salt.empty() || this->hash.empty())
- return false;
- return true;
+ return this->iterations && this->length && !this->salt.empty() && !this->hash.empty();
}
};
@@ -82,7 +80,7 @@ public:
unsigned long iterations;
size_t dkey_length;
- std::string PBKDF2(const std::string& pass, const std::string& salt, unsigned long itr = 0, size_t dkl = 0)
+ std::string PBKDF2(const std::string& pass, const std::string& salt, unsigned long itr = 0, size_t dkl = 0) const
{
size_t blocks = std::ceil((double)dkl / provider->out_size);
diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp
index 9120cde9a..33bcf731a 100644
--- a/src/modules/m_repeat.cpp
+++ b/src/modules/m_repeat.cpp
@@ -262,7 +262,7 @@ public:
}
private:
- bool ParseSettings(User* source, std::string& parameter, ChannelSettings& settings)
+ static bool ParseSettings(User* source, std::string& parameter, ChannelSettings& settings)
{
irc::sepstream stream(parameter, ':');
std::string item;
diff --git a/src/modules/m_restrictmsg.cpp b/src/modules/m_restrictmsg.cpp
index 073ab6a80..acbff05ae 100644
--- a/src/modules/m_restrictmsg.cpp
+++ b/src/modules/m_restrictmsg.cpp
@@ -32,7 +32,7 @@ class ModuleRestrictMsg final
, public CTCTags::EventListener
{
private:
- ModResult HandleMessage(User* user, const MessageTarget& target)
+ static ModResult HandleMessage(User* user, const MessageTarget& target)
{
if ((target.type == MessageTarget::TYPE_USER) && (IS_LOCAL(user)))
{
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index daf59ff7e..0d1d01f91 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -68,7 +68,7 @@ public:
{
if (ZlineOnMatch)
{
- ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, MODNAME "@" + ServerInstance->Config->ServerName, reason.c_str(), u->GetIPString());
+ ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, MODNAME "@" + ServerInstance->Config->ServerName, reason, u->GetIPString());
if (ServerInstance->XLines->AddLine(zl, nullptr))
{
if (!duration)
@@ -161,7 +161,7 @@ public:
try
{
- r = factory.Generate(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
+ r = factory.Generate(ServerInstance->Time(), duration, user->nick, parameters[2], parameters[0]);
}
catch (const ModuleException& e)
{
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp
index 7bca715db..48cd996f2 100644
--- a/src/modules/m_sasl.cpp
+++ b/src/modules/m_sasl.cpp
@@ -210,7 +210,7 @@ public:
SendSASL(user, "*", 'S', params);
}
- SaslResult GetSaslResult(const std::string &result_)
+ static SaslResult GetSaslResult(const std::string &result_)
{
if (result_ == "F")
return SASL_FAIL;
@@ -351,7 +351,7 @@ public:
SaslAuthenticator *sasl = authExt.Get(user);
if (!sasl)
authExt.SetFwd(user, user, parameters[0], sslapi);
- else if (sasl->SendClientMessage(parameters) == false) // IAL abort extension --nenolod
+ else if (!sasl->SendClientMessage(parameters))
{
sasl->AnnounceState();
authExt.Unset(user);
diff --git a/src/modules/m_sha2.cpp b/src/modules/m_sha2.cpp
index 7d85d5a8e..44f92c17c 100644
--- a/src/modules/m_sha2.cpp
+++ b/src/modules/m_sha2.cpp
@@ -52,8 +52,8 @@ public:
std::string GenerateRaw(const std::string& data) override
{
std::vector<char> bytes(out_size);
- SHA(reinterpret_cast<const unsigned char*>(data.data()), static_cast<unsigned int>(data.size()), reinterpret_cast<unsigned char*>(&bytes[0]));
- return std::string(&bytes[0], bytes.size());
+ SHA(reinterpret_cast<const unsigned char*>(data.data()), static_cast<unsigned int>(data.size()), reinterpret_cast<unsigned char*>(bytes.data()));
+ return std::string(bytes.data(), bytes.size());
}
};
diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp
index 56147c5a4..7656e2c3c 100644
--- a/src/modules/m_showwhois.cpp
+++ b/src/modules/m_showwhois.cpp
@@ -52,7 +52,7 @@ public:
access_needed = CmdAccess::SERVER;
}
- void HandleFast(User* dest, User* src)
+ static void HandleFast(User* dest, User* src)
{
dest->WriteNotice("*** " + src->nick + " (" + src->ident + "@" +
src->GetHost(dest->HasPrivPermission("users/auspex")) +
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index e28043da6..07a3119dc 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -113,7 +113,7 @@ public:
expr = parameters[1];
}
- Shun* r = new Shun(ServerInstance->Time(), duration, user->nick.c_str(), expr.c_str(), target.c_str());
+ Shun* r = new Shun(ServerInstance->Time(), duration, user->nick, expr, target);
if (ServerInstance->XLines->AddLine(r, user))
{
if (!duration)
@@ -152,7 +152,7 @@ private:
TokenList enabledcommands;
bool notifyuser;
- bool IsShunned(LocalUser* user)
+ bool IsShunned(LocalUser* user) const
{
// Exempt the user if they are not fully connected and allowconnect is enabled.
if (allowconnect && user->registered != REG_ALL)
diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp
index bd9e3138d..08533f5a8 100644
--- a/src/modules/m_spanningtree/capab.cpp
+++ b/src/modules/m_spanningtree/capab.cpp
@@ -201,7 +201,9 @@ namespace
return true;
bool okay;
- std::ostringstream diffconfig, localmissing, remotemissing;
+ std::ostringstream diffconfig;
+ std::ostringstream localmissing;
+ std::ostringstream remotemissing;
if (protocol <= PROTO_INSPIRCD_3)
okay = CompareModulesOld(property, *remote, diffconfig, localmissing, remotemissing);
else
@@ -418,7 +420,7 @@ void TreeSocket::ListDifference(const std::string &one, const std::string &two,
bool TreeSocket::Capab(const CommandBase::Params& params)
{
- if (params.size() < 1)
+ if (params.empty())
{
this->SendError("Invalid number of parameters for CAPAB - Mismatched version");
return false;
@@ -471,7 +473,8 @@ bool TreeSocket::Capab(const CommandBase::Params& params)
{
if (capab->ChanModes != BuildModeList(MODETYPE_CHANNEL))
{
- std::string diffIneed, diffUneed;
+ std::string diffIneed;
+ std::string diffUneed;
ListDifference(capab->ChanModes, BuildModeList(MODETYPE_CHANNEL), ' ', diffIneed, diffUneed);
if (diffIneed.length() || diffUneed.length())
{
@@ -489,7 +492,8 @@ bool TreeSocket::Capab(const CommandBase::Params& params)
{
if (capab->UserModes != BuildModeList(MODETYPE_USER))
{
- std::string diffIneed, diffUneed;
+ std::string diffIneed;
+ std::string diffUneed;
ListDifference(capab->UserModes, BuildModeList(MODETYPE_USER), ' ', diffIneed, diffUneed);
if (diffIneed.length() || diffUneed.length())
{
diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h
index cf3e1590d..8e8e31f94 100644
--- a/src/modules/m_spanningtree/commands.h
+++ b/src/modules/m_spanningtree/commands.h
@@ -161,7 +161,7 @@ class CommandFJoin final
* @param newname The new name of the channel; must be the same or a case change of the current name
*/
static void LowerTS(Channel* chan, time_t TS, const std::string& newname);
- void ProcessModeUUIDPair(const std::string& item, TreeServer* sourceserver, Channel* chan, Modes::ChangeList* modechangelist, FwdFJoinBuilder& fwdfjoin);
+ static void ProcessModeUUIDPair(const std::string& item, TreeServer* sourceserver, Channel* chan, Modes::ChangeList* modechangelist, FwdFJoinBuilder& fwdfjoin);
public:
CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
CmdResult Handle(User* user, Params& params) override;
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp
index 7e3c6fcd5..3e0e654f6 100644
--- a/src/modules/m_spanningtree/compat.cpp
+++ b/src/modules/m_spanningtree/compat.cpp
@@ -60,5 +60,4 @@ void TreeSocket::WriteLine(const std::string& original_line)
}
WriteLineInternal(line);
- return;
}
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index abbb21efd..4b14352b9 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -146,11 +146,11 @@ public:
/** Handle SQUIT
*/
- ModResult HandleSquit(const CommandBase::Params& parameters, User* user);
+ static ModResult HandleSquit(const CommandBase::Params& parameters, User* user);
/** Handle remote WHOIS
*/
- ModResult HandleRemoteWhois(const CommandBase::Params& parameters, User* user);
+ static ModResult HandleRemoteWhois(const CommandBase::Params& parameters, User* user);
/** Connect a server locally
*/
@@ -166,11 +166,11 @@ public:
/** Check if any connecting servers should timeout
*/
- void DoConnectTimeout(time_t curtime);
+ static void DoConnectTimeout(time_t curtime);
/** Handle remote VERSION
*/
- ModResult HandleVersion(const CommandBase::Params& parameters, User* user);
+ static ModResult HandleVersion(const CommandBase::Params& parameters, User* user);
/** Handle CONNECT
*/
diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp
index b686b4c69..0abd3634c 100644
--- a/src/modules/m_spanningtree/override_map.cpp
+++ b/src/modules/m_spanningtree/override_map.cpp
@@ -179,7 +179,7 @@ static std::vector<std::string> GetMap(User* user, TreeServer* current, size_t m
CmdResult CommandMap::Handle(User* user, const Params& parameters)
{
- if (parameters.size() > 0)
+ if (!parameters.empty())
{
// Remote MAP, the target server is the 1st parameter
TreeServer* s = Utils->FindServerMask(parameters[0]);
diff --git a/src/modules/m_spanningtree/ping.cpp b/src/modules/m_spanningtree/ping.cpp
index 0ed22845e..452cfde64 100644
--- a/src/modules/m_spanningtree/ping.cpp
+++ b/src/modules/m_spanningtree/ping.cpp
@@ -27,7 +27,6 @@
#include "utils.h"
#include "treeserver.h"
#include "commands.h"
-#include "utils.h"
CmdResult CommandPing::Handle(User* user, Params& params)
{
diff --git a/src/modules/m_spanningtree/pong.cpp b/src/modules/m_spanningtree/pong.cpp
index 342ca9a7a..fca5e3d85 100644
--- a/src/modules/m_spanningtree/pong.cpp
+++ b/src/modules/m_spanningtree/pong.cpp
@@ -27,7 +27,6 @@
#include "utils.h"
#include "treeserver.h"
#include "commands.h"
-#include "utils.h"
CmdResult CommandPong::HandleServer(TreeServer* server, CommandBase::Params& params)
{
diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp
index a37d0d52a..b9f745deb 100644
--- a/src/modules/m_spanningtree/precommand.cpp
+++ b/src/modules/m_spanningtree/precommand.cpp
@@ -52,7 +52,7 @@ ModResult ModuleSpanningTree::OnPreCommand(std::string &command, CommandBase::Pa
return this->HandleRemoteWhois(parameters,user);
}
}
- else if ((command == "VERSION") && (parameters.size() > 0))
+ else if ((command == "VERSION") && (!parameters.empty()))
{
return this->HandleVersion(parameters,user);
}
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index 535299e72..cddcd03b4 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -111,7 +111,7 @@ std::shared_ptr<Link> TreeSocket::AuthRemote(const CommandBase::Params& params)
this->SendCapabilities(2);
- if (!ServerInstance->IsSID(sid))
+ if (!InspIRCd::IsSID(sid))
{
this->SendError("Invalid format server ID: "+sid+"!");
return nullptr;
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index 85e5de440..914123bf5 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -232,7 +232,7 @@ public:
/** Construct a password, optionally hashed with the other side's
* challenge string
*/
- std::string MakePass(const std::string &password, const std::string &challenge);
+ static std::string MakePass(const std::string &password, const std::string &challenge);
/** When an outbound connection finishes connecting, we receive
* this event, and must send our SERVER string to the other
@@ -260,20 +260,20 @@ public:
/** Returns mode list as a string, filtered by type.
* @param type The type of modes to return.
*/
- std::string BuildModeList(ModeType type);
+ static std::string BuildModeList(ModeType type);
/** If the extban manager exists then build an extban list.
* @param out The buffer to put the extban list in.
* @return True if the extban manager exists; otherwise, false.
*/
- bool BuildExtBanList(std::string& out);
+ static bool BuildExtBanList(std::string& out);
/** Send my capabilities to the remote side
*/
void SendCapabilities(int phase);
/* Isolate and return the elements that are different between two lists */
- void ListDifference(const std::string &one, const std::string &two, char sep,
+ static void ListDifference(const std::string &one, const std::string &two, char sep,
std::string& mleft, std::string& mright);
bool Capab(const CommandBase::Params& params);
@@ -326,7 +326,7 @@ public:
void ProcessLine(std::string &line);
/** Process message tags received from a remote server. */
- void ProcessTag(User* source, const std::string& tag, ClientProtocol::TagMap& tags);
+ static void ProcessTag(User* source, const std::string& tag, ClientProtocol::TagMap& tags);
/** Process a message for a fully connected server. */
void ProcessConnectedLine(std::string& tags, std::string& prefix, std::string& command, CommandBase::Params& params);
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 602c0dde4..cacccf544 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -37,7 +37,7 @@
/* Handle ERROR command */
void TreeSocket::Error(CommandBase::Params& params)
{
- std::string msg = params.size() ? params[0] : "";
+ const std::string msg = params.empty() ? "" : params[0];
SetError("received ERROR " + msg);
}
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 1d90053b1..616b7c199 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -135,7 +135,7 @@ SpanningTreeUtilities::~SpanningTreeUtilities()
}
// Returns a list of DIRECT servers for a specific channel
-void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list)
+void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list) const
{
ModeHandler::Rank minrank = 0;
if (status)
@@ -175,7 +175,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet
}
}
-void SpanningTreeUtilities::DoOneToAllButSender(const CmdBuilder& params, TreeServer* omitroute)
+void SpanningTreeUtilities::DoOneToAllButSender(const CmdBuilder& params, TreeServer* omitroute) const
{
const std::string& FullLine = params.str();
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 074c1c993..dcf5b73c2 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -127,11 +127,11 @@ public:
/** Send a message from this server to one other local or remote
*/
- void DoOneToOne(const CmdBuilder& params, Server* target);
+ static void DoOneToOne(const CmdBuilder& params, Server* target);
/** Send a message from this server to all but one other, local or remote
*/
- void DoOneToAllButSender(const CmdBuilder& params, TreeServer* omit);
+ void DoOneToAllButSender(const CmdBuilder& params, TreeServer* omit) const;
/** Read the spanningtree module's tags from the config file
*/
@@ -139,11 +139,11 @@ public:
/** Handle nick collision
*/
- bool DoCollision(User* u, TreeServer* server, time_t remotets, const std::string& remoteident, const std::string& remoteip, const std::string& remoteuid, const char* collidecmd);
+ static bool DoCollision(User* u, TreeServer* server, time_t remotets, const std::string& remoteident, const std::string& remoteip, const std::string& remoteuid, const char* collidecmd);
/** Compile a list of servers which contain members of channel c
*/
- void GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list);
+ void GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list) const;
/** Find a server by name or SID
*/
@@ -175,9 +175,9 @@ public:
void SendChannelMessage(User* source, Channel* target, const std::string& text, char status, const ClientProtocol::TagMap& tags, const CUList& exempt_list, const char* message_type, TreeSocket* omit = nullptr);
// Builds link data to be sent to another server.
- std::string BuildLinkString(uint16_t protocol, Module* mod);
+ static std::string BuildLinkString(uint16_t protocol, Module* mod);
/** Send the channel list mode limits to either the specified server or all servers if nullptr. */
- void SendListLimits(Channel* chan, TreeSocket* sock = nullptr);
+ static void SendListLimits(Channel* chan, TreeSocket* sock = nullptr);
};
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp
index 7a4601289..511efe21f 100644
--- a/src/modules/m_sslinfo.cpp
+++ b/src/modules/m_sslinfo.cpp
@@ -278,7 +278,7 @@ private:
CommandSSLInfo cmd;
std::string hash;
- bool MatchFP(ssl_cert* const cert, const std::string& fp) const
+ static bool MatchFP(ssl_cert* const cert, const std::string& fp)
{
return irc::spacesepstream(fp).Contains(cert->GetFingerprint());
}
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index 469130fcb..287c83563 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -51,9 +51,7 @@ public:
bool Matches(User* u) override
{
- if (u->nick == nickname)
- return true;
- return false;
+ return u->nick == nickname;
}
bool Matches(const std::string& s) override
@@ -138,7 +136,7 @@ public:
user->WriteNotice("*** Invalid duration for SVSHOLD.");
return CmdResult::FAILURE;
}
- SVSHold* r = new SVSHold(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
+ SVSHold* r = new SVSHold(ServerInstance->Time(), duration, user->nick, parameters[2], parameters[0]);
if (ServerInstance->XLines->AddLine(r, user))
{
diff --git a/src/server.cpp b/src/server.cpp
index 95031b6ac..2a59bd5c6 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -70,10 +70,10 @@ void InspIRCd::QuickExit(int status)
void InspIRCd::Rehash(const std::string& uuid)
{
- if (!ServerInstance->ConfigThread)
+ if (!ConfigThread)
{
- ServerInstance->ConfigThread = new ConfigReaderThread(uuid);
- ServerInstance->ConfigThread->Start();
+ ConfigThread = new ConfigReaderThread(uuid);
+ ConfigThread->Start();
}
}
diff --git a/src/socketengines/epoll.cpp b/src/socketengines/epoll.cpp
index 0f7da7edf..cb1a4f2bb 100644
--- a/src/socketengines/epoll.cpp
+++ b/src/socketengines/epoll.cpp
@@ -161,7 +161,7 @@ void SocketEngine::DelFd(EventHandler* eh)
int SocketEngine::DispatchEvents()
{
- int i = epoll_wait(EngineHandle, &events[0], static_cast<int>(events.size()), 1000);
+ int i = epoll_wait(EngineHandle, events.data(), static_cast<int>(events.size()), 1000);
ServerInstance->UpdateTime();
stats.TotalEvents += i;
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 689caa7b6..0ab67b707 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -349,7 +349,7 @@ const UserManager::CloneCounts& UserManager::GetCloneCounts(User* user) const
return zeroclonecounts;
}
-void UserManager::ServerNoticeAll(const char* text, ...)
+void UserManager::ServerNoticeAll(const char* text, ...) const
{
std::string message;
VAFORMAT(message, text, text);
diff --git a/src/users.cpp b/src/users.cpp
index 8828994d0..eba46f4c4 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -714,7 +714,7 @@ const std::string& User::GetRealName() const
return realname;
}
-irc::sockets::cidr_mask User::GetCIDRMask()
+irc::sockets::cidr_mask User::GetCIDRMask() const
{
unsigned char range = 0;
switch (client_sa.family())
diff --git a/src/xline.cpp b/src/xline.cpp
index d4b7ab5b9..618e3858c 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -586,7 +586,7 @@ bool KLine::Matches(User *u)
void KLine::Apply(User* u)
{
- DefaultApply(u, "K", (this->identmask == "*") ? true : false);
+ DefaultApply(u, "K", this->identmask == "*");
}
bool GLine::Matches(User *u)
@@ -609,7 +609,7 @@ bool GLine::Matches(User *u)
void GLine::Apply(User* u)
{
- DefaultApply(u, "G", (this->identmask == "*") ? true : false);
+ DefaultApply(u, "G", this->identmask == "*");
}
bool ELine::Matches(User *u)
@@ -632,10 +632,7 @@ bool ZLine::Matches(User *u)
if (lu && lu->exempt)
return false;
- if (InspIRCd::MatchCIDR(u->GetIPString(), this->ipaddr))
- return true;
- else
- return false;
+ return InspIRCd::MatchCIDR(u->GetIPString(), this->ipaddr);
}
void ZLine::Apply(User* u)
@@ -645,10 +642,7 @@ void ZLine::Apply(User* u)
bool QLine::Matches(User *u)
{
- if (InspIRCd::Match(u->nick, this->nick))
- return true;
-
- return false;
+ return InspIRCd::Match(u->nick, this->nick);
}
void QLine::Apply(User* u)
@@ -660,33 +654,27 @@ void QLine::Apply(User* u)
bool ZLine::Matches(const std::string &str)
{
- if (InspIRCd::MatchCIDR(str, this->ipaddr))
- return true;
- else
- return false;
+ return InspIRCd::MatchCIDR(str, this->ipaddr);
}
bool QLine::Matches(const std::string &str)
{
- if (InspIRCd::Match(str, this->nick))
- return true;
-
- return false;
+ return InspIRCd::Match(str, this->nick);
}
bool ELine::Matches(const std::string &str)
{
- return (InspIRCd::MatchCIDR(str, matchtext));
+ return InspIRCd::MatchCIDR(str, matchtext);
}
bool KLine::Matches(const std::string &str)
{
- return (InspIRCd::MatchCIDR(str.c_str(), matchtext));
+ return InspIRCd::MatchCIDR(str, matchtext);
}
bool GLine::Matches(const std::string &str)
{
- return (InspIRCd::MatchCIDR(str, matchtext));
+ return InspIRCd::MatchCIDR(str, matchtext);
}
void ELine::OnAdd()