Fix a ton of pedantic compiler warnings.

This commit is contained in:
Sadie Powell 2021-04-04 23:42:15 +01:00
parent 131e570621
commit 7d84e4900f
96 changed files with 247 additions and 301 deletions

View File

@ -224,7 +224,6 @@ class CoreExport ServiceProvider : public Cullable
/** Type of service (must match object type) */
const ServiceType service;
ServiceProvider(Module* Creator, const std::string& Name, ServiceType Type);
virtual ~ServiceProvider() = default;
/** Retrieves a string that represents the type of this service. */
const char* GetTypeString() const;

View File

@ -358,7 +358,7 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource
void PushParam(const std::string& str) { params.emplace_back(0, str); }
/** Add a non-string parameter to the parameter list.
* @param arg1 Non-string to add, will be copied.
* @param param Non-string to add, will be copied.
*/
template<typename T>
void PushParam(T&& param)
@ -392,20 +392,20 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource
* @param index Index of the parameter to replace. Must be less than GetParams().size().
* @param str String to replace the parameter or placeholder with, will be copied.
*/
void ReplaceParam(unsigned int index, const char* str) { params[index] = Param(0, str); }
void ReplaceParam(size_t index, const char* str) { params[index] = Param(0, str); }
/** Replace a parameter or a placeholder that is already in the parameter list.
* @param index Index of the parameter to replace. Must be less than GetParams().size().
* @param str String to replace the parameter or placeholder with, will be copied.
*/
void ReplaceParam(unsigned int index, const std::string& str) { params[index] = Param(0, str); }
void ReplaceParam(size_t index, const std::string& str) { params[index] = Param(0, str); }
/** Replace a parameter or a placeholder that is already in the parameter list.
* @param index Index of the parameter to replace. Must be less than GetParams().size().
* @param str String to replace the parameter or placeholder with.
* The string will NOT be copied, it must remain alive until ClearParams() is called or until the object is destroyed.
*/
void ReplaceParamRef(unsigned int index, const std::string& str) { params[index] = Param(str); }
void ReplaceParamRef(size_t index, const std::string& str) { params[index] = Param(str); }
/** Add a tag.
* @param tagname Raw name of the tag to use in the protocol.

View File

@ -524,7 +524,7 @@ class CoreExport ConfigReaderThread : public Thread
{
}
~ConfigReaderThread()
~ConfigReaderThread() override
{
delete Config;
}

View File

@ -30,7 +30,7 @@ template<typename T> inline std::string ConvNumeric(const T& in)
std::string out;
while (quotient)
{
out += "0123456789"[std::abs((long)quotient % 10)];
out += "0123456789"[std::llabs(quotient % 10)];
quotient /= 10;
}
if (in < 0)
@ -105,7 +105,7 @@ template<> inline char ConvToNum<char>(const std::string& in)
// We specialise ConvToNum for char to avoid istringstream treating
// the input as a character literal.
int16_t num = ConvToNum<int16_t>(in);
return num >= INT8_MIN && num <= INT8_MAX ? num : 0;
return num >= INT8_MIN && num <= INT8_MAX ? static_cast<char>(num) : 0;
}
template<> inline unsigned char ConvToNum<unsigned char>(const std::string& in)
@ -113,5 +113,5 @@ template<> inline unsigned char ConvToNum<unsigned char>(const std::string& in)
// We specialise ConvToNum for unsigned char to avoid istringstream
// treating the input as a character literal.
uint16_t num = ConvToNum<uint16_t>(in);
return num <= UINT8_MAX ? num : 0;
return num <= UINT8_MAX ? static_cast<unsigned char>(num) : 0;
}

View File

@ -51,9 +51,6 @@ class CoreExport ExtensionItem
*/
ExtensionItem(Module* owner, const std::string& key, ExtensibleType exttype);
/** Destroys an instance of the ExtensionItem class. */
virtual ~ExtensionItem() = default;
/** Sets an ExtensionItem using a value in the internal format.
* @param container A container the ExtensionItem should be set on.
* @param value A value in the internal format.
@ -157,7 +154,7 @@ class CoreExport Extensible
Extensible();
Cullable::Result Cull() override;
virtual ~Extensible();
~Extensible() override;
void UnhookExtensions(const std::vector<reference<ExtensionItem>>& toRemove);
/**
@ -205,9 +202,6 @@ class SimpleExtItem : public ExtensionItem
{
}
/** Destroys an instance of the SimpleExtItem class. */
virtual ~SimpleExtItem() = default;
inline T* Get(const Extensible* container) const
{
return static_cast<T*>(GetRaw(container));
@ -257,9 +251,6 @@ class CoreExport StringExtItem : public SimpleExtItem<std::string>
*/
StringExtItem(Module* owner, const std::string& key, ExtensibleType exttype, bool sync = false);
/** Destroys an instance of the StringExtItem class. */
virtual ~StringExtItem() = default;
/** @copydoc ExtensionItem::FromInternal */
void FromInternal(Extensible* container, const std::string& value) noexcept override;
@ -289,9 +280,6 @@ class CoreExport IntExtItem : public ExtensionItem
*/
IntExtItem(Module* owner, const std::string& key, ExtensibleType exttype, bool sync = false);
/** Destroys an instance of the IntExtItem class. */
virtual ~IntExtItem() = default;
/** @copydoc ExtensionItem::Delete */
void Delete(Extensible* container, void* item) override;
@ -343,9 +331,6 @@ class CoreExport BoolExtItem : public ExtensionItem
*/
BoolExtItem(Module* owner, const std::string& key, ExtensibleType exttype, bool sync = false);
/** Destroys an instance of the BoolExtItem class. */
virtual ~BoolExtItem() = default;
/** @copydoc ExtensionItem::Delete */
void Delete(Extensible* container, void* item) override;

View File

@ -36,7 +36,7 @@ class CoreExport FileLogStream : public LogStream
public:
FileLogStream(LogLevel loglevel, FileWriter *fw);
virtual ~FileLogStream();
~FileLogStream() override;
void OnLog(LogLevel loglevel, const std::string& type, const std::string& msg) override;
};

View File

@ -34,9 +34,9 @@ class CoreExport FilePosition
unsigned int column;
/** Initialises a new file position with the specified name, line, and column.
* @param name The name of the file that the position points to.
* @param line The line of the file that this position points to.
* @param column The column of the file that this position points to.
* @param Name The name of the file that the position points to.
* @param Line The line of the file that this position points to.
* @param Column The column of the file that this position points to.
*/
FilePosition(const std::string& Name, unsigned int Line, unsigned int Column);

View File

@ -390,6 +390,7 @@ class CoreExport InspIRCd
* @param status The exit code to give to the operating system
* (See the ExitStatus enum for valid values)
*/
[[noreturn]]
void Exit(int status);
/** Formats the input string with the specified arguments.

View File

@ -400,6 +400,8 @@ class CoreExport BufferedSocket : public StreamSocket
*/
BufferedSocket(int newfd);
~BufferedSocket() override;
/** Begin connection to the given address
* This will create a socket, register with socket engine, and start the asynchronous
* connection process. If an error is detected at this point (such as out of file descriptors),
@ -431,7 +433,6 @@ class CoreExport BufferedSocket : public StreamSocket
*/
virtual void OnTimeout();
virtual ~BufferedSocket();
protected:
void OnEventHandlerWrite() override;
BufferedSocketError BeginConnect(const irc::sockets::sockaddrs& dest, const irc::sockets::sockaddrs& bind, unsigned int timeout);

View File

@ -36,7 +36,7 @@
va_start(_vaList, last); \
ret.assign(InspIRCd::Format(_vaList, format)); \
va_end(_vaList); \
} while (false);
} while (false)
/** Compose a hex string from raw data.
* @param raw The raw data to compose hex from (can be NULL if rawsize is 0)

View File

@ -70,7 +70,7 @@ class CoreExport FileWriter
/** Close the log file and cancel any events.
*/
virtual ~FileWriter();
~FileWriter();
};
@ -104,11 +104,6 @@ class CoreExport LogStream : public Cullable
{
}
/* A LogStream's destructor should do whatever it needs to close any resources it was using (or indicate that it is no longer using a resource
* in the event that the resource is shared, see for example FileLogStream).
*/
virtual ~LogStream() = default;
/** Changes the loglevel for this LogStream on-the-fly.
* This is needed for -nofork. But other LogStreams could use it to change loglevels.
*/

View File

