diff options
author | Sadie Powell <sadie@witchery.services> | 2024-02-27 10:16:05 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-02-27 10:19:44 +0000 |
commit | 7640fad30cc2a3d61e67a7075c27f26400d4779f (patch) | |
tree | f313f0e7cf6fafd1c94f7bd2b3650a207f941ccc /src | |
parent | 9f6d3787559febb48611b1477eaa6a35beadf71a (diff) |
Simplify several boolean expressions.
Diffstat (limited to 'src')
-rw-r--r-- | src/misc.cpp | 5 | ||||
-rw-r--r-- | src/modes.cpp | 5 | ||||
-rw-r--r-- | src/protocol.cpp | 4 | ||||
-rw-r--r-- | src/uplink.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 2 |
5 files changed, 6 insertions, 12 deletions
diff --git a/src/misc.cpp b/src/misc.cpp index 6d8c1ce9a..b8095af41 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -260,10 +260,7 @@ void InfoFormatter::AddOption(const Anope::string &opt) bool Anope::IsFile(const Anope::string &filename) { struct stat fileinfo; - if (!stat(filename.c_str(), &fileinfo)) - return true; - - return false; + return stat(filename.c_str(), &fileinfo) == 0; } time_t Anope::DoTime(const Anope::string &s) diff --git a/src/modes.cpp b/src/modes.cpp index 6cf99f61e..876492e98 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -233,10 +233,7 @@ bool UserModeNoone::CanSet(User *u) const bool ChannelModeKey::IsValid(Anope::string &value) const { - if (!value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos) - return true; - - return false; + return !value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos; } bool ChannelModeOperOnly::CanSet(User *u) const diff --git a/src/protocol.cpp b/src/protocol.cpp index bc97e58c8..007627114 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -271,10 +271,10 @@ bool IRCDProto::IsNickValid(const Anope::string &nick) Anope::string special = "[]\\`_^{|}"; for (unsigned i = 0; i < nick.length(); ++i) - if (!(nick[i] >= 'A' && nick[i] <= 'Z') && !(nick[i] >= 'a' && nick[i] <= 'z') + if ((nick[i] < 'A' || nick[i] > 'Z') && (nick[i] < 'a' || nick[i] > 'z') && special.find(nick[i]) == Anope::string::npos && (Config && Config->NickChars.find(nick[i]) == Anope::string::npos) - && (!i || (!(nick[i] >= '0' && nick[i] <= '9') && nick[i] != '-'))) + && (!i || ((nick[i] < '0' || nick[i] > '9') && nick[i] != '-'))) return false; return true; diff --git a/src/uplink.cpp b/src/uplink.cpp index dece54ba8..baa878db3 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -148,7 +148,7 @@ UplinkSocket::~UplinkSocket() bool UplinkSocket::ProcessRead() { bool b = BufferedSocket::ProcessRead(); - for (Anope::string buf; (buf = this->GetLine()).empty() == false;) + for (Anope::string buf; !(buf = this->GetLine()).empty();) { Anope::Process(buf); User::QuitUsers(); diff --git a/src/users.cpp b/src/users.cpp index e47cf93a6..285fe2c40 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -443,7 +443,7 @@ bool User::IsIdentified(bool check_nick) const return na && *na->nc == *this->nc; } - return this->nc ? true : false; + return this->nc; } bool User::IsRecognized(bool check_secure) const |