From 3ad5334f17119c9ae010d5059f5cfb1831c9ddbd Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 17 Mar 2018 22:11:51 +0300 Subject: more warning fixes --- plugins/NewsAggregator/Src/Utils.cpp | 12 ++++-------- plugins/Quotes/src/ImportExport.cpp | 6 +++--- plugins/SimpleStatusMsg/src/main.cpp | 11 +++++------ plugins/UserInfoEx/src/psp_options.cpp | 3 +-- plugins/UserInfoEx/src/svc_reminder.cpp | 8 ++++---- plugins/Variables/src/contact.cpp | 12 +++++++----- 6 files changed, 24 insertions(+), 28 deletions(-) (limited to 'plugins') diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index 4eff01b870..56a5a99182 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -429,24 +429,20 @@ LPCTSTR ClearText(CMStringW &result, const wchar_t *message) MCONTACT GetContactByNick(const wchar_t *nick) { - MCONTACT hContact = NULL; - for (auto &hContact : Contacts(MODULE)) { ptrW contactNick(::db_get_wsa(hContact, MODULE, "Nick")); if (!mir_wstrcmpi(contactNick, nick)) - break; + return hContact; } - return hContact; + return 0; } MCONTACT GetContactByURL(const wchar_t *url) { - MCONTACT hContact = NULL; - for (auto &hContact : Contacts(MODULE)) { ptrW contactURL(::db_get_wsa(hContact, MODULE, "URL")); if (!mir_wstrcmpi(contactURL, url)) - break; + return hContact; } - return hContact; + return 0; } diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp index 081023b6a2..b68cc67103 100644 --- a/plugins/Quotes/src/ImportExport.cpp +++ b/plugins/Quotes/src/ImportExport.cpp @@ -222,10 +222,10 @@ INT_PTR Quotes_Export(WPARAM wp, LPARAM lp) } } else { - for (auto &hContact : Contacts(QUOTES_MODULE_NAME)) { - CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact); + for (auto &cc : Contacts(QUOTES_MODULE_NAME)) { + CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(cc); if (pProvider) { - IXMLNode::TXMLNodePtr pNode = export_contact(hContact, pXmlEngine); + IXMLNode::TXMLNodePtr pNode = export_contact(cc, pXmlEngine); if (pNode) pRoot->AddChild(pNode); } diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index c373c84401..0a9807348d 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -1614,16 +1614,15 @@ static int OnICQStatusMsgRequest(WPARAM wParam, LPARAM lParam, LPARAM lMirParam) return 0; char *szProto = (char *)lMirParam; - BOOL bContactFound = FALSE; - MCONTACT hContact; + MCONTACT hContact = 0; - for (auto &hContact : Contacts()) { - if (db_get_dw(hContact, szProto, "UIN", 0) == (DWORD)lParam) { - bContactFound = TRUE; + for (auto &cc : Contacts()) { + if (db_get_dw(cc, szProto, "UIN", 0) == (DWORD)lParam) { + hContact = cc; break; } } - if (!bContactFound) + if (!hContact) return 0; int iStatus = ICQMsgTypeToStatus(wParam); diff --git a/plugins/UserInfoEx/src/psp_options.cpp b/plugins/UserInfoEx/src/psp_options.cpp index 78466a2838..a27b0c6190 100644 --- a/plugins/UserInfoEx/src/psp_options.cpp +++ b/plugins/UserInfoEx/src/psp_options.cpp @@ -452,8 +452,7 @@ static INT_PTR CALLBACK DlgProc_AdvancedOpts(HWND hDlg, UINT uMsg, WPARAM wParam LPGENW("This will delete all settings, you've made!\nAll TreeView settings, window positions and any other settings!\n\nAre you sure to proceed?")); if (WantReset) { - MCONTACT hContact; - DB::CEnumList Settings; + DB::CEnumList Settings; // delete all skin icons if (!Settings.EnumSettings(NULL, "SkinIcons")) diff --git a/plugins/UserInfoEx/src/svc_reminder.cpp b/plugins/UserInfoEx/src/svc_reminder.cpp index c1e60e7531..b76227f7de 100644 --- a/plugins/UserInfoEx/src/svc_reminder.cpp +++ b/plugins/UserInfoEx/src/svc_reminder.cpp @@ -726,10 +726,10 @@ static INT_PTR BackupBirthdayService(WPARAM hContact, LPARAM lParam) else { WORD a1 = 0; - //walk through all the contacts stored in the DB - for (auto &hContact : Contacts()) - if (!db_mc_isSub(hContact) && !mdb.DBGetBirthDate(hContact)) - mdb.BackupBirthday(hContact, nullptr, TRUE, &a1); + // walk through all the contacts stored in the DB + for (auto &cc : Contacts()) + if (!db_mc_isSub(cc) && !mdb.DBGetBirthDate(cc)) + mdb.BackupBirthday(cc, nullptr, TRUE, &a1); } if (lParam != TRUE) { diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index 9e40bc71dd..52ecf66950 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -194,8 +194,8 @@ MCONTACT getContactFromString(const wchar_t *tszContact, DWORD dwFlags, int nMat // contact was not in cache, do a search CMStringW tmp; int count = 0; - MCONTACT hContact; LIST arResults(1); + MCONTACT hMatch = 0; for (auto &hContact : Contacts()) { // <_HANDLE_:hContact> @@ -268,8 +268,10 @@ MCONTACT getContactFromString(const wchar_t *tszContact, DWORD dwFlags, int nMat if (bMatch) { if (nMatch == -1) arResults.insert((HANDLE)hContact); - else if (nMatch == count) + else if (nMatch == count) { + hMatch = hContact; break; + } count++; } } @@ -277,7 +279,7 @@ MCONTACT getContactFromString(const wchar_t *tszContact, DWORD dwFlags, int nMat if (bReturnCount) return count; - if (hContact == 0) + if (hMatch == 0) return INVALID_CONTACT_ID; // return random contact @@ -289,13 +291,13 @@ MCONTACT getContactFromString(const wchar_t *tszContact, DWORD dwFlags, int nMat mir_cslock lck(csContactCache); CONTACTCE *cce = new CONTACTCE(); - cce->hContact = hContact; + cce->hContact = hMatch; cce->flags = dwFlags; cce->tszContact = mir_wstrdup(tszContact); arContactCache.insert(cce); } - return hContact; + return hMatch; } /* keep cache consistent */ -- cgit v1.2.3