@ -175,7 +175,6 @@ class CoreExport ModeHandler : public ServiceProvider
*/
ModeHandler(Module* me, const std::string& name, char modeletter, ParamSpec params, ModeType type, Class mclass = MC_OTHER);
Cullable::Result Cull() override;
virtual ~ModeHandler() = default;
/** Register this object in the ModeParser
*/
@ -254,10 +253,8 @@ class CoreExport ModeHandler : public ServiceProvider
/**
* Called when a channel mode change access check for your mode occurs.
* @param source Contains the user setting the mode.
* @param channel contains the destination channel the modes are being set on.
* @param parameter The parameter for your mode. This is modifiable.
* @param adding This value is true when the mode is being set, or false when it is being unset.
* @return allow, deny, or passthru to check against the required level
* @param channel The destination channel the modes are being set on.
* @param change Information regarding the mode change.
*/
virtual ModResult AccessCheck(User* source, Channel* channel, Modes::Change& change);
@ -266,11 +263,7 @@ class CoreExport ModeHandler : public ServiceProvider
* @param source Contains the user setting the mode.
* @param dest For usermodes, contains the destination user the mode is being set on. For channelmodes, this is an undefined value.
* @param channel For channel modes, contains the destination channel the modes are being set on. For usermodes, this is an undefined value.
* @param parameter The parameter for your mode, if you indicated that your mode requires a parameter when being set or unset. Note that
* if you alter this value, the new value becomes the one displayed and send out to the network, also, if you set this to an empty string
* but you specified your mode REQUIRES a parameter, this is equivalent to returning MODEACTION_DENY and will prevent the mode from being
* displayed.
* @param adding This value is true when the mode is being set, or false when it is being unset.
* @param change Information regarding the mode change.
* @return MODEACTION_ALLOW to allow the mode, or MODEACTION_DENY to prevent the mode, also see the description of 'parameter'.
*/
virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change);
@ -299,7 +292,6 @@ class CoreExport ModeHandler : public ServiceProvider
*/
virtual void OnParameterInvalid(User* user, Channel* targetchannel, User* targetuser, const std::string& parameter);
/**
* If your mode is a listmode, this method will be called to display an empty list (just the end of list numeric)
* @param user The user issuing the command
@ -397,8 +389,7 @@ class CoreExport PrefixMode : public ModeHandler
* Called when a channel mode change access check for your mode occurs.
* @param source Contains the user setting the mode.
* @param channel contains the destination channel the modes are being set on.
* @param parameter The parameter for your mode. This is modifiable.
* @param adding This value is true when the mode is being set, or false when it is being unset.
* @param change Information regarding the mode change.
* @return allow, deny, or passthru to check against the required level
*/
ModResult AccessCheck(User* source, Channel* channel, Modes::Change& change) override;
@ -410,8 +401,7 @@ class CoreExport PrefixMode : public ModeHandler
* @param source Source of the mode change, an error message is sent to this user if the target is not found
* @param dest Unused
* @param channel The channel the mode change is happening on
* @param param The nickname or uuid of the target user
* @param adding True when the mode is being set, false when it is being unset
* @param change Information regarding the mode change.
* @return MODEACTION_ALLOW if the change happened, MODEACTION_DENY if no change happened
* The latter occurs either when the member cannot be found or when the member already has this prefix set
* (when setting) or doesn't have this prefix set (when unsetting).
@ -513,14 +503,16 @@ class CoreExport ModeWatcher : public Cullable
public:
ModuleRef creator;
/**
* The constructor initializes the mode and the mode type
*/
ModeWatcher(Module* creator, const std::string& modename, ModeType type);
/**
* The default destructor does nothing.
*/
virtual ~ModeWatcher();
~ModeWatcher() override;
/**
* Get the mode name being watched
@ -539,22 +531,20 @@ class CoreExport ModeWatcher : public Cullable
* @param source The sender of the mode
* @param dest The target user for the mode, if you are watching a user mode
* @param channel The target channel for the mode, if you are watching a channel mode
* @param parameter The parameter of the mode, if the mode is supposed to have a parameter.
* @param change Information regarding the mode change.
* If you alter the parameter you are given, the mode handler will see your atered version
* when it handles the mode.
* @param adding True if the mode is being added and false if it is being removed
* @return True to allow the mode change to go ahead, false to abort it. If you abort the
* change, the mode handler (and ModeWatcher::AfterMode()) will never see the mode change.
*/
virtual bool BeforeMode(User* source, User* dest, Channel* channel, Modes::Change& change);
/**
* After the mode character has been processed by the ModeHandler, this method will be called.
* @param source The sender of the mode
* @param dest The target user for the mode, if you are watching a user mode
* @param channel The target channel for the mode, if you are watching a channel mode
* @param parameter The parameter of the mode, if the mode is supposed to have a parameter.
* You cannot alter the parameter here, as the mode handler has already processed it.
* @param adding True if the mode is being added and false if it is being removed
* @param change Information regarding the mode change.
*/
virtual void AfterMode(User* source, User* dest, Channel* channel, const Modes::Change& change);
};

View File

@ -89,11 +89,7 @@ class Modes::ChangeList
items.insert(items.end(), first, last);
}
/** Add a new mode to be changed to this ChangeList
* @param mh Mode handler
* @param adding True if this mode is being set, false if removed
* @param param Mode parameter
*/
/** Add a new mode to be changed to this ChangeList. Parameters are forwarded to the Modes::Change constructor. */
template <typename... Args>
void push(Args&&... args)
{

View File

@ -145,7 +145,7 @@ class ModResult
ServerInstance->Logs.Log("MODULE", LOG_DEFAULT, "Exception caught: " + modexcept.GetReason()); \
} \
} \
} while (0);
} while (0)
/**
* Custom module result handling loop. This is a paired macro, and should only
@ -330,11 +330,6 @@ class CoreExport Module : public Cullable, public usecountbase
*/
Cullable::Result Cull() override;
/** Default destructor.
* destroys a module class
*/
virtual ~Module() = default;
/** Retrieves link compatibility data for this module.
* @param data The location to store link compatibility data.
*/
@ -844,10 +839,8 @@ class CoreExport Module : public Cullable, public usecountbase
* Return 1 from this function to block the mode character from being processed entirely.
* @param user The user who is sending the mode
* @param chan The channel the mode is being sent to (or NULL if a usermode)
* @param mh The mode handler for the mode being changed
* @param param The parameter for the mode or an empty string
* @param adding true of the mode is being added, false if it is being removed
* @return ACR_DENY to deny the mode, ACR_DEFAULT to do standard mode checking, and ACR_ALLOW
* @param change Information regarding the mode change.
* @return MOD_RES_DENY to deny the mode, MOD_RES_DEFAULT to do standard mode checking, and MOD_RES_ALLOW
* to skip all permission checking. Please note that for remote mode changes, your return value
* will be ignored!
*/

View File

@ -177,7 +177,7 @@ namespace Cap
Unregister();
}
~Capability()
~Capability() override
{
SetActive(false);
}

View File

@ -188,7 +188,7 @@ namespace DNS
{
}
virtual ~Request()
~Request() override
{
manager->RemoveRequest(this);
}

View File

@ -256,7 +256,7 @@ class ExtBan::EventListener
public:
/** Called when an extban is being checked.
* @param user The user which the extban is being checked against.
* @param channel The channel which the extban is set on.
* @param chan The channel which the extban is set on.
* @param extban The extban which is being checked against.
*/
virtual ModResult OnExtBanCheck(User* user, Channel* chan, ExtBan::Base* extban) = 0;

View File

@ -72,7 +72,7 @@ class Regex::Engine
virtual PatternPtr Create(const std::string& pattern, uint8_t options = Regex::OPT_NONE) = 0;
/** Compiles a regular expression from the human-writable form.
* @param The pattern to compile in the format /pattern/flags.
* @param pattern The pattern to compile in the format /pattern/flags.
* @return A shared pointer to an instance of the Regex::Pattern class.
*/
PatternPtr CreateHuman(const std::string& pattern);
@ -157,8 +157,8 @@ class Regex::Pattern
protected:
/** Initializes a new instance of the Pattern class.
* @param Pattern The pattern as a string.
* @param Options The options used when matching this pattern.
* @param pattern The pattern as a string.
* @param options The options used when matching this pattern.
*/
Pattern(const std::string& pattern, uint8_t options)
: optionflags(options)

View File

