Normalise the case of MOD_RESULT variables.

This commit is contained in:
Sadie Powell 2024-08-31 16:21:09 +01:00
parent 0e603bab1d
commit f6da60b3f4
15 changed files with 70 additions and 70 deletions

View File

@ -184,9 +184,9 @@ Membership* Channel::JoinUser(LocalUser* user, std::string cname, bool override,
privs = ServerInstance->Config->DefaultModes.substr(0, ServerInstance->Config->DefaultModes.find(' '));
// Ask the modules whether they're ok with the join, pass NULL as Channel* as the channel is yet to be created
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, nullptr, cname, privs, key, override));
if (!override && MOD_RESULT == MOD_RES_DENY)
ModResult modres;
FIRST_MOD_RESULT(OnUserPreJoin, modres, (user, nullptr, cname, privs, key, override));
if (!override && modres == MOD_RES_DENY)
return nullptr; // A module wasn't happy with the join, abort
chan = new Channel(cname, ServerInstance->Time());
@ -199,12 +199,12 @@ Membership* Channel::JoinUser(LocalUser* user, std::string cname, bool override,
if (chan->HasUser(user))
return nullptr;
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, chan, cname, privs, key, override));
ModResult modres;
FIRST_MOD_RESULT(OnUserPreJoin, modres, (user, chan, cname, privs, key, override));
// A module explicitly denied the join and (hopefully) generated a message
// describing the situation, so we may stop here without sending anything
if (!override && MOD_RESULT == MOD_RES_DENY)
if (!override && modres == MOD_RES_DENY)
return nullptr;
}

View File

