OSDN Git Service

Fix Code scanning alert: Unused local variable
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 19 Feb 2023 07:27:24 +0000 (16:27 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 19 Feb 2023 07:27:24 +0000 (16:27 +0900)
Src/Common/RegOptionsMgr.cpp
Src/ConflictFileParser.cpp
Src/DirDoc.cpp
Src/MainFrm.cpp
Src/MergeDoc.cpp
Src/MergeEditView.cpp

index 9ca8d84..3df9d2f 100644 (file)
@@ -186,7 +186,7 @@ int CRegOptionsMgr::LoadValueFromReg(HKEY hKey, const String& strName,
        DWORD type = 0;
        DWORD size = 0;
        int retVal = COption::OPT_OK;
-       auto [strPath, strValueName] = SplitName(strName);
+       [[maybe_unused]] auto [strPath, strValueName] = SplitName(strName);
 
        // Get type and size of value in registry
        retValReg = RegQueryValueEx(hKey, strValueName.c_str(), 0, &type,
index 5c53d60..f5fb82e 100644 (file)
@@ -98,11 +98,19 @@ bool ParseConflictFile(const String& conflictFileName,
 
        // open input file
        bool success = conflictFile.OpenReadOnly(conflictFileName);
+       if (!success)
+               return false;
 
        // Create output files
        bool success2 = workingCopy.Open(workingCopyFileName, _T("wb"));
+       if (!success2)
+               return false;
        bool success3 = newRevision.Open(newRevisionFileName, _T("wb"));
+       if (!success3)
+               return false;
        bool success4 = baseRevision.Open(baseRevisionFileName, _T("wb"));
+       if (!success4)
+               return false;
 
        // detect codepage of conflict file
        FileTextEncoding encoding = codepage_detect::Guess(conflictFileName, iGuessEncodingType);
index f9d06d2..44bf016 100644 (file)
@@ -488,8 +488,7 @@ void CDirDoc::SetDirView(CDirView * newView)
        m_pDirView = newView;
        // MFC has a view list for us, so lets check against it
        POSITION pos = GetFirstViewPosition();
-       CDirView * temp = static_cast<CDirView *>(GetNextView(pos));
-       ASSERT(temp == m_pDirView); // verify that our stashed pointer is the same as MFC's
+       ASSERT(m_pDirView == static_cast<CDirView *>(GetNextView(pos))); // verify that our stashed pointer is the same as MFC's
 }
 
 /**
index 076f29b..87eb0c1 100644 (file)
@@ -2525,8 +2525,7 @@ static void LoadHiColImageList(UINT nIDResource, int nWidth, int nHeight, int nN
        bm.Attach(LoadBitmapAndConvertTo32bit(AfxGetInstanceHandle(), nIDResource, nNewWidth * nCount, nNewHeight, bGrayscale, RGB(0xff, 0, 0xff)));
 
        VERIFY(ImgList.Create(nNewWidth, nNewHeight, ILC_COLOR32, nCount, 0));
-       int nIndex = ImgList.Add(&bm, nullptr);
-       ASSERT(-1 != nIndex);
+       ASSERT(-1 != ImgList.Add(&bm, nullptr));
 }
 
 /**
@@ -3343,7 +3342,7 @@ String CMainFrame::GetPluginPipelineByMenuId(unsigned idSearch, const std::vecto
 {
        PluginInfo* pluginFound = nullptr;
        String pluginName;
-       auto [suggestedPlugins, allPlugins] = FileTransform::CreatePluginMenuInfos(_T(""), events, baseId);
+       [[maybe_unused]] auto [suggestedPlugins, allPlugins] = FileTransform::CreatePluginMenuInfos(_T(""), events, baseId);
        for (const auto& [processType, pluginList] : allPlugins)
        {
                for (const auto& [caption, name, id, plugin] : pluginList)
index 3bc6318..3c4b311 100644 (file)
@@ -63,7 +63,7 @@ using std::swap;
 
 int CMergeDoc::m_nBuffersTemp = 2;
 
-static void SaveBuffForDiff(CDiffTextBuffer & buf, const String& filepath, int nStartLine = 0, int nLines = -1);
+static int SaveBuffForDiff(CDiffTextBuffer & buf, const String& filepath, int nStartLine = 0, int nLines = -1);
 
 /////////////////////////////////////////////////////////////////////////////
 // CMergeDoc
@@ -290,14 +290,14 @@ void CMergeDoc::Serialize(CArchive& ar)
  * (the plugins are optional, not the conversion)
  * @todo Show SaveToFile() errors?
  */
-static void SaveBuffForDiff(CDiffTextBuffer & buf, const String& filepath, int nStartLine, int nLines)
+static int SaveBuffForDiff(CDiffTextBuffer & buf, const String& filepath, int nStartLine, int nLines)
 {
        // and we don't repack the file
        PackingInfo tempPacker(false);
 
        // write buffer out to temporary file
        String sError;
-       int retVal = buf.SaveToFile(filepath, true, sError, tempPacker,
+       return buf.SaveToFile(filepath, true, sError, tempPacker,
                CRLFSTYLE::AUTOMATIC, false, nStartLine, nLines);
 }
 
@@ -3878,7 +3878,6 @@ void CMergeDoc::OnFileRecompareAs(UINT nID)
        DWORD dwFlags[3] = { 0 };
        PathContext paths = m_filePaths;
        String strDesc[3];
-       int nBuffers = m_nBuffers;
        PackingInfo infoUnpacker(m_infoUnpacker.GetPluginPipeline());
 
        for (int pane = 0; pane < m_nBuffers; pane++)
index 18a0b18..b060ac2 100644 (file)
@@ -2179,7 +2179,7 @@ void CMergeEditView::OnAllLeft()
 void CMergeEditView::OnUpdateAllLeft(CCmdUI* pCmdUI)
 {
        // Check that left side is not readonly
-       auto [srcPane, dstPane] = CMergeFrameCommon::MenuIDtoXY(pCmdUI->m_nID, m_nThisPane, GetDocument()->m_nBuffers);
+       [[maybe_unused]] auto [srcPane, dstPane] = CMergeFrameCommon::MenuIDtoXY(pCmdUI->m_nID, m_nThisPane, GetDocument()->m_nBuffers);
        if (!IsReadOnly(dstPane))
                pCmdUI->Enable(GetDocument()->m_diffList.HasSignificantDiffs());
        else
@@ -2209,7 +2209,7 @@ void CMergeEditView::OnAllRight()
 void CMergeEditView::OnUpdateAllRight(CCmdUI* pCmdUI)
 {
        // Check that right side is not readonly
-       auto [srcPane, dstPane] = CMergeFrameCommon::MenuIDtoXY(pCmdUI->m_nID, m_nThisPane, GetDocument()->m_nBuffers);
+       [[maybe_unused]] auto [srcPane, dstPane] = CMergeFrameCommon::MenuIDtoXY(pCmdUI->m_nID, m_nThisPane, GetDocument()->m_nBuffers);
        if (!IsReadOnly(dstPane))
                pCmdUI->Enable(GetDocument()->m_diffList.HasSignificantDiffs());
        else
@@ -4318,7 +4318,6 @@ void CMergeEditView::OnWindowSplit()
 
        auto& wndSplitter = dynamic_cast<CMergeEditFrame *>(GetParentFrame())->GetSplitter();
        CMergeDoc *pDoc = GetDocument();
-       CMergeEditView *pView = pDoc->GetView(0, m_nThisPane);
        int nBuffer = m_nThisPane;
        if (pDoc->m_nGroups <= 2)
        {