aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-10-22 20:45:22 +0100
committerGravatar Sadie Powell2022-10-23 14:51:33 +0100
commit859088dac5b937208c7aff7fd3976bbc63329281 (patch)
tree79b297813d7f2cb13e6967486340912ad72d0477
parentAvoid spamming opers with notices when a SQL log provider is down. (diff)
More const correctness.
-rw-r--r--include/channels.h11
-rw-r--r--include/modules.h4
-rw-r--r--include/modules/sql.h2
-rw-r--r--include/users.h10
-rw-r--r--src/channels.cpp2
-rw-r--r--src/configparser.cpp2
-rw-r--r--src/configreader.cpp8
-rw-r--r--src/inspsocket.cpp2
-rw-r--r--src/modulemanager.cpp2
-rw-r--r--src/modules.cpp8
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp2
-rw-r--r--src/modules/extra/m_ssl_mbedtls.cpp2
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp2
-rw-r--r--src/modules/m_cloaking.cpp2
-rw-r--r--src/modules/m_log_sql.cpp2
-rw-r--r--src/modules/m_opermotd.cpp2
-rw-r--r--src/modules/m_permchannels.cpp2
-rw-r--r--src/modules/m_showfile.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp2
-rw-r--r--src/modules/m_sqlauth.cpp2
-rw-r--r--src/modules/m_sqloper.cpp2
21 files changed, 37 insertions, 36 deletions
diff --git a/include/channels.h b/include/channels.h
index 9b88b7d15..cbc6ce911 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -115,15 +115,16 @@ public:
* @param mode The mode character to set or unset
* @param value True if you want to set the mode or false if you want to remove it
*/
- void SetMode(ModeHandler* mode, bool value);
+ void SetMode(const ModeHandler* mode, bool value);
+ void SetMode(const ModeHandler& mh, bool value) { SetMode(&mh, value); }
/** Returns true if a mode is set on a channel
* @param mode The mode character you wish to query
* @return True if the custom mode is set, false if otherwise
*/
- bool IsModeSet(ModeHandler* mode) { return ((mode->GetId() != ModeParser::MODEID_MAX) && (modes[mode->GetId()])); }
- bool IsModeSet(ModeHandler& mode) { return IsModeSet(&mode); }
- bool IsModeSet(ChanModeReference& mode);
+ bool IsModeSet(const ModeHandler* mode) { return ((mode->GetId() != ModeParser::MODEID_MAX) && (modes[mode->GetId()])); }
+ bool IsModeSet(const ModeHandler& mode) { return IsModeSet(&mode); }
+ bool IsModeSet(const ChanModeReference& mode);
/** Returns the parameter for a custom mode on a channel.
* @param mode The mode character you wish to query
@@ -310,7 +311,7 @@ inline std::string Channel::GetModeParameter(ParamModeBase* pm)
return out;
}
-inline bool Channel::IsModeSet(ChanModeReference& mode)
+inline bool Channel::IsModeSet(const ChanModeReference& mode)
{
if (!mode)
return false;
diff --git a/include/modules.h b/include/modules.h
index f9034578d..dfb3a70e5 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1059,7 +1059,7 @@ public:
* @param mod Module to attach events to
* @param sz The size of the implementation array
*/
- void Attach(Implementation* i, Module* mod, size_t sz);
+ void Attach(const Implementation* i, Module* mod, size_t sz);
/** Attach all events to a module (used on module load)
* @param mod Module to attach to all events
@@ -1082,7 +1082,7 @@ public:
* @param mod Module to detach events from
* @param sz The size of the implementation array
*/
- void Detach(Implementation* i, Module* mod, size_t sz);
+ void Detach(const Implementation* i, Module* mod, size_t sz);
/** Detach all events from a module (used on unload)
* @param mod Module to detach from
diff --git a/include/modules/sql.h b/include/modules/sql.h
index 2985d1009..2f7557fdd 100644
--- a/include/modules/sql.h
+++ b/include/modules/sql.h
@@ -183,7 +183,7 @@ public:
/** Called when an SQL error happens.
* @param error The error that occurred.
*/
- virtual void OnError(SQL::Error& error) = 0;
+ virtual void OnError(const SQL::Error& error) = 0;
/** Called when a SQL result is received.
* @param result The result of the SQL query.
diff --git a/include/users.h b/include/users.h
index f2c9f979a..08265f83f 100644
--- a/include/users.h
+++ b/include/users.h
@@ -403,14 +403,14 @@ public:
bool IsModeSet(unsigned char m) const;
bool IsModeSet(const ModeHandler* mh) const;
bool IsModeSet(const ModeHandler& mh) const { return IsModeSet(&mh); }
- bool IsModeSet(UserModeReference& moderef) const;
+ bool IsModeSet(const UserModeReference& moderef) const;
/** Set a specific usermode to on or off
* @param mh The user mode
* @param value On or off setting of the mode
*/
- void SetMode(ModeHandler* mh, bool value);
- void SetMode(ModeHandler& mh, bool value) { SetMode(&mh, value); }
+ void SetMode(const ModeHandler* mh, bool value);
+ void SetMode(const ModeHandler& mh, bool value) { SetMode(&mh, value); }
/** Returns true or false for if a user can execute a privileged oper command.
* This is done by looking up their oper type from User::oper, then referencing
@@ -805,14 +805,14 @@ inline bool User::IsModeSet(const ModeHandler* mh) const
return ((mh->GetId() != ModeParser::MODEID_MAX) && (modes[mh->GetId()]));
}
-inline bool User::IsModeSet(UserModeReference& moderef) const
+inline bool User::IsModeSet(const UserModeReference& moderef) const
{
if (!moderef)
return false;
return IsModeSet(*moderef);
}
-inline void User::SetMode(ModeHandler* mh, bool value)
+inline void User::SetMode(const ModeHandler* mh, bool value)
{
if (mh && mh->GetId() != ModeParser::MODEID_MAX)
modes[mh->GetId()] = value;
diff --git a/src/channels.cpp b/src/channels.cpp
index 21e648c9f..ce20a689d 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -49,7 +49,7 @@ Channel::Channel(const std::string& cname, time_t ts)
throw CoreException("Cannot create duplicate channel " + cname);
}
-void Channel::SetMode(ModeHandler* mh, bool on)
+void Channel::SetMode(const ModeHandler* mh, bool on)
{
if (mh && mh->GetId() != ModeParser::MODEID_MAX)
modes[mh->GetId()] = on;
diff --git a/src/configparser.cpp b/src/configparser.cpp
index 8afc20856..cbbfdc755 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -316,7 +316,7 @@ struct Parser final
}
}
}
- catch (CoreException& err)
+ catch (const CoreException& err)
{
stack.errstr << err.GetReason() << " at " << current.str();
if (tag)
diff --git a/src/configreader.cpp b/src/configreader.cpp
index ca4d77b6b..d91f5a389 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -360,7 +360,7 @@ void ServerConfig::Read()
{
valid = stack.ParseFile(ServerInstance->ConfigFileName, 0);
}
- catch (CoreException& err)
+ catch (const CoreException& err)
{
valid = false;
errstr << err.GetReason() << std::endl;
@@ -411,7 +411,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string& useruid)
CrossCheckOperClassType();
CrossCheckConnectBlocks(old);
}
- catch (CoreException& ce)
+ catch (const CoreException& ce)
{
errstr << ce.GetReason() << std::endl;
}
@@ -664,7 +664,7 @@ void ConfigReaderThread::OnStop()
ServerInstance->Logs.Debug("MODULE", "Rehashing " + modname);
mod->ReadConfig(status);
}
- catch (CoreException& modex)
+ catch (const CoreException& modex)
{
ServerInstance->Logs.Normal("MODULE", "Exception caught: " + modex.GetReason());
if (user)
@@ -680,7 +680,7 @@ void ConfigReaderThread::OnStop()
ServerInstance->Logs.CloseLogs();
ServerInstance->Logs.OpenLogs(true);
}
- catch (CoreException& ex)
+ catch (const CoreException& ex)
{
ServerInstance->Logs.Normal("LOG", "Cannot open log files: " + ex.GetReason());
if (user)
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index b3b3bffdf..abbdbebb3 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -464,7 +464,7 @@ void StreamSocket::OnEventHandlerRead()
{
DoRead();
}
- catch (CoreException& ex)
+ catch (const CoreException& ex)
{
ServerInstance->Logs.Normal("SOCKET", "Caught exception in socket processing on FD %d - '%s'",
GetFd(), ex.GetReason().c_str());
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 2e210ba7f..0281541b0 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -102,7 +102,7 @@ bool ModuleManager::Load(const std::string& modname, bool defer)
return false;
}
}
- catch (CoreException& modexcept)
+ catch (const CoreException& modexcept)
{
this->NewServices = nullptr;
diff --git a/src/modules.cpp b/src/modules.cpp
index 308bbac0e..f30a980d8 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -213,13 +213,13 @@ bool ModuleManager::Detach(Implementation i, Module* mod)
return stdalgo::erase(EventHandlers[i], mod);
}
-void ModuleManager::Attach(Implementation* i, Module* mod, size_t sz)
+void ModuleManager::Attach(const Implementation* i, Module* mod, size_t sz)
{
for (size_t n = 0; n < sz; ++n)
Attach(i[n], mod);
}
-void ModuleManager::Detach(Implementation* i, Module* mod, size_t sz)
+void ModuleManager::Detach(const Implementation* i, Module* mod, size_t sz)
{
for (size_t n = 0; n < sz; ++n)
Detach(i[n], mod);
@@ -534,7 +534,7 @@ void ModuleManager::LoadAll()
AddServices(servicemap[modname]);
mod->init();
}
- catch (CoreException& modexcept)
+ catch (const CoreException& modexcept)
{
LastModuleError = "Unable to initialize " + modname + ": " + modexcept.GetReason();
ServerInstance->Logs.Normal("MODULE", LastModuleError);
@@ -556,7 +556,7 @@ void ModuleManager::LoadAll()
ServerInstance->Logs.Debug("MODULE", "Reading configuration for %s", modname.c_str());
mod->ReadConfig(confstatus);
}
- catch (CoreException& modexcept)
+ catch (const CoreException& modexcept)
{
LastModuleError = "Unable to read the configuration for " + modname + ": " + modexcept.GetReason();
ServerInstance->Logs.Normal("MODULE", LastModuleError);
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 1c148b36c..fcd58c6cc 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -1091,7 +1091,7 @@ class ModuleSSLGnuTLS final
GnuTLS::Profile::Config profileconfig(name, tag);
prov = std::make_shared<GnuTLSIOHookProvider>(this, profileconfig);
}
- catch (CoreException& ex)
+ catch (const CoreException& ex)
{
throw ModuleException(this, "Error while initializing TLS profile \"" + name + "\" at " + tag->source.str() + " - " + ex.GetReason());
}
diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp
index be395b2be..ee9609cc7 100644
--- a/src/modules/extra/m_ssl_mbedtls.cpp
+++ b/src/modules/extra/m_ssl_mbedtls.cpp
@@ -919,7 +919,7 @@ private:
mbedTLS::Profile::Config profileconfig(name, tag, ctr_drbg);
prov = std::make_shared<mbedTLSIOHookProvider>(this, profileconfig);
}
- catch (CoreException& ex)
+ catch (const CoreException& ex)
{
throw ModuleException(this, "Error while initializing TLS profile \"" + name + "\" at " + tag->source.str() + " - " + ex.GetReason());
}
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 7b73ee435..a38813f26 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -958,7 +958,7 @@ class ModuleSSLOpenSSL final
{
prov = std::make_shared<OpenSSLIOHookProvider>(this, name, tag);
}
- catch (CoreException& ex)
+ catch (const CoreException& ex)
{
throw ModuleException(this, "Error while initializing TLS profile \"" + name + "\" at " + tag->source.str() + " - " + ex.GetReason());
}
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index c8766478f..5d35173d1 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -165,7 +165,7 @@ public:
creator->OnUserConnect(user);
cloaks = ext.Get(user);
}
- catch (CoreException& modexcept)
+ catch (const CoreException& modexcept)
{
ServerInstance->Logs.Normal(MODNAME, "Exception caught when generating cloak: " + modexcept.GetReason());
return MODEACTION_DENY;
diff --git a/src/modules/m_log_sql.cpp b/src/modules/m_log_sql.cpp
index 4ace5ad3a..034062dc1 100644
--- a/src/modules/m_log_sql.cpp
+++ b/src/modules/m_log_sql.cpp
@@ -39,7 +39,7 @@ public:
// Nothing to do here.
}
- void OnError(SQL::Error& error) override
+ void OnError(const SQL::Error& error) override
{
ServerInstance->SNO.WriteGlobalSno('a', "Unable to write to SQL log (query error: %s).", error.ToString());
}
diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp
index b50b94b45..208496eae 100644
--- a/src/modules/m_opermotd.cpp
+++ b/src/modules/m_opermotd.cpp
@@ -111,7 +111,7 @@ public:
cmd.opermotd = reader.GetVector();
InspIRCd::ProcessColors(cmd.opermotd);
}
- catch (CoreException&)
+ catch (const CoreException&)
{
// Nothing happens here as we do the error handling in ShowOperMOTD.
}
diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp
index 3cb35e514..e1daac763 100644
--- a/src/modules/m_permchannels.cpp
+++ b/src/modules/m_permchannels.cpp
@@ -311,7 +311,7 @@ public:
{
LoadDatabase();
}
- catch (CoreException& e)
+ catch (const CoreException& e)
{
ServerInstance->Logs.Normal(MODNAME, "Error loading permchannels database: " + std::string(e.GetReason()));
}
diff --git a/src/modules/m_showfile.cpp b/src/modules/m_showfile.cpp
index 456dfe50c..d50a327d5 100644
--- a/src/modules/m_showfile.cpp
+++ b/src/modules/m_showfile.cpp
@@ -158,7 +158,7 @@ public:
{
ReadTag(tag, newcmds);
}
- catch (CoreException& ex)
+ catch (const CoreException& ex)
{
ServerInstance->Logs.Normal(MODNAME, "Error: " + ex.GetReason() + " at " + tag->source.str());
}
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index af97b28ed..80f30411d 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -217,7 +217,7 @@ void TreeSocket::OnDataReady()
{
ProcessLine(line);
}
- catch (CoreException& ex)
+ catch (const CoreException& ex)
{
ServerInstance->Logs.Normal(MODNAME, "Error while processing: " + line);
ServerInstance->Logs.Normal(MODNAME, ex.GetReason());
diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp
index ae7b31f1c..d3a4cbbe7 100644
--- a/src/modules/m_sqlauth.cpp
+++ b/src/modules/m_sqlauth.cpp
@@ -109,7 +109,7 @@ public:
}
}
- void OnError(SQL::Error& error) override
+ void OnError(const SQL::Error& error) override
{
auto user = ServerInstance->Users.Find(uid);
if (!user)
diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp
index 453654c9e..6323d1ef2 100644
--- a/src/modules/m_sqloper.cpp
+++ b/src/modules/m_sqloper.cpp
@@ -112,7 +112,7 @@ public:
}
}
- void OnError(SQL::Error& error) override
+ void OnError(const SQL::Error& error) override
{
ServerInstance->Logs.Normal(MODNAME, "query failed (%s)", error.ToString());
ServerInstance->SNO.WriteGlobalSno('a', "m_sqloper: Failed to update blocks from database");