Skip to content

Commit

Permalink
Merge branch 'cleanup' of https://github.com/kylef/znc
Browse files Browse the repository at this point in the history
  • Loading branch information
psychon committed Mar 28, 2011
2 parents bc67400 + d735e9d commit 1109455
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 48 deletions.
12 changes: 2 additions & 10 deletions FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,7 @@ bool CFile::Truncate() {
}

bool CFile::Sync() {
if (m_iFD != -1 && fsync(m_iFD) == 0) {
return true;
}

return false;
return (m_iFD != -1 && fsync(m_iFD) == 0);
}

bool CFile::Open(const CString& sFileName, int iFlags, mode_t iMode) {
Expand Down Expand Up @@ -414,11 +410,7 @@ bool CFile::Lock(int iType, bool bBlocking) {
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
if (fcntl(m_iFD, (bBlocking ? F_SETLKW : F_SETLK), &fl) == -1) {
return false;
} else {
return true;
}
return (fcntl(m_iFD, (bBlocking ? F_SETLKW : F_SETLK), &fl) != -1);
}

bool CFile::IsOpen() const { return (m_iFD != -1); }
Expand Down
10 changes: 1 addition & 9 deletions Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ CServer::CServer(const CString& sName, unsigned short uPort, const CString& sPas
CServer::~CServer() {}

bool CServer::IsValidHostName(const CString& sHostName) {
if (sHostName.empty()) {
return false;
}

if (sHostName.find(' ') != CString::npos) {
return false;
}

return true;
return (!sHostName.empty() && (sHostName.find(' ') == CString::npos));
}

const CString& CServer::GetName() const { return m_sName; }
Expand Down
13 changes: 2 additions & 11 deletions User.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,7 @@ void CUser::SetIRCSocket(CIRCSock* pIRCSock) {
bool CUser::IsIRCConnected() const
{
const CIRCSock* pSock = GetIRCSock();

if (!pSock)
return false;

if (!pSock->IsConnected())
return false;

return true;
return (pSock && pSock->IsConnected());
}

void CUser::IRCDisconnected() {
Expand Down Expand Up @@ -630,9 +623,7 @@ bool CUser::PrintLine(CFile& File, CString sName, CString sValue) const {
// FirstLine() so that no one can inject new lines to the config if he
// manages to add "\n" to e.g. sValue.
CString sLine = "\t" + sName.FirstLine() + " = " + sValue.FirstLine() + "\n";
if (File.Write(sLine) <= 0)
return false;
return true;
return (File.Write(sLine) > 0);
}

bool CUser::WriteConfig(CFile& File) {
Expand Down
5 changes: 1 addition & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ static void signalHandler(int sig) {

static bool isRoot() {
// User root? If one of these were root, we could switch the others to root, too
if (geteuid() == 0 || getuid() == 0)
return true;

return false;
return (geteuid() == 0 || getuid() == 0);
}

static void seedPRNG() {
Expand Down
5 changes: 1 addition & 4 deletions modules/watch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ class CWatchEntry {
return false;
if (!Nick.GetHostMask().AsLower().WildCmp(m_sHostMask.AsLower()))
return false;
if (!sText.AsLower().WildCmp(pUser->ExpandString(m_sPattern).AsLower()))
return false;

return true;
return (sText.AsLower().WildCmp(pUser->ExpandString(m_sPattern).AsLower()));
}

bool operator ==(const CWatchEntry& WatchEntry) {
Expand Down
5 changes: 1 addition & 4 deletions modules/webadmin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ inline bool FOR_EACH_MODULE_CanContinue(FOR_EACH_MODULE_Type& state, CModules::i
i = state.CMuser.begin();
state.bOnCMuser = true;
}
if (state.bOnCMuser && i == state.CMuser.end()) {
return false;
}
return true;
return !(state.bOnCMuser && i == state.CMuser.end());
}

#define FOR_EACH_MODULE(I, pUser)\
Expand Down
8 changes: 2 additions & 6 deletions znc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,7 @@ bool CZNC::DeletePidFile() {

CUtils::PrintAction("Deleting pid file [" + File->GetLongName() + "]");

bool bRet = false;
if (File->Delete())
bRet = true;
bool bRet = File->Delete();

delete File;
CUtils::PrintStatus(bRet);
Expand Down Expand Up @@ -416,9 +414,7 @@ bool CZNC::IsHostAllowed(const CString& sHostMask) const {
bool CZNC::AllowConnectionFrom(const CString& sIP) const {
if (m_uiAnonIPLimit == 0)
return true;
if (GetManager().GetAnonConnectionCount(sIP) >= m_uiAnonIPLimit)
return false;
return true;
return (GetManager().GetAnonConnectionCount(sIP) < m_uiAnonIPLimit)
}

void CZNC::InitDirs(const CString& sArgvPath, const CString& sDataDir) {
Expand Down

0 comments on commit 1109455

Please sign in to comment.