@ -50,8 +50,9 @@ class Numeric::Numeric
{
}
/** Add a parameter to the numeric. The parameter will be converted to a string first with ConvToStr().
* @param x Parameter to add
/** Add a parameter pack to the numeric.
* @param x1 The first element of the parameter pack.
* @param x2 The rest of the parameter pack.
*/
template <typename T1, typename... T2>
Numeric& push(const T1& x1, T2... x2)
@ -59,6 +60,9 @@ class Numeric::Numeric
return push(x1).push(std::forward<T2>(x2)...);
}
/** Add a parameter to the numeric. The parameter will be converted to a string first with ConvToStr().
* @param x The parameter to add to the numeric.
*/
template <typename T>
Numeric& push(const T& x)
{

View File

@ -83,21 +83,21 @@ class CoreExport ProtocolInterface
* @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
* @param data The string representation of the data
*/
virtual void SendMetaData(Channel* chan, const std::string& key, const std::string& data) { }
virtual void SendMetaData(const Channel* chan, const std::string& key, const std::string& data) { }
/** Send metadata for a user to other linked servers.
* @param user The user to send metadata for
* @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
* @param data The string representation of the data
*/
virtual void SendMetaData(User* user, const std::string& key, const std::string& data) { }
virtual void SendMetaData(const User* user, const std::string& key, const std::string& data) { }
/** Send metadata for a user to other linked servers.
* @param memb The membership to send metadata for
* @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
* @param data The string representation of the data
*/
virtual void SendMetaData(Membership* memb, const std::string& key, const std::string& data) { }
virtual void SendMetaData(const Membership* memb, const std::string& key, const std::string& data) { }
/** Send metadata related to the server to other linked servers.
* @param key The 'key' of the data

View File

@ -196,7 +196,7 @@ class CoreExport ListenSocket : public EventHandler
ListenSocket(std::shared_ptr<ConfigTag> tag, const irc::sockets::sockaddrs& bind_to);
/** Close the socket
*/
~ListenSocket();
~ListenSocket() override;
/** Handles new connections, called by the socket engine
*/

View File

@ -194,10 +194,6 @@ class CoreExport EventHandler : public Cullable
*/
EventHandler();
/** Destructor
*/
virtual ~EventHandler() = default;
/** Called by the socket engine in case of a read event
*/
virtual void OnEventHandlerRead() = 0;
@ -290,6 +286,7 @@ class CoreExport SocketEngine
static void LookupMaxFds();
/** Terminates the program when the socket engine fails to initialize. */
[[noreturn]]
static void InitError();
static void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);

View File

@ -40,7 +40,7 @@ class CoreExport Thread
virtual void OnStart() = 0;
/** Callback which is executed on the calling thread before this thread is stopped. */
virtual void OnStop() { };
virtual void OnStop() { }
/** Initialises an instance of the Thread class. */
Thread() = default;

View File

@ -48,7 +48,7 @@ class CoreExport SocketThread : public Thread
*/
void NotifyParent();
SocketThread();
virtual ~SocketThread();
~SocketThread() override;
/** Lock queue.
*/
void LockQueue()

View File

@ -97,7 +97,7 @@ class CoreExport UserManager
/** Number of unregistered users online right now.
* (Unregistered means before USER/NICK/dns)
*/
unsigned int unregistered_count;
size_t unregistered_count;
/** Perform background user events for all local users such as PING checks, registration timeouts,
* penalty management and recvq processing for users who have data in their recvq due to throttling.
@ -157,22 +157,22 @@ class CoreExport UserManager
/** Return a count of fully registered connections on the network
* @return The number of registered users on the network
*/
unsigned int RegisteredUserCount() { return this->clientlist.size() - this->UnregisteredUserCount() - this->ServiceCount(); }
size_t RegisteredUserCount() { return this->clientlist.size() - this->UnregisteredUserCount() - this->ServiceCount(); }
/** Return a count of local unregistered (before NICK/USER) users
* @return The number of local unregistered (unknown) connections
*/
unsigned int UnregisteredUserCount() const { return this->unregistered_count; }
size_t UnregisteredUserCount() const { return this->unregistered_count; }
/** Return a count of users on a services servers.
* @return The number of users on services servers.
*/
unsigned int ServiceCount() const { return this->all_services.size(); }
size_t ServiceCount() const { return this->all_services.size(); }
/** Return a count of local registered users
* @return The number of registered local users
*/
unsigned int LocalUserCount() const { return (this->local_users.size() - this->UnregisteredUserCount()); }
size_t LocalUserCount() const { return (this->local_users.size() - this->UnregisteredUserCount()); }
/** Get a hash map containing all users, keyed by their nickname
* @return A hash map mapping nicknames to User pointers
@ -203,7 +203,7 @@ class CoreExport UserManager
User* Find(const std::string& nickuuid);
/** Find a user by their nickname.
* @param The nickname of the user to find.
* @param nick The nickname of the user to find.
* @return If the user was found then a pointer to a User object; otherwise, nullptr.
*/
User* FindNick(const std::string& nick);

View File

@ -620,9 +620,6 @@ class CoreExport User : public Extensible
*/
void PurgeEmptyChannels();
/** Default destructor
*/
virtual ~User() = default;
Cullable::Result Cull() override;
/** @copydoc Serializable::Deserialize */

View File

@ -52,14 +52,14 @@ refcountbase::~refcountbase()
{
if (refcount && ServerInstance)
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "refcountbase::~ @%p with refcount %d",
(void*)this, refcount);
static_cast<void*>(this), refcount);
}
usecountbase::~usecountbase()
{
if (usecount && ServerInstance)
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "usecountbase::~ @%p with refcount %d",
(void*)this, usecount);
static_cast<void*>(this), usecount);
}
void ServiceProvider::RegisterService()

View File

@ -148,7 +148,7 @@ CmdResult CommandParser::CallHandler(const std::string& commandname, const Comma
case CmdAccess::SERVER: // Only servers can execute.
bOkay = IS_SERVER(user);
break;
};
}
}
else
{

View File

@ -103,5 +103,5 @@ CmdResult CommandTopic::HandleLocal(LocalUser* user, const Params& parameters)
void Topic::ShowTopic(LocalUser* user, Channel* chan)
{
user->WriteNumeric(RPL_TOPIC, chan->name, chan->topic);
user->WriteNumeric(RPL_TOPICTIME, chan->name, chan->setby, (unsigned long)chan->topicset);
user->WriteNumeric(RPL_TOPICTIME, chan->name, chan->setby, chan->topicset);
}

View File

@ -95,7 +95,8 @@ void Invite::APIImpl::Create(LocalUser* user, Channel* chan, time_t timeout)
// Expired, don't bother
return;
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Invite::APIImpl::Create(): user=%s chan=%s timeout=%lu", user->uuid.c_str(), chan->name.c_str(), (unsigned long)timeout);
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Invite::APIImpl::Create(): user=%s chan=%s timeout=%lu",
user->uuid.c_str(), chan->name.c_str(), static_cast<unsigned long>(timeout));
Invite* inv = Find(user, chan);
if (inv)
@ -104,7 +105,8 @@ void Invite::APIImpl::Create(LocalUser* user, Channel* chan, time_t timeout)
if (!inv->IsTimed())
return;
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Invite::APIImpl::Create(): changing expiration in %p", (void*) inv);
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Invite::APIImpl::Create(): changing expiration in %p",
static_cast<void*>(inv));
if (timeout == 0)
{
// Convert timed invite to non-expiring
@ -128,7 +130,8 @@ void Invite::APIImpl::Create(LocalUser* user, Channel* chan, time_t timeout)
userext.Get(user, true)->invites.push_front(inv);
chanext.Get(chan, true)->invites.push_front(inv);
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Invite::APIImpl::Create(): created new Invite %p", (void*) inv);
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Invite::APIImpl::Create(): created new Invite %p",
static_cast<void*>(inv));
}
}
@ -176,7 +179,7 @@ Invite::Invite::Invite(LocalUser* u, Channel* c)
Invite::Invite::~Invite()
{
delete expiretimer;
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Invite::~ %p", (void*) this);
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Invite::~ %p", static_cast<void*>(this));
}
void Invite::Invite::Serialize(bool human, bool show_chans, std::string& out)
@ -202,7 +205,7 @@ InviteExpireTimer::InviteExpireTimer(Invite::Invite* invite, time_t timeout)
bool InviteExpireTimer::Tick(time_t currtime)
{
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "InviteExpireTimer::Tick(): expired %p", (void*) inv);
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "InviteExpireTimer::Tick(): expired %p", static_cast<void*>(inv));
apiimpl->Destruct(inv);
return false;
}

View File

@ -398,7 +398,7 @@ class MyManager : public Manager, public Timer, public EventHandler
cachettl = rr.ttl;
}
cachettl = std::min(cachettl, (unsigned int)5*60);
cachettl = std::min<unsigned int>(cachettl, 5*60);
ResourceRecord& rr = r.answers.front();
// Set TTL to what we've determined to be the lowest
rr.ttl = cachettl;
@ -418,7 +418,7 @@ class MyManager : public Manager, public Timer, public EventHandler
ServerInstance->Timers.AddTimer(this);
}
~MyManager()
~MyManager() override
{
// Ensure Process() will fail for new requests
Close();
@ -557,7 +557,6 @@ class MyManager : public Manager, public Timer, public EventHandler
return "DNS lookups are disabled";
case ERROR_NONE:
case ERROR_UNKNOWN:
default:
return "Unknown error";
}
}

View File

