From f69aeff3d9ef15c7bef34daca9dd93327f23a087 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 20 Feb 2011 10:55:29 +0100 Subject: [PATCH] Some minor cleanup This makes the code use GetISpoofFile() instead of accessing m_sISpoofFile directly. Additonally, CFile::GetLongName() is used for printing the filepath. (This also removes an useless if branch, because nothing here cares if m_sISpoofFile is empty, we just need the lock file.) Signed-off-by: Uli Schlachter --- znc.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/znc.cpp b/znc.cpp index 53bbea50..1d18e9f8 100644 --- a/znc.cpp +++ b/znc.cpp @@ -255,9 +255,9 @@ bool CZNC::WriteISpoof(CUser* pUser) { if (m_pISpoofLockFile != NULL) return false; - if (!m_sISpoofFile.empty()) { + if (!GetISpoofFile().empty()) { m_pISpoofLockFile = new CFile; - if (!m_pISpoofLockFile->TryExLock(m_sISpoofFile, O_RDWR | O_CREAT)) { + if (!m_pISpoofLockFile->TryExLock(GetISpoofFile(), O_RDWR | O_CREAT)) { DEBUG("Couldn't open and lock ISpoofFile: " << strerror(errno)); delete m_pISpoofLockFile; m_pISpoofLockFile = NULL; @@ -283,7 +283,7 @@ bool CZNC::WriteISpoof(CUser* pUser) { if (sData == m_sISpoofFormat) { sData.Replace("%", pUser->GetIdent()); } - DEBUG("Writing [" + sData + "] to ISpoofFile [" + m_sISpoofFile + "]"); + DEBUG("Writing [" + sData + "] to ISpoofFile [" + m_pISpoofLockFile->GetLongName() + "]"); m_pISpoofLockFile->Write(sData + "\n"); } return true; @@ -293,17 +293,15 @@ void CZNC::ReleaseISpoof() { if (m_pISpoofLockFile == NULL) return; - if (!m_sISpoofFile.empty()) { - if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) { - DEBUG("Writing [" + m_sOrigISpoof + "] to ISpoofFile [" + m_sISpoofFile + "]"); - m_pISpoofLockFile->Write(m_sOrigISpoof); - } else { - DEBUG("Error while restoring ISpoof: " << strerror(errno)); - } - - m_sOrigISpoof = ""; + if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) { + DEBUG("Writing [" + m_sOrigISpoof + "] to ISpoofFile [" + m_pISpoofLockFile->GetLongName() + "]"); + m_pISpoofLockFile->Write(m_sOrigISpoof); + } else { + DEBUG("Error while restoring ISpoof: " << strerror(errno)); } + m_sOrigISpoof = ""; + delete m_pISpoofLockFile; m_pISpoofLockFile = NULL; }