diff --git a/include/znc/Socket.h b/include/znc/Socket.h index e0e0ab7a..67808398 100644 --- a/include/znc/Socket.h +++ b/include/znc/Socket.h @@ -46,10 +46,10 @@ class CZNCSock : public Csock, public CCoreTranslationMixin { m_ssTrustedFingerprints = ssFPs; } - void SetTrustAllCerts(const bool bTrustAll = false) { m_bTrustAllCerts = bTrustAll; } + void SetTrustAllCerts(bool bTrustAll) { m_bTrustAllCerts = bTrustAll; } bool GetTrustAllCerts() const { return m_bTrustAllCerts; } - void SetTrustPKI(const bool bTrustPKI = true) { m_bTrustPKI = bTrustPKI; } + void SetTrustPKI(bool bTrustPKI) { m_bTrustPKI = bTrustPKI; } bool GetTrustPKI() const { return m_bTrustPKI; } void SetEncoding(const CString&); @@ -66,8 +66,8 @@ class CZNCSock : public Csock, public CCoreTranslationMixin { CString m_sHostToVerifySSL; SCString m_ssTrustedFingerprints; SCString m_ssCertVerificationErrors; - bool m_bTrustAllCerts; - bool m_bTrustPKI; + bool m_bTrustAllCerts = false; + bool m_bTrustPKI = true; }; enum EAddrType { ADDR_IPV4ONLY, ADDR_IPV6ONLY, ADDR_ALL }; diff --git a/modules/controlpanel.cpp b/modules/controlpanel.cpp index e1ca243e..832cc762 100644 --- a/modules/controlpanel.cpp +++ b/modules/controlpanel.cpp @@ -549,28 +549,20 @@ class CAdminMod : public CModule { const CString sNetwork = sLine.Token(3); const CString sValue = sLine.Token(4, true); - CUser* pUser = nullptr; - CIRCNetwork* pNetwork = nullptr; - if (sValue.empty()) { PutModule( "Usage: SetNetwork "); return; } - if (sUsername.empty()) { - pUser = GetUser(); - pNetwork = CModule::GetNetwork(); - } else { - pUser = FindUser(sUsername); - if (!pUser) { - return; - } + CUser* pUser = FindUser(sUsername); + if (!pUser) { + return; + } - pNetwork = FindNetwork(pUser, sNetwork); - if (!pNetwork && !sNetwork.empty()) { - return; - } + CIRCNetwork* pNetwork = FindNetwork(pUser, sNetwork); + if (!pNetwork) { + return; } if (sVar.Equals("nick")) { diff --git a/modules/modpython/module.h b/modules/modpython/module.h index 42e45ffb..1343b45d 100644 --- a/modules/modpython/module.h +++ b/modules/modpython/module.h @@ -225,8 +225,8 @@ class ZNC_EXPORT_LIB_EXPORT CPyTimer : public CTimer { : CTimer(pModule, uInterval, uCycles, sLabel, sDescription), m_pyObj(pyObj) { Py_INCREF(pyObj); - pModule->AddTimer(this); m_pModPython = pModule->GetModPython(); + pModule->AddTimer(this); } void RunJob() override; PyObject* GetPyObj() { return m_pyObj; } diff --git a/modules/modtcl.cpp b/modules/modtcl.cpp index ef77f0fb..6e298c35 100644 --- a/modules/modtcl.cpp +++ b/modules/modtcl.cpp @@ -136,7 +136,7 @@ class CModTcl : public CModule { Tcl_CreateCommand(interp, "exit", tcl_exit, this, nullptr); if (!sMyArgs.empty()) { - i = Tcl_EvalFile(interp, sMyArgs.c_str()); + int i = Tcl_EvalFile(interp, sMyArgs.c_str()); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } @@ -171,7 +171,7 @@ class CModTcl : public CModule { void TclUpdate() { while (Tcl_DoOneEvent(TCL_DONT_WAIT)) { } - i = Tcl_Eval(interp, "Binds::ProcessTime"); + int i = Tcl_Eval(interp, "Binds::ProcessTime"); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } @@ -212,7 +212,7 @@ class CModTcl : public CModule { CString sCommand = "Binds::ProcessPubm {" + sNick + "} {" + sHost + "} - {" + sChannel + "} {" + sMes + "}"; - i = Tcl_Eval(interp, sCommand.c_str()); + int i = Tcl_Eval(interp, sCommand.c_str()); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } @@ -227,7 +227,7 @@ class CModTcl : public CModule { CString sCommand = "Binds::ProcessMsgm {" + sNick + "} {" + sHost + "} - {" + sMes + "}"; - i = Tcl_Eval(interp, sCommand.c_str()); + int i = Tcl_Eval(interp, sCommand.c_str()); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } @@ -249,7 +249,7 @@ class CModTcl : public CModule { sCommand = "Binds::ProcessNick {" + sOldNick + "} {" + sHost + "} - {" + vChans[n]->GetName() + "} {" + sNewNickTmp + "}"; - i = Tcl_Eval(interp, sCommand.c_str()); + int i = Tcl_Eval(interp, sCommand.c_str()); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } @@ -266,7 +266,7 @@ class CModTcl : public CModule { CString sCommand = "Binds::ProcessKick {" + sOpNick + "} {" + sOpHost + "} - {" + Channel.GetName() + "} {" + sNick + "} {" + sMessage + "}"; - i = Tcl_Eval(interp, sCommand.c_str()); + int i = Tcl_Eval(interp, sCommand.c_str()); if (i != TCL_OK) { PutModule(Tcl_GetStringResult(interp)); } @@ -274,7 +274,6 @@ class CModTcl : public CModule { private: Tcl_Interp* interp; - int i; static CString argvit(const char* argv[], unsigned int end, unsigned int begin, CString delim) { diff --git a/src/FileUtils.cpp b/src/FileUtils.cpp index 38b9402f..18b5bfb5 100644 --- a/src/FileUtils.cpp +++ b/src/FileUtils.cpp @@ -472,8 +472,7 @@ void CFile::Close() { void CFile::ClearBuffer() { m_sBuffer.clear(); } bool CFile::TryExLock(const CString& sLockFile, int iFlags) { - Open(sLockFile, iFlags); - return TryExLock(); + return Open(sLockFile, iFlags) && TryExLock(); } bool CFile::TryExLock() { return Lock(F_WRLCK, false); } diff --git a/src/znc.cpp b/src/znc.cpp index ba86fb76..f2b57113 100644 --- a/src/znc.cpp +++ b/src/znc.cpp @@ -1252,7 +1252,7 @@ bool CZNC::LoadUsers(CConfig& config, CString& sError) { CUtils::PrintMessage("Loading user [" + sUserName + "]"); - CUser* pUser = new CUser(sUserName); + std::unique_ptr pUser(new CUser(sUserName)); if (!m_sStatusPrefix.empty()) { if (!pUser->SetStatusPrefix(m_sStatusPrefix)) { @@ -1265,35 +1265,26 @@ bool CZNC::LoadUsers(CConfig& config, CString& sError) { if (!pUser->ParseConfig(pSubConf, sError)) { CUtils::PrintError(sError); - delete pUser; - pUser = nullptr; return false; } if (!pSubConf->empty()) { sError = "Unhandled lines in config for User [" + sUserName + "]!"; CUtils::PrintError(sError); - DumpConfig(pSubConf); return false; } CString sErr; - if (!AddUser(pUser, sErr, true)) { - sError = "Invalid user [" + pUser->GetUserName() + "] " + sErr; + if (!AddUser(pUser.release(), sErr, true)) { + sError = "Invalid user [" + sUserName + "] " + sErr; } if (!sError.empty()) { CUtils::PrintError(sError); - if (pUser) { - pUser->SetBeingDeleted(true); - delete pUser; - pUser = nullptr; - } + pUser->SetBeingDeleted(true); return false; } - - pUser = nullptr; } if (m_msUsers.empty()) {