@ -28,9 +28,9 @@
struct LusersCounters
{
unsigned int max_local;
unsigned int max_global;
unsigned int invisible = 0;
size_t max_local;
size_t max_global;
size_t invisible = 0;
LusersCounters(UserModeReference& invisiblemode)
: max_local(ServerInstance->Users.LocalUserCount())
@ -47,7 +47,7 @@ struct LusersCounters
inline void UpdateMaxUsers()
{
unsigned int current = ServerInstance->Users.LocalUserCount();
size_t current = ServerInstance->Users.LocalUserCount();
if (current > max_local)
max_local = current;
@ -80,11 +80,11 @@ class CommandLusers : public Command
*/
CmdResult CommandLusers::Handle(User* user, const Params& parameters)
{
unsigned int n_users = ServerInstance->Users.RegisteredUserCount();
size_t n_users = ServerInstance->Users.RegisteredUserCount();
ProtocolInterface::ServerList serverlist;
ServerInstance->PI->GetServerList(serverlist);
unsigned int n_serv = serverlist.size();
unsigned int n_local_servs = 0;
size_t n_serv = serverlist.size();
size_t n_local_servs = 0;
for (ProtocolInterface::ServerList::const_iterator i = serverlist.begin(); i != serverlist.end(); ++i)
{
if (i->parentname == ServerInstance->Config->ServerName)
@ -96,10 +96,10 @@ CmdResult CommandLusers::Handle(User* user, const Params& parameters)
counters.UpdateMaxUsers();
user->WriteNumeric(RPL_LUSERCLIENT, InspIRCd::Format("There are %d users and %d invisible on %d servers",
user->WriteNumeric(RPL_LUSERCLIENT, InspIRCd::Format("There are %zu users and %zu invisible on %zu servers",
n_users - counters.invisible, counters.invisible, n_serv));
unsigned int opercount = ServerInstance->Users.all_opers.size();
size_t opercount = ServerInstance->Users.all_opers.size();
if (opercount)
user->WriteNumeric(RPL_LUSEROP, opercount, "operator(s) online");
@ -107,19 +107,20 @@ CmdResult CommandLusers::Handle(User* user, const Params& parameters)
user->WriteNumeric(RPL_LUSERUNKNOWN, ServerInstance->Users.UnregisteredUserCount(), "unknown connections");
user->WriteNumeric(RPL_LUSERCHANNELS, ServerInstance->GetChans().size(), "channels formed");
user->WriteNumeric(RPL_LUSERME, InspIRCd::Format("I have %d clients and %d servers", ServerInstance->Users.LocalUserCount(), n_local_servs));
user->WriteNumeric(RPL_LOCALUSERS, InspIRCd::Format("Current local users: %d Max: %d", ServerInstance->Users.LocalUserCount(), counters.max_local));
user->WriteNumeric(RPL_GLOBALUSERS, InspIRCd::Format("Current global users: %d Max: %d", n_users, counters.max_global));
user->WriteNumeric(RPL_LUSERME, InspIRCd::Format("I have %zu clients and %zu servers", ServerInstance->Users.LocalUserCount(), n_local_servs));
user->WriteNumeric(RPL_LOCALUSERS, InspIRCd::Format("Current local users: %zu Max: %zu", ServerInstance->Users.LocalUserCount(), counters.max_local));
user->WriteNumeric(RPL_GLOBALUSERS, InspIRCd::Format("Current global users: %zu Max: %zu", n_users, counters.max_global));
return CmdResult::SUCCESS;
}
class InvisibleWatcher : public ModeWatcher
{
unsigned int& invisible;
size_t& invisible;
public:
InvisibleWatcher(Module* mod, unsigned int& Invisible)
: ModeWatcher(mod, "invisible", MODETYPE_USER), invisible(Invisible)
InvisibleWatcher(Module* mod, size_t& Invisible)
: ModeWatcher(mod, "invisible", MODETYPE_USER)
, invisible(Invisible)
{
}

View File

@ -248,7 +248,7 @@ void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* tar
modenum.push(targetchannel->name);
GetModeList(modenum, targetchannel, user);
user->WriteNumeric(modenum);
user->WriteNumeric(RPL_CHANNELCREATED, targetchannel->name, (unsigned long)targetchannel->age);
user->WriteNumeric(RPL_CHANNELCREATED, targetchannel->name, targetchannel->age);
}
else
{

View File

@ -62,12 +62,9 @@ CmdResult CommandDie::Handle(User* user, const Params& parameters)
{
if (irc::equals(parameters[0], ServerInstance->Config->ServerName))
{
{
std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating.";
const std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating.";
ServerInstance->Logs.Log(MODNAME, LOG_SPARSE, diebuf);
DieRestart::SendError(diebuf);
}
ServerInstance->Exit(EXIT_STATUS_DIE);
}
else
@ -76,5 +73,4 @@ CmdResult CommandDie::Handle(User* user, const Params& parameters)
ServerInstance->SNO.WriteGlobalSno('a', "Failed DIE command from %s.", user->GetFullRealHost().c_str());
return CmdResult::FAILURE;
}
return CmdResult::SUCCESS;
}

View File

@ -179,7 +179,7 @@ class DataKeeper
// Data saved for each user
struct UserData : public OwnedModesExts
{
static const size_t UNUSED_INDEX = (size_t)-1;
static const size_t UNUSED_INDEX = SIZE_MAX;
size_t serializerindex;
UserData(User* user, size_t serializeridx)
@ -520,7 +520,7 @@ void DataKeeper::Save(Module* currmod)
reloadevprov->Call(&ReloadModule::EventListener::OnReloadModuleSave, mod, this->moddata);
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Saved data about %lu users %lu chans %lu modules", (unsigned long)userdatalist.size(), (unsigned long)chandatalist.size(), (unsigned long)moddata.list.size());
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Saved data about %zu users %zu chans %zu modules", userdatalist.size(), chandatalist.size(), moddata.list.size());
}
void DataKeeper::VerifyServiceProvider(const ProviderInfo& service, const char* type)
@ -694,7 +694,7 @@ void DataKeeper::DoRestoreModules()
for (ReloadModule::CustomData::List::iterator i = moddata.list.begin(); i != moddata.list.end(); ++i)
{
ReloadModule::CustomData::Data& data = *i;
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Calling module data handler %p", (void*)data.handler);
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Calling module data handler %p", static_cast<void*>(data.handler));
data.handler->OnReloadModuleRestore(mod, data.data);
}
}

View File

@ -315,7 +315,7 @@ CmdResult CommandWhois::HandleLocal(LocalUser* user, const Params& parameters)
LocalUser* localuser = IS_LOCAL(dest);
if (localuser && (ServerInstance->Config->HideServer.empty() || parameters.size() > 1))
{
idle = labs((long)((localuser->idle_lastmsg)-ServerInstance->Time()));
idle = std::max<unsigned long>(localuser->idle_lastmsg - ServerInstance->Time(), 0);
signon = dest->signon;
}

View File

@ -35,7 +35,7 @@ Cullable::Cullable()
if (ServerInstance)
{
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "Cullable::+%s @%p",
typeid(*this).name(), (void*)this);
typeid(*this).name(), static_cast<void*>(this));
}
#endif
}
@ -46,7 +46,7 @@ Cullable::~Cullable()
if (ServerInstance)
{
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "Cullable::~%s @%p",
typeid(*this).name(), (void*)this);
typeid(*this).name(), static_cast<void*>(this));
}
#endif
}
@ -57,7 +57,7 @@ Cullable::Result Cullable::Cull()
if (ServerInstance)
{
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "Cullable::-%s @%p",
typeid(*this).name(), (void*)this);
typeid(*this).name(), static_cast<void*>(this));
}
#endif
return Result();
@ -88,9 +88,9 @@ void CullList::Apply()
{
#ifdef INSPIRCD_ENABLE_RTTI
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "Deleting %s @%p", typeid(*c).name(),
(void*)c);
static_cast<void*>(c));
#else
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "Deleting @%p", (void*)c);
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "Deleting @%p", static_cast<void*>(c));
#endif
c->Cull();
queue.push_back(c);
@ -98,7 +98,7 @@ void CullList::Apply()
else
{
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "WARNING: Object @%p culled twice!",
(void*)c);
static_cast<void*>(c));
}
}
list.clear();

View File

