OSDN Git Service

Reduce IntelliSense warnings
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 6 Aug 2023 10:18:50 +0000 (19:18 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 6 Aug 2023 10:18:50 +0000 (19:18 +0900)
Externals/crystaledit/editlib/ccrystaltextview.cpp
Src/ClipboardHistory.h
Src/CompareStats.h
Src/DirActions.cpp
Src/DirCompProgressBar.cpp
Src/InternalPlugins.cpp
Src/MainFrm.cpp
Src/OpenView.cpp
Src/WinMergePluginBase.h
Src/locality.cpp

index f8168b9..91e3f89 100644 (file)
@@ -3638,8 +3638,7 @@ int CCrystalTextView::GetSubLineIndex( int nLineIndex )
   else
     {
       m_nLastLineIndexCalculatedSubLineIndex = 0;
-      if (m_panSubLineIndexCache->size () >= 0)
-        m_panSubLineIndexCache->resize (1);
+      m_panSubLineIndexCache->resize (1);
       (*m_panSubLineIndexCache)[0] = 0;
     }
 
index c9a3cb0..39e465d 100644 (file)
@@ -15,7 +15,7 @@ namespace ClipboardHistory
 {
        struct Item
        {
-               time_t timestamp;
+               time_t timestamp = 0;
                std::shared_ptr<TempFile> pTextTempFile;
                std::shared_ptr<TempFile> pBitmapTempFile;
        };
index dbd185f..87e38ae 100644 (file)
@@ -78,19 +78,20 @@ public:
                m_rgThreadState.clear();
                m_rgThreadState.resize(nCompareThreads);
        }
-       int GetIdleCompareThreadCount() const
+       unsigned GetIdleCompareThreadCount() const
        {
                return m_nIdleCompareThreadCount;
        }
-       void SetIdleCompareThreadCount(int nIdleCompareThreadCount)
+       void SetIdleCompareThreadCount(unsigned nIdleCompareThreadCount)
        {
+               assert(nIdleCompareThreadCount < m_rgThreadState.size());
                m_nIdleCompareThreadCount = nIdleCompareThreadCount;
        }
-       bool IsIdleCompareThread(int iCompareThread) const
+       bool IsIdleCompareThread(unsigned iCompareThread) const
        {
                return iCompareThread >= (m_rgThreadState.size() - m_nIdleCompareThreadCount);
        }
-       void BeginCompare(const DIFFITEM *di, int iCompareThread)
+       void BeginCompare(const DIFFITEM *di, unsigned iCompareThread)
        {
                ThreadState &rThreadState = m_rgThreadState[iCompareThread];
                rThreadState.m_nHitCount = 0;
@@ -125,7 +126,7 @@ private:
                const DIFFITEM *m_pDiffItem;
        };
        std::vector<ThreadState> m_rgThreadState;
-       int m_nIdleCompareThreadCount;
+       unsigned m_nIdleCompareThreadCount;
 };
 
 /** 
index cb912cc..cb5b9ba 100644 (file)
@@ -22,9 +22,9 @@
 #include "FileFilterHelper.h"
 #include "DebugNew.h"
 
-static void ThrowConfirmCopy(const CDiffContext& ctxt, int origin, int destination, int count,
+static void ThrowConfirmCopy(const CDiffContext& ctxt, int origin, int destination, size_t count,
                const String& src, const String& dest, bool destIsSide);
-static void ThrowConfirmMove(const CDiffContext& ctxt, int origin, int destination, int count,
+static void ThrowConfirmMove(const CDiffContext& ctxt, int origin, int destination, size_t count,
                const String& src, const String& dest, bool destIsSide);
 static void ThrowConfirmationNeededException(const CDiffContext& ctxt, const String &caption, const String &question,
                int origin, int destination, size_t count,
@@ -287,7 +287,7 @@ UPDATEITEM_TYPE UpdateDiffAfterOperation(const FileActionItem & act, CDiffContex
 
        if (bRemoveItem)
                return UPDATEITEM_REMOVE;
-       if (bUpdateSrc | bUpdateDest)
+       if (bUpdateSrc || bUpdateDest)
                return UPDATEITEM_UPDATE;
        return UPDATEITEM_NONE;
 }
index f411f07..8d3669c 100644 (file)
@@ -78,8 +78,7 @@ BOOL DirCompProgressBar::Create(CWnd* pParentWnd)
                return FALSE; 
 
 #ifdef __ITaskbarList3_INTERFACE_DEFINED__
-       CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_ALL, IID_ITaskbarList3, (void**)&m_pTaskbarList);
-       if (m_pTaskbarList != nullptr)
+       if (SUCCEEDED(CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_ALL, IID_ITaskbarList3, (void**)&m_pTaskbarList)))
                m_pTaskbarList->SetProgressState(AfxGetMainWnd()->m_hWnd, TBPF_INDETERMINATE);
 #endif
 
index 7da57ef..58137a6 100644 (file)
@@ -461,14 +461,16 @@ protected:
                        PARSEDURL parsedURL{sizeof(PARSEDURL)};
                        ParseURL(fileSrc.c_str(), &parsedURL);
                        strutils::replace(command, _T("${SRC_URL_PROTOCOL}"), String{ parsedURL.pszProtocol, parsedURL.cchProtocol });
-                       strutils::replace(command, _T("${SRC_URL_SUFFIX}"), parsedURL.pszSuffix);
+                       strutils::replace(command, _T("${SRC_URL_SUFFIX}"), 
+                               parsedURL.pszSuffix ? parsedURL.pszSuffix : _T(""));
                }
                if (paths::IsURL(fileDst))
                {
                        PARSEDURL parsedURL{sizeof(PARSEDURL)};
                        ParseURL(fileDst.c_str(), &parsedURL);
                        strutils::replace(command, _T("${DST_URL_PROTOCOL}"), String{ parsedURL.pszProtocol, parsedURL.cchProtocol });
-                       strutils::replace(command, _T("${DST_URL_SUFFIX}"), parsedURL.pszSuffix);
+                       strutils::replace(command, _T("${DST_URL_SUFFIX}"), 
+                               parsedURL.pszSuffix ? parsedURL.pszSuffix : _T(""));
                }
                strutils::replace(command, _T("${SRC_FILE}"), fileSrc);
                strutils::replace(command, _T("${DST_FILE}"), fileDst);
index 88e60a2..dd1bf12 100644 (file)
@@ -1257,9 +1257,11 @@ static bool AddToRecentDocs(const PathContext& paths,
        }
 
        Concurrent::CreateTask([params, title](){
-                       CoInitialize(nullptr);
-                       JumpList::AddToRecentDocs(_T(""), params, title, params, _T(""), 0);
-                       CoUninitialize();
+                       if (SUCCEEDED(CoInitialize(nullptr)))
+                       {
+                               JumpList::AddToRecentDocs(_T(""), params, title, params, _T(""), 0);
+                               CoUninitialize();
+                       }
                        return 0;
                });
        return true;
index 2d2cddc..d0e8b99 100644 (file)
@@ -1086,12 +1086,12 @@ struct UpdateButtonStatesThreadParams
 
 static UINT UpdateButtonStatesThread(LPVOID lpParam)
 {
-       MSG msg;
-       BOOL bRet;
+       if (FAILED(CoInitialize(nullptr)))
+               return 0;
 
-       CoInitialize(nullptr);
        CAssureScriptsForThread scriptsForRescan(new MergeAppCOMClass());
-
+       MSG msg;
+       BOOL bRet;
        while( (bRet = GetMessage( &msg, nullptr, 0, 0 )) != 0)
        { 
                if (bRet == -1)
index c330540..e8ed338 100644 (file)
@@ -333,9 +333,11 @@ public:
                if (hr == DISP_E_EXCEPTION && pExcepInfo)
                {
                        IErrorInfo* pErrorInfo = nullptr;
-                       GetErrorInfo(0, &pErrorInfo);
-                       pErrorInfo->GetDescription(&pExcepInfo->bstrDescription);
-                       pErrorInfo->GetSource(&pExcepInfo->bstrSource);
+                       if (SUCCEEDED(GetErrorInfo(0, &pErrorInfo)))
+                       {
+                               pErrorInfo->GetDescription(&pExcepInfo->bstrDescription);
+                               pErrorInfo->GetSource(&pExcepInfo->bstrSource);
+                       }
                }
                return hr;
        }
index a8a4499..a264d08 100644 (file)
@@ -123,7 +123,7 @@ String TimeString(const int64_t * tim)
        if (tim == nullptr) return _T("---");
        
        SYSTEMTIME sysTimeGlobal, sysTime;
-       FILETIME ft;
+       FILETIME ft{};
        Timestamp t(*tim * Timestamp::resolution());
 
        if (t == 0)