@ -183,9 +183,9 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman
if (!handler)
{
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, false));
if (MOD_RESULT == MOD_RES_DENY)
ModResult modres;
FIRST_MOD_RESULT(OnPreCommand, modres, (command, command_p, user, false));
if (modres == MOD_RES_DENY)
{
FOREACH_MOD(OnCommandBlocked, (command, command_p, user));
return;
@ -242,9 +242,9 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman
* We call OnPreCommand here separately if the command exists, so the magic above can
* truncate to max_params if necessary. -- w00t
*/
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, false));
if (MOD_RESULT == MOD_RES_DENY)
ModResult modres;
FIRST_MOD_RESULT(OnPreCommand, modres, (command, command_p, user, false));
if (modres == MOD_RES_DENY)
{
FOREACH_MOD(OnCommandBlocked, (command, command_p, user));
return;
@ -313,8 +313,8 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman
handler->use_count++;
/* module calls too */
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, command_p, user, true));
if (MOD_RESULT == MOD_RES_DENY)
FIRST_MOD_RESULT(OnPreCommand, modres, (command, command_p, user, true));
if (modres == MOD_RES_DENY)
{
FOREACH_MOD(OnCommandBlocked, (command, command_p, user));
return;

View File

@ -55,7 +55,7 @@ CommandInvite::CommandInvite(Module* parent, Invite::APIImpl& invapiimpl)
CmdResult CommandInvite::Handle(User* user, const Params& parameters)
{
ModResult MOD_RESULT;
ModResult modres;
if (parameters.size() >= 2)
{
@ -119,13 +119,13 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters)
return CmdResult::FAILURE;
}
FIRST_MOD_RESULT(OnUserPreInvite, MOD_RESULT, (user, u, c, timeout));
FIRST_MOD_RESULT(OnUserPreInvite, modres, (user, u, c, timeout));
if (MOD_RESULT == MOD_RES_DENY)
if (modres == MOD_RES_DENY)
{
return CmdResult::FAILURE;
}
else if (MOD_RESULT == MOD_RES_PASSTHRU)
else if (modres == MOD_RES_PASSTHRU)
{
if (IS_LOCAL(user))
{

View File

@ -94,8 +94,8 @@ CmdResult CommandTopic::HandleLocal(LocalUser* user, const Params& parameters)
}
if (c->IsModeSet(topiclockmode))
{
ModResult MOD_RESULT = exemptionprov.Check(user, c, "topiclock");
if (!MOD_RESULT.check(c->GetPrefixValue(user) >= HALFOP_VALUE))
ModResult modres = exemptionprov.Check(user, c, "topiclock");
if (!modres.check(c->GetPrefixValue(user) >= HALFOP_VALUE))
{
user->WriteNumeric(Numerics::ChannelPrivilegesNeeded(c, HALFOP_VALUE, "change the topic"));
return CmdResult::FAILURE;

View File

@ -275,9 +275,9 @@ public:
const std::string ckey = chan->GetModeParameter(&keymode);
if (!ckey.empty())
{
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnCheckKey, MOD_RESULT, (user, chan, keygiven));
if (!MOD_RESULT.check(InspIRCd::TimingSafeCompare(ckey, keygiven)))
ModResult modres;
FIRST_MOD_RESULT(OnCheckKey, modres, (user, chan, keygiven));
if (!modres.check(InspIRCd::TimingSafeCompare(ckey, keygiven)))
{
// If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled)
user->WriteNumeric(ERR_BADCHANNELKEY, chan->name, "Cannot join channel (incorrect channel key)");
@ -288,9 +288,9 @@ public:
// Check whether the invite only mode is set.
if (chan->IsModeSet(inviteonlymode))
{
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, chan));
if (MOD_RESULT != MOD_RES_ALLOW)
ModResult modres;
FIRST_MOD_RESULT(OnCheckInvite, modres, (user, chan));
if (modres != MOD_RES_ALLOW)
{
user->WriteNumeric(ERR_INVITEONLYCHAN, chan->name, "Cannot join channel (invite only)");
return MOD_RES_DENY;
@ -300,9 +300,9 @@ public:
// Check whether the limit would be exceeded by this user joining.
if (chan->IsModeSet(limitmode))
{
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan));
if (!MOD_RESULT.check(chan->GetUsers().size() < static_cast<size_t>(limitmode.ext.Get(chan))))
ModResult modres;
FIRST_MOD_RESULT(OnCheckLimit, modres, (user, chan));
if (!modres.check(chan->GetUsers().size() < static_cast<size_t>(limitmode.ext.Get(chan))))
{
user->WriteNumeric(ERR_CHANNELISFULL, chan->name, "Cannot join channel (channel is full)");
return MOD_RES_DENY;

View File

@ -178,17 +178,17 @@ public:
isupport.SendTo(user);
/* Trigger MOTD and LUSERS output, give modules a chance too */
ModResult MOD_RESULT;
ModResult modres;
std::string command("LUSERS");
CommandBase::Params parameters;
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, user, true));
if (!MOD_RESULT)
FIRST_MOD_RESULT(OnPreCommand, modres, (command, parameters, user, true));
if (!modres)
ServerInstance->Parser.CallHandler(command, parameters, user);
MOD_RESULT = MOD_RES_PASSTHRU;
modres = MOD_RES_PASSTHRU;
command = "MOTD";
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, user, true));
if (!MOD_RESULT)
FIRST_MOD_RESULT(OnPreCommand, modres, (command, parameters, user, true));
if (!modres)
ServerInstance->Parser.CallHandler(command, parameters, user);
if (ServerInstance->Config->RawLog)

View File

@ -130,13 +130,13 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters)
ModeType type = targetchannel ? MODETYPE_CHANNEL : MODETYPE_USER;
ServerInstance->Modes.ModeParamsToChangeList(user, type, parameters, changelist);
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnPreMode, MOD_RESULT, (user, targetuser, targetchannel, changelist));
ModResult modres;
FIRST_MOD_RESULT(OnPreMode, modres, (user, targetuser, targetchannel, changelist));
ModeParser::ModeProcessFlag flags = ModeParser::MODE_NONE;
if (IS_LOCAL(user))
{
if (MOD_RESULT == MOD_RES_PASSTHRU)
if (modres == MOD_RES_PASSTHRU)
{
if ((targetuser) && (user != targetuser))
{
@ -149,7 +149,7 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters)
// Ensure access checks will happen for each mode being changed.
flags |= ModeParser::MODE_CHECKACCESS;
}
else if (MOD_RESULT == MOD_RES_DENY)
else if (modres == MOD_RES_DENY)
return CmdResult::FAILURE; // Entire mode change denied by a module
}
else

View File

@ -86,10 +86,10 @@ CmdResult CommandKill::Handle(User* user, const Params& parameters)
* Moved this event inside the IS_LOCAL check also, we don't want half the network killing a user
* and the other half not. This would be a bad thing. ;p -- w00t
*/
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnKill, MOD_RESULT, (user, target, parameters[1]));
ModResult modres;
FIRST_MOD_RESULT(OnKill, modres, (user, target, parameters[1]));
if (MOD_RESULT == MOD_RES_DENY)
if (modres == MOD_RES_DENY)
return CmdResult::FAILURE;
killreason = "Killed (";

View File