@ -55,7 +55,10 @@ Extensible::Extensible()
Extensible::~Extensible()
{
if ((!extensions.empty() || !culled) && ServerInstance)
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "Extensible destructor called without cull @%p", (void*)this);
{
ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "Extensible destructor called without cull @%p",
static_cast<void*>(this));
}
}
Cullable::Result Extensible::Cull()
@ -137,15 +140,15 @@ void ExtensionItem::Sync(const Extensible* container, void* item)
switch (type)
{
case ExtensionItem::EXT_CHANNEL:
ServerInstance->PI->SendMetaData((Channel*)container, name, networkstr);
ServerInstance->PI->SendMetaData(static_cast<const Channel*>(container), name, networkstr);
break;
case ExtensionItem::EXT_MEMBERSHIP:
ServerInstance->PI->SendMetaData((Membership*)container, name, networkstr);
ServerInstance->PI->SendMetaData(static_cast<const Membership*>(container), name, networkstr);
break;
case ExtensionItem::EXT_USER:
ServerInstance->PI->SendMetaData((User*)container, name, networkstr);
ServerInstance->PI->SendMetaData(static_cast<const User*>(container), name, networkstr);
break;
}
}

View File

@ -89,8 +89,8 @@ unsigned const char ascii_case_insensitive_map[256] = {
bool irc::equals(const std::string& s1, const std::string& s2)
{
const unsigned char* n1 = (const unsigned char*)s1.c_str();
const unsigned char* n2 = (const unsigned char*)s2.c_str();
const unsigned char* n1 = reinterpret_cast<const unsigned char*>(s1.c_str());
const unsigned char* n2 = reinterpret_cast<const unsigned char*>(s2.c_str());
for (; *n1 && *n2; n1++, n2++)
if (national_case_insensitive_map[*n1] != national_case_insensitive_map[*n2])
return false;
@ -111,7 +111,9 @@ size_t irc::find(const std::string& haystack, const std::string& needle)
bool found = true;
for (size_t npos = 0; npos < needle.length(); ++npos)
{
if (national_case_insensitive_map[(unsigned char)needle[npos]] != national_case_insensitive_map[(unsigned char)haystack[hpos + npos]])
unsigned char unpos = needle[npos];
unsigned char uhpos = haystack[hpos + npos];
if (national_case_insensitive_map[unpos] != national_case_insensitive_map[uhpos])
{
// Uh-oh, characters at the current haystack position don't match.
found = false;
@ -131,15 +133,14 @@ size_t irc::find(const std::string& haystack, const std::string& needle)
bool irc::insensitive_swo::operator()(const std::string& a, const std::string& b) const
{
const unsigned char* charmap = national_case_insensitive_map;
std::string::size_type asize = a.size();
std::string::size_type bsize = b.size();
std::string::size_type maxsize = std::min(asize, bsize);
for (std::string::size_type i = 0; i < maxsize; i++)
{
unsigned char A = charmap[(unsigned char)a[i]];
unsigned char B = charmap[(unsigned char)b[i]];
unsigned char A = national_case_insensitive_map[static_cast<unsigned char>(a[i])];
unsigned char B = national_case_insensitive_map[static_cast<unsigned char>(b[i])];
if (A > B)
return false;
else if (A < B)
@ -157,8 +158,8 @@ size_t irc::insensitive::operator()(const std::string &s) const
* This avoids a copy to use hash<const char*>
*/
size_t t = 0;
for (std::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */
t = 5 * t + national_case_insensitive_map[(unsigned char)*x];
for (const auto& c : s)
t = 5 * t + national_case_insensitive_map[static_cast<unsigned char>(c)];
return t;
}

View File

@ -501,7 +501,7 @@ std::string InspIRCd::GenRandomStr(unsigned int length, bool printable)
unsigned long InspIRCd::GenRandomInt(unsigned long max)
{
unsigned long rv;
GenRandom((char*)&rv, sizeof(rv));
GenRandom(reinterpret_cast<char*>(&rv), sizeof(rv));
return rv % max;
}

View File

@ -65,6 +65,7 @@ unsigned const char* national_case_insensitive_map = ascii_case_insensitive_map;
namespace
{
[[noreturn]]
void VoidSignalHandler(int);
// Warns a user running as root that they probably shouldn't.
@ -309,7 +310,6 @@ namespace
<< con_bright << "Usage: " << con_reset << argv[0] << " [--config <file>] [--debug] [--nofork] [--nolog]" << std::endl
<< std::string(strlen(argv[0]) + 8, ' ') << "[--nopid] [--runasroot] [--version]" << std::endl;
ServerInstance->Exit(EXIT_STATUS_ARGV);
break;
}
}

View File

@ -294,7 +294,7 @@ void StreamSocket::FlushSendQ(SendQueue& sq)
rv = SocketEngine::WriteV(this, iovecs, bufcount);
}
if (rv == (int)sq.bytes())
if (rv == static_cast<int>(sq.bytes()))
{
// it's our lucky day, everything got written out. Fast cleanup.
// This won't ever happen if the number of buffers got capped.
@ -311,7 +311,7 @@ void StreamSocket::FlushSendQ(SendQueue& sq)
while (rv > 0 && !sq.empty())
{
const SendQueue::Element& front = sq.front();
if (front.length() <= (size_t)rv)
if (front.length() <= static_cast<size_t>(rv))
{
// this string got fully written out
rv -= front.length();
@ -518,7 +518,7 @@ void StreamSocket::AddIOHook(IOHook* newhook)
return;
}
IOHookMiddle* lasthook;
IOHookMiddle* lasthook = nullptr;
while (curr)
{
lasthook = IOHookMiddle::ToMiddleHook(curr);

View File

@ -50,7 +50,7 @@ std::string BinToBase64(const std::string& data_str, const char* table, char pad
table = b64table;
uint32_t buffer;
uint8_t* data = (uint8_t*)data_str.data();
const uint8_t* data = reinterpret_cast<const uint8_t*>(data_str.data());
std::string rv;
size_t i = 0;
while (i + 2 < data_str.length())

View File

@ -40,7 +40,7 @@ void ListModeBase::DisplayList(User* user, Channel* channel)
{
for (ModeList::const_iterator it = cd->list.begin(); it != cd->list.end(); ++it)
{
user->WriteNumeric(listnumeric, channel->name, it->mask, it->setter, (unsigned long) it->time);
user->WriteNumeric(listnumeric, channel->name, it->mask, it->setter, it->time);
}
}
user->WriteNumeric(endoflistnumeric, channel->name, endofliststring);

View File

@ -209,19 +209,19 @@ void ModuleManager::Attach(Implementation* i, Module* mod, size_t sz)
void ModuleManager::AttachAll(Module* mod)
{
for (size_t i = 0; i != I_END; ++i)
Attach((Implementation)i, mod);
Attach(static_cast<Implementation>(i), mod);
}
void ModuleManager::DetachAll(Module* mod)
{
for (size_t n = 0; n != I_END; ++n)
Detach((Implementation)n, mod);
Detach(static_cast<Implementation>(n), mod);
}
void ModuleManager::SetPriority(Module* mod, Priority s)
{
for (size_t n = 0; n != I_END; ++n)
SetPriority(mod, (Implementation)n, s);
SetPriority(mod, static_cast<Implementation>(n), s);
}
bool ModuleManager::SetPriority(Module* mod, Implementation i, Priority s, Module* which)
@ -608,7 +608,7 @@ void ModuleManager::DelService(ServiceProvider& item)
case SERVICE_MODE:
if (!ServerInstance->Modes.DelMode(static_cast<ModeHandler*>(&item)))
throw ModuleException("Mode "+std::string(item.name)+" does not exist.");
// Fall through
[[fallthrough]];
case SERVICE_DATA:
case SERVICE_IOHOOK:
{

View File

@ -156,7 +156,7 @@ class ModuleGeoMaxMind : public Module
memset(&geoapi.mmdb, 0, sizeof(geoapi.mmdb));
}
~ModuleGeoMaxMind()
~ModuleGeoMaxMind() override
{
MMDB_close(&geoapi.mmdb);
}

View File

@ -294,7 +294,7 @@ class LDAPService : public LDAPProvider, public SocketThread
Connect();
}
~LDAPService()
~LDAPService() override
{
this->LockQueue();
@ -623,7 +623,7 @@ class ModuleLDAP : public Module
{
}
~ModuleLDAP()
~ModuleLDAP() override
{
for (ServiceMap::iterator i = LDAPServices.begin(); i != LDAPServices.end(); ++i)
{

View File

@ -140,7 +140,7 @@ class ModuleSQL : public Module
void init() override;
ModuleSQL();
~ModuleSQL();
~ModuleSQL() override;
void ReadConfig(ConfigStatus& status) override;
void OnUnloadModule(Module* mod) override;
};
@ -305,7 +305,7 @@ class SQLConnection : public SQL::Provider
{
}
~SQLConnection()
~SQLConnection() override
{
mysql_close(connection);
}

View File

@ -207,7 +207,7 @@ class SQLConn : public SQL::Provider, public EventHandler
return this->EventHandler::Cull();
}
~SQLConn()
~SQLConn() override
{
SQL::Error err(SQL::BAD_DBID);
if (qinprog.c)
@ -532,7 +532,7 @@ class ModulePgSQL : public Module
{
}
~ModulePgSQL()
~ModulePgSQL() override
{
delete retimer;
ClearAllConnections();

View File

@ -63,7 +63,7 @@ class PCREPattern final
throw Regex::Exception(pattern, error, erroroffset);
}
~PCREPattern()
~PCREPattern() override
{
pcre_free(regex);
}

View File

@ -57,7 +57,7 @@ class POSIXPattern final
throw Regex::Exception(pattern, std::string(&errormsg[0], errormsg.size()));
}
~POSIXPattern()
~POSIXPattern() override
{
regfree(&regex);
}

View File

@ -64,7 +64,7 @@ class TREPattern final
throw Regex::Exception(pattern, std::string(&errormsg[0], errormsg.size()));
}
~TREPattern()
~TREPattern() override
{
regfree(&regex);
}

View File

@ -113,7 +113,7 @@ class SQLConn : public SQL::Provider
}
}
~SQLConn()
~SQLConn() override
{
if (conn)
{
@ -237,7 +237,7 @@ class ModuleSQLite3 : public Module
{
}
~ModuleSQLite3()
~ModuleSQLite3() override
{
ClearConns();
}

View File

@ -1086,7 +1086,7 @@ class GnuTLSIOHookProvider : public SSLIOHookProvider
ServerInstance->Modules.AddService(*this);
}
~GnuTLSIOHookProvider()
~GnuTLSIOHookProvider() override
{
ServerInstance->Modules.DelService(*this);
}
@ -1199,7 +1199,7 @@ class ModuleSSLGnuTLS : public Module
}
}
~ModuleSSLGnuTLS()
~ModuleSSLGnuTLS() override
{
ServerInstance->GenRandom = &InspIRCd::DefaultGenRandom;
}

View File

@ -818,7 +818,7 @@ class mbedTLSIOHookProvider : public SSLIOHookProvider
ServerInstance->Modules.AddService(*this);
}
~mbedTLSIOHookProvider()
~mbedTLSIOHookProvider() override
{
ServerInstance->Modules.DelService(*this);
}

View File

@ -869,7 +869,7 @@ class OpenSSLIOHookProvider : public SSLIOHookProvider
ServerInstance->Modules.AddService(*this);
}
~OpenSSLIOHookProvider()
~OpenSSLIOHookProvider() override
{
ServerInstance->Modules.DelService(*this);
}
@ -952,7 +952,7 @@ class ModuleSSLOpenSSL : public Module
biomethods = OpenSSL::BIOMethod::alloc();
}
~ModuleSSLOpenSSL()
~ModuleSSLOpenSSL() override
{
BIO_meth_free(biomethods);
}

View File

@ -36,7 +36,7 @@ class ModuleSSLRehashSignal : public Module
{
}
~ModuleSSLRehashSignal()
~ModuleSSLRehashSignal() override
{
signal(SIGUSR1, SIG_IGN);
}

View File

@ -142,10 +142,6 @@ class AntiCapsMode : public ParamMode<AntiCapsMode, SimpleExtItem<AntiCapsSettin
case ACM_KICK_BAN:
out.append("kickban");
break;
default:
out.append("unknown~");
out.append(ConvToStr(acs->method));
break;
}
out.push_back(':');
out.append(ConvToStr(acs->minlen));

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// $CompilerFlags: -Ivendor_directory("bcrypt")
/// $CompilerFlags: -isystem vendor_directory("bcrypt")
#include "inspircd.h"

