From a9afa89800e0fe30159edf16cbebd3c0d85c8e41 Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Sun, 10 May 2020 01:38:56 +0200 Subject: [PATCH] Fix cppcheck [useInitializationList] warnings --- src/AsyncDNS.cpp | 2 +- src/CanceledFileList.cpp | 2 +- src/FileLock.h | 6 +++--- src/Friend.cpp | 2 +- src/GapList.h | 2 +- src/IP2Country.cpp | 2 +- src/Tag.cpp | 4 ++-- src/TextClient.cpp | 2 +- src/utils/wxCas/src/onlinesig.cpp | 18 +++++++----------- src/webserver/src/WebSocket.cpp | 8 ++++---- 10 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/AsyncDNS.cpp b/src/AsyncDNS.cpp index c0c08d720c..f1b1576d20 100644 --- a/src/AsyncDNS.cpp +++ b/src/AsyncDNS.cpp @@ -33,9 +33,9 @@ CAsyncDNS::CAsyncDNS(const wxString& ipName, DnsSolveType type, wxEvtHandler* handler, void* socket) : wxThread(wxTHREAD_DETACHED) + , m_ipName(ipName.wc_str()) // make a deep copy to to circument the thread-unsafe wxString reference counting { m_type = type; - m_ipName = ipName.wc_str(); // make a deep copy to to circument the thread-unsafe wxString reference counting m_socket = socket; m_handler = handler; } diff --git a/src/CanceledFileList.cpp b/src/CanceledFileList.cpp index f0286f04f4..def54c9a2a 100644 --- a/src/CanceledFileList.cpp +++ b/src/CanceledFileList.cpp @@ -33,8 +33,8 @@ CCanceledFileList::CCanceledFileList() + : m_filename(wxT("canceled.met")) { - m_filename = wxT("canceled.met"); Init(); } diff --git a/src/FileLock.h b/src/FileLock.h index 9758bdd863..edb948c273 100644 --- a/src/FileLock.h +++ b/src/FileLock.h @@ -59,14 +59,14 @@ class CFileLock CFileLock(const std::string& file) #ifdef _WIN32 : m_ok(false) - { - hd = CreateFileA((file + "_lock").c_str(), + , hd(CreateFileA((file + "_lock").c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, // share - shareable NULL, // security - not inheritable CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, - NULL); + NULL)) + { if (hd != INVALID_HANDLE_VALUE) { m_ok = SetLock(true); } diff --git a/src/Friend.cpp b/src/Friend.cpp index 3e528fcfd3..fe0b1dc010 100644 --- a/src/Friend.cpp +++ b/src/Friend.cpp @@ -39,12 +39,12 @@ void CFriend::Init() CFriend::CFriend( const CMD4Hash& userhash, uint32 tm_dwLastSeen, uint32 tm_dwLastUsedIP, uint32 tm_nLastUsedPort, uint32 tm_dwLastChatted, const wxString& tm_strName) + : m_UserHash(userhash) { m_dwLastSeen = tm_dwLastSeen; m_dwLastUsedIP = tm_dwLastUsedIP; m_nLastUsedPort = tm_nLastUsedPort; m_dwLastChatted = tm_dwLastChatted; - m_UserHash = userhash; if (tm_strName.IsEmpty()) { m_strName = wxT("?"); diff --git a/src/GapList.h b/src/GapList.h index 41c4af7189..2496ed1206 100644 --- a/src/GapList.h +++ b/src/GapList.h @@ -94,7 +94,7 @@ class CGapList { public: // constructs const_iterator() {}; - const_iterator(const ListType::const_iterator& it) { m_it = it; }; + const_iterator(const ListType::const_iterator& it) : m_it(it) { }; // operators bool operator != (const const_iterator& it) const { return m_it != it.m_it; } const_iterator& operator ++ () { ++ m_it; return *this; } diff --git a/src/IP2Country.cpp b/src/IP2Country.cpp index 24563daabd..90a7b575ef 100644 --- a/src/IP2Country.cpp +++ b/src/IP2Country.cpp @@ -73,9 +73,9 @@ #include "IP2Country.h" CIP2Country::CIP2Country(const wxString& configDir) + : m_DataBaseName(wxT("GeoIP.dat")) { m_geoip = NULL; - m_DataBaseName = wxT("GeoIP.dat"); m_DataBasePath = configDir + m_DataBaseName; } diff --git a/src/Tag.cpp b/src/Tag.cpp index 2e7e0c803c..f9f97f3ddc 100644 --- a/src/Tag.cpp +++ b/src/Tag.cpp @@ -37,10 +37,10 @@ // CTag CTag::CTag(const wxString& Name) + : m_Name(Name) { m_uType = 0; m_uName = 0; - m_Name = Name; m_uVal = 0; m_nSize = 0; } @@ -54,10 +54,10 @@ CTag::CTag(uint8 uName) } CTag::CTag(const CTag& rTag) + : m_Name(rTag.m_Name) { m_uType = rTag.m_uType; m_uName = rTag.m_uName; - m_Name = rTag.m_Name; m_nSize = 0; if (rTag.IsStr()) { m_pstrVal = new wxString(rTag.GetStr()); diff --git a/src/TextClient.cpp b/src/TextClient.cpp index 7d7cad0a1a..bac282ee4b 100644 --- a/src/TextClient.cpp +++ b/src/TextClient.cpp @@ -111,8 +111,8 @@ enum { // method to create a SearchFile SearchFile::SearchFile(const CEC_SearchFile_Tag *tag) + : nHash(tag->FileHash()) { - nHash = tag->FileHash(); sHash = nHash.Encode(); sFileName = tag->FileName(); lFileSize = tag->SizeFull(); diff --git a/src/utils/wxCas/src/onlinesig.cpp b/src/utils/wxCas/src/onlinesig.cpp index 3543e5482a..3348b91430 100644 --- a/src/utils/wxCas/src/onlinesig.cpp +++ b/src/utils/wxCas/src/onlinesig.cpp @@ -37,18 +37,14 @@ OnLineSig::OnLineSig ( const wxFileName& file, const double absoluteMaxDL, const wxDateTime absoluteMaxDlDate ) + : m_sessionMaxDL(0.0) + , m_sessionMaxDLDate(wxDateTime::Now()) + , m_isSessionMaxDlReseted(false) + , m_absoluteMaxDL(absoluteMaxDL) + , m_absoluteMaxDlDate(absoluteMaxDlDate) + , m_isAbsoluteMaxDlReseted(false) + , m_amulesig(file) { - m_amulesig = file; - - m_sessionMaxDL = 0.0; - m_sessionMaxDLDate = wxDateTime::Now(); - - m_absoluteMaxDL = absoluteMaxDL; - m_absoluteMaxDlDate = absoluteMaxDlDate; - - m_isSessionMaxDlReseted = false; - m_isAbsoluteMaxDlReseted = false; - Refresh (); } diff --git a/src/webserver/src/WebSocket.cpp b/src/webserver/src/WebSocket.cpp index 0fd4e5c0ff..2d66e143b5 100644 --- a/src/webserver/src/WebSocket.cpp +++ b/src/webserver/src/WebSocket.cpp @@ -33,14 +33,14 @@ #endif CWebSocket::CWebSocket(CWebServerBase *parent) + : m_dwBufSize(4096) + , m_dwRecv(0) + , m_dwHttpHeaderLen(0) + , m_dwHttpContentLen(0) { m_pHead = 0; m_pTail = 0; m_pBuf = new char [4096]; - m_dwBufSize = 4096; - m_dwRecv = 0; - m_dwHttpHeaderLen = 0; - m_dwHttpContentLen = 0; m_Cookie = 0; m_IsGet = false; m_IsPost = false;