@ -64,11 +64,11 @@ CmdResult CommandNick::HandleLocal(LocalUser* user, const Params& parameters)
return CmdResult::FAILURE;
}
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnUserPreNick, MOD_RESULT, (user, newnick));
ModResult modres;
FIRST_MOD_RESULT(OnUserPreNick, modres, (user, newnick));
// If a module denied the change, abort now
if (MOD_RESULT == MOD_RES_DENY)
if (modres == MOD_RES_DENY)
return CmdResult::FAILURE;
// Disallow the nick change if <security:restrictbannedusers> is on and there is a ban matching this user in

View File

@ -75,9 +75,9 @@ CmdResult CommandUser::CheckRegister(LocalUser* user)
// the other handler will call us again
if (user->connected == User::CONN_NICKUSER)
{
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnUserRegister, MOD_RESULT, (user));
if (MOD_RESULT == MOD_RES_DENY)
ModResult modres;
FIRST_MOD_RESULT(OnUserRegister, modres, (user));
if (modres == MOD_RES_DENY)
return CmdResult::FAILURE;
}

View File

@ -260,21 +260,21 @@ bool ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Modes::Cha
if (mcitem.param.length() > MODE_PARAM_MAX && mcitem.adding)
mcitem.param.erase(MODE_PARAM_MAX);
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, mcitem));
ModResult modres;
FIRST_MOD_RESULT(OnRawMode, modres, (user, chan, mcitem));
if (IS_LOCAL(user) && (MOD_RESULT == MOD_RES_DENY))
if (IS_LOCAL(user) && (modres == MOD_RES_DENY))
return false;
const char modechar = mh->GetModeChar();
if (chan && !SkipACL && (MOD_RESULT != MOD_RES_ALLOW))
if (chan && !SkipACL && (modres != MOD_RES_ALLOW))
{
MOD_RESULT = mh->AccessCheck(user, chan, mcitem);
modres = mh->AccessCheck(user, chan, mcitem);
if (MOD_RESULT == MOD_RES_DENY)
if (modres == MOD_RES_DENY)
return false;
if (MOD_RESULT == MOD_RES_PASSTHRU)
if (modres == MOD_RES_PASSTHRU)
{
ModeHandler::Rank neededrank = mh->GetLevelRequired(mcitem.adding);
ModeHandler::Rank ourrank = chan->GetPrefixValue(user);
@ -478,9 +478,9 @@ void ModeParser::ShowListModeList(User* user, Channel* chan, ModeHandler* mh)
{
{
Modes::Change modechange(mh, true, "");
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, modechange));
if (MOD_RESULT == MOD_RES_DENY)
ModResult modres;
FIRST_MOD_RESULT(OnRawMode, modres, (user, chan, modechange));
if (modres == MOD_RES_DENY)
return;
bool display = true;

View File

@ -132,11 +132,11 @@ public:
params.push_back(password);
// Begin callback to other modules (i.e. sslinfo) now that we completed the DB fetch
ModResult MOD_RESULT;
ModResult modres;
std::string origin = "OPER";
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (origin, params, user, true));
if (MOD_RESULT == MOD_RES_DENY)
FIRST_MOD_RESULT(OnPreCommand, modres, (origin, params, user, true));
if (modres == MOD_RES_DENY)
return;
// Now handle /OPER.

View File

@ -84,9 +84,9 @@ void Snomask::SendMessage(const std::string& message, char letter)
this->Flush();
std::string desc = GetDescription(letter);
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnSendSnotice, MOD_RESULT, (letter, desc, message));
if (MOD_RESULT == MOD_RES_DENY)
ModResult modres;
FIRST_MOD_RESULT(OnSendSnotice, modres, (letter, desc, message));
if (modres == MOD_RES_DENY)
return;
Snomask::Send(letter, desc, message);

View File

@ -259,9 +259,9 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std
LocalUser* const localuser = IS_LOCAL(user);
if (localuser)
{
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnUserPreQuit, MOD_RESULT, (localuser, quitmsg, operquitmsg));
if (MOD_RESULT == MOD_RES_DENY)
ModResult modres;
FIRST_MOD_RESULT(OnUserPreQuit, modres, (localuser, quitmsg, operquitmsg));
if (modres == MOD_RES_DENY)
return;
}

View File

@ -781,11 +781,11 @@ void User::WriteNumeric(const Numeric::Numeric& numeric)
if (!localuser)
return;
ModResult MOD_RESULT;
ModResult modres;
FIRST_MOD_RESULT(OnNumeric, MOD_RESULT, (this, numeric));
FIRST_MOD_RESULT(OnNumeric, modres, (this, numeric));
if (MOD_RESULT == MOD_RES_DENY)
if (modres == MOD_RES_DENY)
return;
ClientProtocol::Messages::Numeric numericmsg(numeric, localuser);