View File

@ -423,7 +423,7 @@ public:
time_t now = ServerInstance->Time();
/* +g and *not* accepted */
user->WriteNumeric(ERR_TARGUMODEG, dest->nick, "is in +g mode (server-side ignore).");
if (now > (dat->lastnotify + (time_t)notify_cooldown))
if (now > (dat->lastnotify + notify_cooldown))
{
user->WriteNumeric(RPL_TARGNOTIFY, dest->nick, "has been informed that you messaged them.");
dest->WriteRemoteNumeric(RPL_UMODEGMSG, user->nick, InspIRCd::Format("%s@%s", user->ident.c_str(), user->GetDisplayedHost().c_str()), InspIRCd::Format("is messaging you, and you have user mode +g set. Use /ACCEPT +%s to allow.",

View File

@ -158,7 +158,7 @@ class Cap::ManagerImpl : public Cap::Manager, public ReloadModule::EventListener
managerimpl = this;
}
~ManagerImpl()
~ManagerImpl() override
{
for (CapMap::iterator i = caps.begin(); i != caps.end(); ++i)
{

View File

@ -180,7 +180,7 @@ class ModuleCBan : public Module, public Stats::EventListener
ServerInstance->XLines->RegisterFactory(&f);
}
~ModuleCBan()
~ModuleCBan() override
{
ServerInstance->XLines->DelAll("CBAN");
ServerInstance->XLines->UnregisterFactory(&f);

View File

@ -494,8 +494,8 @@ class ModuleCloaking : public Module
break;
}
case MODE_OPAQUE:
default:
chost = SegmentIP(info, ip, true);
break;
}
return chost;
}

View File

@ -124,7 +124,7 @@ class ModuleCodepage
{
}
~ModuleCodepage()
~ModuleCodepage() override
{
ServerInstance->IsNick = origisnick;
CheckInvalidNick();

View File

@ -103,7 +103,7 @@ class ModuleCustomPrefix : public Module
}
}
~ModuleCustomPrefix()
~ModuleCustomPrefix() override
{
stdalgo::delete_all(modes);
}

View File

@ -234,7 +234,6 @@ class DNSBLResolver : public DNS::Request
break;
}
case DNSBLConfEntry::I_UNKNOWN:
default:
break;
}

View File

@ -40,12 +40,12 @@ class ExemptChanOps : public ListModeBase
syntax = "<restriction>:<prefix>";
}
static PrefixMode* FindMode(const std::string& mode)
static PrefixMode* FindMode(const std::string& pmode)
{
if (mode.length() == 1)
return ServerInstance->Modes.FindPrefixMode(mode[0]);
if (pmode.length() == 1)
return ServerInstance->Modes.FindPrefixMode(pmode[0]);
ModeHandler* mh = ServerInstance->Modes.FindMode(mode, MODETYPE_CHANNEL);
ModeHandler* mh = ServerInstance->Modes.FindMode(pmode, MODETYPE_CHANNEL);
return mh ? mh->IsPrefixMode() : NULL;
}

View File

@ -128,7 +128,6 @@ class FilterResult
break;
default:
return *n;
break;
}
}
return 0;

View File

@ -86,7 +86,7 @@ class ModuleHideList : public Module
{
}
~ModuleHideList()
~ModuleHideList() override
{
stdalgo::delete_all(watchers);
}

View File

@ -26,7 +26,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// $CompilerFlags: -Ivendor_directory("http_parser")
/// $CompilerFlags: -isystem vendor_directory("http_parser")
#include "inspircd.h"
@ -225,7 +225,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
ServerInstance->Timers.AddTimer(this);
}
~HttpServerSocket()
~HttpServerSocket() override
{
sockets.erase(this);
}

View File

@ -320,17 +320,14 @@ namespace Stats
bool operator()(User* u1, User* u2)
{
switch (order) {
switch (order)
{
case OB_LASTMSG:
return Compare(IS_LOCAL(u1)->idle_lastmsg, IS_LOCAL(u2)->idle_lastmsg);
break;
case OB_NICK:
return Compare(u1->nick, u2->nick);
break;
default:
case OB_NONE:
return false;
break;
}
}
};

View File

@ -74,7 +74,7 @@ class STSCap : public Cap::Capability
DisableAutoRegister();
}
~STSCap()
~STSCap() override
{
// TODO: Send duration=0 when STS vanishes.
}

View File

@ -311,7 +311,7 @@ class ModuleNationalChars : public Module
}
}
~ModuleNationalChars()
~ModuleNationalChars() override
{
ServerInstance->IsNick = rememberer;
national_case_insensitive_map = lowermap_rememberer;

View File

@ -207,7 +207,7 @@ class ModulePBKDF2 : public Module
{
}
~ModulePBKDF2()
~ModulePBKDF2() override
{
stdalgo::delete_all(providers);
}

View File

@ -232,7 +232,7 @@ class ModuleRLine
ServerInstance->XLines->RegisterFactory(&f);
}
~ModuleRLine()
~ModuleRLine() override
{
ServerInstance->XLines->DelAll("R");
ServerInstance->XLines->UnregisterFactory(&f);

View File

@ -234,7 +234,8 @@ class SaslAuthenticator
case SASL_INIT:
this->agent = msg[0];
this->state = SASL_COMM;
/* fall through */
[[fallthrough]];
case SASL_COMM:
if (msg[0] != this->agent)
return this->state;
@ -261,13 +262,10 @@ class SaslAuthenticator
this->user->WriteNumeric(RPL_SASLMECHS, msg[3], "are available SASL mechanisms");
else
ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "Services sent an unknown SASL message \"%s\" \"%s\"", msg[2].c_str(), msg[3].c_str());
break;
break;
case SASL_DONE:
break;
default:
ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "WTF: SaslState is not a known state (%d)", this->state);
break;
}
return this->state;
@ -306,8 +304,6 @@ class SaslAuthenticator
case SASL_FAIL:
this->user->WriteNumeric(ERR_SASLFAIL, "SASL authentication failed");
break;
default:
break;
}
this->state_announced = true;

View File

@ -264,7 +264,6 @@ class ModuleServicesAccount
// User is messaging a +M channel and is not registered or exempt.
user->WriteNumeric(ERR_NEEDREGGEDNICK, targchan->name, "You need to be identified to a registered account to message this channel");
return MOD_RES_DENY;
break;
}
case MessageTarget::TYPE_USER:
{
@ -278,7 +277,6 @@ class ModuleServicesAccount
// User is messaging a +R user and is not registered or on an accept list.
user->WriteNumeric(ERR_NEEDREGGEDNICK, targuser->nick, "You need to be identified to a registered account to message this user");
return MOD_RES_DENY;
break;
}
case MessageTarget::TYPE_SERVER:
break;

View File

@ -23,7 +23,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// $CompilerFlags: -Ivendor_directory("sha2")
/// $CompilerFlags: -isystem vendor_directory("sha2")
#include "inspircd.h"
@ -43,7 +43,7 @@ class HashSHA2 : public HashProvider
std::string GenerateRaw(const std::string& data) override
{
std::vector<char> bytes(out_size);
SHA((unsigned char*)data.data(), data.size(), (unsigned char*)&bytes[0]);
SHA(reinterpret_cast<const unsigned char*>(data.data()), data.size(), reinterpret_cast<unsigned char*>(&bytes[0]));
return std::string(&bytes[0], bytes.size());
}
};

View File

@ -171,7 +171,7 @@ class ModuleShowFile : public Module
cmds.swap(newcmds);
}
~ModuleShowFile()
~ModuleShowFile() override
{
stdalgo::delete_all(cmds);
}

View File

@ -185,7 +185,7 @@ class ModuleShun : public Module, public Stats::EventListener
ServerInstance->XLines->RegisterFactory(&shun);
}
~ModuleShun()
~ModuleShun() override
{
ServerInstance->XLines->DelAll("SHUN");
ServerInstance->XLines->UnregisterFactory(&shun);

View File

@ -102,9 +102,9 @@ class CommandMetadata : public ServerCommand
class Builder : public CmdBuilder
{
public:
Builder(User* user, const std::string& key, const std::string& val);
Builder(Channel* chan, const std::string& key, const std::string& val);
Builder(Membership* memb, const std::string& key, const std::string& val);
Builder(const User* user, const std::string& key, const std::string& val);
Builder(const Channel* chan, const std::string& key, const std::string& val);
Builder(const Membership* memb, const std::string& key, const std::string& val);
Builder(const std::string& key, const std::string& val);
};
};

View File

@ -220,6 +220,6 @@ class ModuleSpanningTree
void OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags) override;
void OnShutdown(const std::string& reason) override;
Cullable::Result Cull() override;
~ModuleSpanningTree();
~ModuleSpanningTree() override;
void Prioritize() override;
};

View File

@ -110,7 +110,7 @@ CmdResult CommandMetadata::Handle(User* srcuser, Params& params)
return CmdResult::SUCCESS;
}
CommandMetadata::Builder::Builder(User* user, const std::string& key, const std::string& val)
CommandMetadata::Builder::Builder(const User* user, const std::string& key, const std::string& val)
: CmdBuilder("METADATA")
{
push(user->uuid);
@ -118,7 +118,7 @@ CommandMetadata::Builder::Builder(User* user, const std::string& key, const std:
push_last(val);
}
CommandMetadata::Builder::Builder(Channel* chan, const std::string& key, const std::string& val)
CommandMetadata::Builder::Builder(const Channel* chan, const std::string& key, const std::string& val)
: CmdBuilder("METADATA")
{
push(chan->name);
@ -127,7 +127,7 @@ CommandMetadata::Builder::Builder(Channel* chan, const std::string& key, const s
push_last(val);
}
CommandMetadata::Builder::Builder(Membership* memb, const std::string& key, const std::string& val)
CommandMetadata::Builder::Builder(const Membership* memb, const std::string& key, const std::string& val)
: CmdBuilder("METADATA")
{
push_raw("@");

View File

@ -87,17 +87,17 @@ void SpanningTreeProtocolInterface::BroadcastEncap(const std::string& cmd, const
CmdBuilder(source, "ENCAP * ").push_raw(cmd).insert(params).Forward(server);
}
void SpanningTreeProtocolInterface::SendMetaData(User* u, const std::string& key, const std::string& data)
void SpanningTreeProtocolInterface::SendMetaData(const User* u, const std::string& key, const std::string& data)
{
CommandMetadata::Builder(u, key, data).Broadcast();
}
void SpanningTreeProtocolInterface::SendMetaData(Channel* c, const std::string& key, const std::string& data)
void SpanningTreeProtocolInterface::SendMetaData(const Channel* c, const std::string& key, const std::string& data)
{
CommandMetadata::Builder(c, key, data).Broadcast();
}
void SpanningTreeProtocolInterface::SendMetaData(Membership* m, const std::string& key, const std::string& data)
void SpanningTreeProtocolInterface::SendMetaData(const Membership* m, const std::string& key, const std::string& data)
{
CommandMetadata::Builder(m, key, data).Broadcast();
}

View File

@ -37,9 +37,9 @@ class SpanningTreeProtocolInterface : public ProtocolInterface
bool SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const CommandBase::Params& params, User* source) override;
void BroadcastEncap(const std::string& cmd, const CommandBase::Params& params, User* source, User* omit) override;
void SendMetaData(User* user, const std::string& key, const std::string& data) override;
void SendMetaData(Channel* chan, const std::string& key, const std::string& data) override;
void SendMetaData(Membership* memb, const std::string& key, const std::string& data) override;
void SendMetaData(const User* user, const std::string& key, const std::string& data) override;
void SendMetaData(const Channel* chan, const std::string& key, const std::string& data) override;
void SendMetaData(const Membership* memb, const std::string& key, const std::string& data) override;
void SendMetaData(const std::string& key, const std::string& data) override;
void SendSNONotice(char snomask, const std::string& text) override;
void SendMessage(Channel* target, char status, const std::string& text, MessageType msgtype) override;

View File

@ -234,7 +234,7 @@ class TreeServer : public Server
/** Destructor, deletes ServerUser unless IsRoot()
*/
~TreeServer();
~TreeServer() override;
/** Returns the TreeServer the given user is connected to
* @param user The user whose server to return

View File

@ -123,7 +123,7 @@ class SpanningTreeUtilities : public Cullable
/** Destroy class and free listeners etc
*/
~SpanningTreeUtilities();
~SpanningTreeUtilities() override;
void RouteCommand(TreeServer* origin, CommandBase* cmd, const CommandBase::Params& parameters, User* user);

View File

@ -195,7 +195,7 @@ public:
GetOperBlocks();
}
~ModuleSQLOper()
~ModuleSQLOper() override
{
// Remove all oper blocks that were from the DB
for (std::vector<std::string>::const_iterator i = my_blocks.begin(); i != my_blocks.end(); ++i)

View File

@ -223,7 +223,7 @@ class ModuleSVSHold : public Module, public Stats::EventListener
return MOD_RES_PASSTHRU;
}
~ModuleSVSHold()
~ModuleSVSHold() override
{
ServerInstance->XLines->DelAll("SVSHOLD");
ServerInstance->XLines->UnregisterFactory(&s);

View File

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// $CompilerFlags: -Ivendor_directory("utfcpp")
/// $CompilerFlags: -isystem vendor_directory("utfcpp")
#include "inspircd.h"

View File

@ -147,6 +147,6 @@ std::string Snomask::GetDescription(char letter) const
if (!Description.empty())
ret += Description;
else
ret += std::string("SNO-") + (char)tolower(letter);
ret += InspIRCd::Format("SNO-%c", tolower(letter));
return ret;
}

View File

@ -236,13 +236,13 @@ std::string irc::sockets::sockaddrs::addr() const
{
case AF_INET:
char ip4addr[INET_ADDRSTRLEN];
if (!inet_ntop(AF_INET, (void*)&in4.sin_addr, ip4addr, sizeof(ip4addr)))
if (!inet_ntop(AF_INET, static_cast<const void*>(&in4.sin_addr), ip4addr, sizeof(ip4addr)))
return "0.0.0.0";
return ip4addr;
case AF_INET6:
char ip6addr[INET6_ADDRSTRLEN];
if (!inet_ntop(AF_INET6, (void*)&in6.sin6_addr, ip6addr, sizeof(ip6addr)))
if (!inet_ntop(AF_INET6, static_cast<const void*>(&in6.sin6_addr), ip6addr, sizeof(ip6addr)))
return "0:0:0:0:0:0:0:0";
return ip6addr;
@ -261,13 +261,13 @@ std::string irc::sockets::sockaddrs::str() const
{
case AF_INET:
char ip4addr[INET_ADDRSTRLEN];
if (!inet_ntop(AF_INET, (void*)&in4.sin_addr, ip4addr, sizeof(ip4addr)))
if (!inet_ntop(AF_INET, static_cast<const void*>(&in4.sin_addr), ip4addr, sizeof(ip4addr)))
strcpy(ip4addr, "0.0.0.0");
return InspIRCd::Format("%s:%u", ip4addr, ntohs(in4.sin_port));
case AF_INET6:
char ip6addr[INET6_ADDRSTRLEN];
if (!inet_ntop(AF_INET6, (void*)&in6.sin6_addr, ip6addr, sizeof(ip6addr)))
if (!inet_ntop(AF_INET6, static_cast<const void*>(&in6.sin6_addr), ip6addr, sizeof(ip6addr)))
strcpy(ip6addr, "0:0:0:0:0:0:0:0");
return InspIRCd::Format("[%s]:%u", ip6addr, ntohs(in6.sin6_port));
@ -340,13 +340,13 @@ static void sa2cidr(irc::sockets::cidr_mask& cidr, const irc::sockets::sockaddrs
case AF_INET:
cidr.length = range > 32 ? 32 : range;
target_byte = sizeof(sa.in4.sin_addr);
base = (unsigned char*)&sa.in4.sin_addr;
base = reinterpret_cast<const unsigned char*>(&sa.in4.sin_addr);
break;
case AF_INET6:
cidr.length = range > 128 ? 128 : range;
target_byte = sizeof(sa.in6.sin6_addr);
base = (unsigned char*)&sa.in6.sin6_addr;
base = reinterpret_cast<const unsigned char*>(&sa.in6.sin6_addr);
break;
default:
@ -402,12 +402,12 @@ std::string irc::sockets::cidr_mask::str() const
switch (type)
{
case AF_INET:
base = (unsigned char*)&sa.in4.sin_addr;
base = reinterpret_cast<unsigned char*>(&sa.in4.sin_addr);
len = 4;
break;
case AF_INET6:
base = (unsigned char*)&sa.in6.sin6_addr;
base = reinterpret_cast<unsigned char*>(&sa.in6.sin6_addr);
len = 16;
break;
@ -421,7 +421,7 @@ std::string irc::sockets::cidr_mask::str() const
}
memcpy(base, bits, len);
return sa.addr() + "/" + ConvToStr((int)length);
return sa.addr() + "/" + ConvToStr(length);
}
bool irc::sockets::cidr_mask::operator==(const cidr_mask& other) const

View File

@ -231,33 +231,33 @@ int SocketEngine::NonBlocking(int fd)
void SocketEngine::SetReuse(int fd)
{
int on = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on));
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, static_cast<void*>(&on), sizeof(on));
}
int SocketEngine::RecvFrom(EventHandler* fd, void *buf, size_t len, int flags, sockaddr *from, socklen_t *fromlen)
{
int nbRecvd = recvfrom(fd->GetFd(), (char*)buf, len, flags, from, fromlen);
int nbRecvd = recvfrom(fd->GetFd(), static_cast<char*>(buf), len, flags, from, fromlen);
stats.UpdateReadCounters(nbRecvd);
return nbRecvd;
}
int SocketEngine::Send(EventHandler* fd, const void *buf, size_t len, int flags)
{
int nbSent = send(fd->GetFd(), (const char*)buf, len, flags);
int nbSent = send(fd->GetFd(), static_cast<const char*>(buf), len, flags);
stats.UpdateWriteCounters(nbSent);
return nbSent;
}
int SocketEngine::Recv(EventHandler* fd, void *buf, size_t len, int flags)
{
int nbRecvd = recv(fd->GetFd(), (char*)buf, len, flags);
int nbRecvd = recv(fd->GetFd(), static_cast<char*>(buf), len, flags);
stats.UpdateReadCounters(nbRecvd);
return nbRecvd;
}
int SocketEngine::SendTo(EventHandler* fd, const void* buf, size_t len, int flags, const irc::sockets::sockaddrs& address)
{
int nbSent = sendto(fd->GetFd(), (const char*)buf, len, flags, &address.sa, address.sa_size());
int nbSent = sendto(fd->GetFd(), static_cast<const char*>(buf), len, flags, &address.sa, address.sa_size());
stats.UpdateWriteCounters(nbSent);
return nbSent;
}
@ -354,8 +354,8 @@ void SocketEngine::Statistics::CheckFlush() const
void SocketEngine::Statistics::GetBandwidth(float& kbitpersec_in, float& kbitpersec_out, float& kbitpersec_total) const
{
CheckFlush();
float in_kbit = indata * 8;
float out_kbit = outdata * 8;
float in_kbit = static_cast<float>(indata) * 8;
float out_kbit = static_cast<float>(outdata) * 8;
kbitpersec_total = ((in_kbit + out_kbit) / 1024);
kbitpersec_in = in_kbit / 1024;
kbitpersec_out = out_kbit / 1024;

View File

@ -35,7 +35,7 @@ class ThreadSignalSocket : public EventHandler
SocketEngine::AddFd(this, FD_WANT_FAST_READ | FD_WANT_NO_WRITE);
}
~ThreadSignalSocket()
~ThreadSignalSocket() override
{
SocketEngine::Close(this);
}

View File

@ -234,8 +234,8 @@ void UserIOHandler::OnDataReady()
if (recvq.length() > user->GetClass()->GetRecvqMax() && !user->HasPrivPermission("users/flood/increased-buffers"))
{
ServerInstance->Users.QuitUser(user, "RecvQ exceeded");
ServerInstance->SNO.WriteToSnoMask('a', "User %s RecvQ of %lu exceeds connect class maximum of %lu",
user->nick.c_str(), (unsigned long)recvq.length(), user->GetClass()->GetRecvqMax());
ServerInstance->SNO.WriteToSnoMask('a', "User %s RecvQ of %zu exceeds connect class maximum of %lu",
user->nick.c_str(), recvq.length(), user->GetClass()->GetRecvqMax());
return;
}
@ -796,7 +796,7 @@ void LocalUser::Write(const ClientProtocol::SerializedMessage& text)
if (nlpos == std::string::npos)
nlpos = text.length(); // TODO is this ok, test it
ServerInstance->Logs.Log("USEROUTPUT", LOG_RAWIO, "C[%s] O %.*s", uuid.c_str(), (int) nlpos, text.c_str());
ServerInstance->Logs.Log("USEROUTPUT", LOG_RAWIO, "C[%s] O %.*s", uuid.c_str(), static_cast<int>(nlpos), text.c_str());
}
eh.AddWriteBuf(text);

View File

@ -26,10 +26,10 @@
static bool MatchInternal(const unsigned char* str, const unsigned char* mask, unsigned const char* map)
{
unsigned char* cp = NULL;
unsigned char* mp = NULL;
unsigned char* string = (unsigned char*)str;
unsigned char* wild = (unsigned char*)mask;
const unsigned char* cp = nullptr;
const unsigned char* mp = nullptr;
const unsigned char* string = reinterpret_cast<const unsigned char*>(str);
const unsigned char* wild = reinterpret_cast<const unsigned char*>(mask);
while ((*string) && (*wild != '*'))
{
@ -81,7 +81,7 @@ bool InspIRCd::Match(const std::string& str, const std::string& mask, unsigned c
if (!map)
map = national_case_insensitive_map;
return MatchInternal((const unsigned char*)str.c_str(), (const unsigned char*)mask.c_str(), map);
return MatchInternal(reinterpret_cast<const unsigned char*>(str.c_str()), reinterpret_cast<const unsigned char*>(mask.c_str()), map);
}
bool InspIRCd::Match(const char* str, const char* mask, unsigned const char* map)
@ -89,7 +89,7 @@ bool InspIRCd::Match(const char* str, const char* mask, unsigned const char* map
if (!map)
map = national_case_insensitive_map;
return MatchInternal((const unsigned char*)str, (const unsigned char*)mask, map);
return MatchInternal(reinterpret_cast<const unsigned char*>(str), reinterpret_cast<const unsigned char*>(mask), map);
}
bool InspIRCd::MatchCIDR(const std::string& str, const std::string& mask, unsigned const char* map)