OSDN Git Service

Cppcheck: Variable '...' is assigned a value that is never used.
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Tue, 16 Aug 2016 12:53:00 +0000 (21:53 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Tue, 16 Aug 2016 12:53:00 +0000 (21:53 +0900)
13 files changed:
Src/Common/PropertyPageHost.cpp
Src/Common/ShellContextMenu.cpp
Src/Common/version.cpp
Src/DirView.cpp
Src/DropHandler.cpp
Src/Merge7zFormatShellImpl.cpp
Src/MergeDoc.cpp
Src/MergeDocEncoding.cpp
Src/MergeEditView.cpp
Src/OptionsInit.cpp
Src/Plugins.cpp
Src/paths.cpp
Src/stringdiffs.cpp

index ae5e29f..5989a39 100644 (file)
@@ -242,7 +242,6 @@ BOOL COccManager::IsDialogMessage(CWnd* pWndDlg, LPMSG lpMsg)
 {
        CWnd* pWndFocus = CWnd::GetFocus();
        HWND hWndFocus = pWndFocus->GetSafeHwnd();
-       HWND hWndDlg = pWndDlg->GetSafeHwnd();
        UINT uMsg = lpMsg->message;
 
        if (((uMsg >= WM_KEYFIRST) && (uMsg <= WM_KEYLAST)) ||
index 66e661b..b31ffb9 100644 (file)
@@ -77,7 +77,7 @@ HMENU CShellContextMenu::GetHMENU() const
 
 bool CShellContextMenu::HandleMenuMessage(UINT message, WPARAM wParam, LPARAM lParam, LRESULT& retval)
 {
-       HRESULT hr = E_FAIL;
+       //HRESULT hr = E_FAIL;
        switch (message)
        {
        case WM_DRAWITEM:
@@ -85,7 +85,7 @@ bool CShellContextMenu::HandleMenuMessage(UINT message, WPARAM wParam, LPARAM lP
        case WM_MEASUREITEM:
                if (m_pShellContextMenu3)
                {
-                       if (FAILED(hr = m_pShellContextMenu3->HandleMenuMsg(message, wParam, lParam/*, &retval*/)))
+                       if (FAILED(/*hr = */m_pShellContextMenu3->HandleMenuMsg(message, wParam, lParam/*, &retval*/)))
                        {
                                //TRACE(_T("HandleMenuMsg(%x) failed with error: %lx\n"), message, hr);
                                //if (message == WM_DRAWITEM)
@@ -99,7 +99,7 @@ bool CShellContextMenu::HandleMenuMessage(UINT message, WPARAM wParam, LPARAM lP
                }
                else if (m_pShellContextMenu2)
                {
-                       if (FAILED(hr = m_pShellContextMenu2->HandleMenuMsg(message, wParam, lParam)))
+                       if (FAILED(/*hr = */m_pShellContextMenu2->HandleMenuMsg(message, wParam, lParam)))
                        {
                                //TRACE(_T("HandleMenuMsg(%x) failed with error: %lx\n"), message, hr);
                                //assert(0);
@@ -112,7 +112,7 @@ bool CShellContextMenu::HandleMenuMessage(UINT message, WPARAM wParam, LPARAM lP
                if (m_pShellContextMenu3)
                {
                        retval = 0;
-                       if (FAILED(hr = m_pShellContextMenu3->HandleMenuMsg2(message, wParam, lParam, &retval)))
+                       if (FAILED(/*hr = */m_pShellContextMenu3->HandleMenuMsg2(message, wParam, lParam, &retval)))
                        {
                                //TRACE(_T("HandleMenuMsg2(%x) failed with error: %lx\n"), message, hr);
                                //assert(0);
@@ -125,9 +125,9 @@ bool CShellContextMenu::HandleMenuMessage(UINT message, WPARAM wParam, LPARAM lP
 
 bool CShellContextMenu::QueryShellContextMenu()
 {
-       HRESULT hr = E_FAIL;
+       //HRESULT hr = E_FAIL;
        IShellFolderPtr pDesktop;
-       if (FAILED(hr = SHGetDesktopFolder(&pDesktop)))
+       if (FAILED(/*hr = */SHGetDesktopFolder(&pDesktop)))
                return false;
 
        String parentDir; // use it to track that all selected files are in the same parent directory
@@ -145,7 +145,7 @@ bool CShellContextMenu::QueryShellContextMenu()
                        parentDir = currentDir;
 
                        LPITEMIDLIST dirPidl;
-                       if (FAILED(hr = pDesktop->ParseDisplayName(NULL,                                           // hwnd
+                       if (FAILED(/*hr = */pDesktop->ParseDisplayName(NULL,                                       // hwnd
                                                                                                           NULL,                                           // pbc
                                                                                                           CT2OLE(currentDir.c_str()), // pszDisplayName
                                                                                                           NULL,                                           // pchEaten
@@ -156,7 +156,7 @@ bool CShellContextMenu::QueryShellContextMenu()
                                return false;
                        }
 
-                       if (FAILED(hr = pDesktop->BindToObject(dirPidl,                  // pidl
+                       if (FAILED(/*hr = */pDesktop->BindToObject(dirPidl,                      // pidl
                                                                                                   NULL,                         // pbc
                                                                                                   IID_IShellFolder, // riid
                                                                                                   reinterpret_cast<void**>(&pCurrFolder))))
@@ -170,7 +170,7 @@ bool CShellContextMenu::QueryShellContextMenu()
                }
 
                LPITEMIDLIST pidl;
-               if (FAILED(hr = pCurrFolder->ParseDisplayName(NULL,
+               if (FAILED(/*hr = */pCurrFolder->ParseDisplayName(NULL,
                                                                                                          NULL,
                                                                                                          CT2OLE(file.filename.c_str()), 
                                                                                                          NULL,
@@ -189,7 +189,7 @@ bool CShellContextMenu::QueryShellContextMenu()
        }
 
        IContextMenuPtr pCMenu1;
-       if (FAILED(hr = pCurrFolder->GetUIObjectOf(NULL,
+       if (FAILED(/*hr = */pCurrFolder->GetUIObjectOf(NULL,
                                                                                           static_cast<unsigned>(pidls.Size()),
                                                                                           pidls.GetList(),
                                                                                           IID_IContextMenu,
@@ -214,7 +214,7 @@ bool CShellContextMenu::QueryShellContextMenu()
        }
 
        ASSERT(::IsMenu(m_hShellContextMenu));
-       if (FAILED(hr = m_pPreferredMenu->QueryContextMenu(m_hShellContextMenu,
+       if (FAILED(/*hr = */m_pPreferredMenu->QueryContextMenu(m_hShellContextMenu,
                                                                                                           0,
                                                                                                           m_cmdFirst,
                                                                                                           m_cmdLast,
index 5405a36..ba88ad7 100644 (file)
@@ -402,7 +402,10 @@ void CVersionInfo::GetFixedVersionInfo()
        UINT len = sizeof(*pffi);
        BOOL bRetCode = VerQueryValue(
                (LPVOID)m_pVffInfo.get(), _T("\\"), (LPVOID *)&pffi, &len);
-       memcpy(&m_FixedFileInfo, pffi, sizeof(m_FixedFileInfo));
+       if (bRetCode)
+               memcpy(&m_FixedFileInfo, pffi, sizeof(m_FixedFileInfo));
+       else
+               memset(&m_FixedFileInfo, 0, sizeof(m_FixedFileInfo));
        m_dvi.dwMajorVersion = HIWORD(m_FixedFileInfo.dwFileVersionMS);
        m_dvi.dwMinorVersion = LOWORD(m_FixedFileInfo.dwFileVersionMS);
        m_dvi.dwBuildNumber = HIWORD(m_FixedFileInfo.dwFileVersionLS);
index 2d1c369..bba04be 100644 (file)
@@ -1596,7 +1596,6 @@ void CDirView::GetItemFileNames(int sel, String& strLeft, String& strRight) cons
  */
 void CDirView::GetItemFileNames(int sel, PathContext * paths) const
 {
-       String strPath[3];
        UINT_PTR diffpos = GetItemKey(sel);
        if (diffpos == SPECIAL_ITEM_POS)
        {
@@ -1724,7 +1723,6 @@ void CDirView::DoUpdateOpen(SELECTIONTYPE selectionType, CCmdUI* pCmdUI)
        if (sel2 == -1)
        {
                // One item selected
-               const DIFFITEM& di = GetDiffItem(sel1);
                if (selectionType != SELECTIONTYPE_NORMAL)
                {
                        pCmdUI->Enable(FALSE);
index de29e6c..5b5b736 100644 (file)
@@ -41,7 +41,6 @@ namespace
                std::vector<String> files;
                // Get the number of pathnames that have been dropped
                UINT wNumFilesDropped = DragQueryFile(dropInfo, 0xFFFFFFFF, NULL, 0);
-               UINT fileCount = 0;
 
                // get all file names. but we'll only need the first one.
                for (WORD x = 0; x < wNumFilesDropped; x++)
@@ -362,5 +361,5 @@ HRESULT DropHandler::Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, D
                files.resize(3);
        if (!files.empty())
                m_callback(files);
-       return S_OK;
+       return ok ? S_OK : E_FAIL;
 }
index 40ff905..f8b1fbf 100644 (file)
@@ -65,7 +65,7 @@ HRESULT Merge7zFormatShellImpl::DeCompressArchive(HWND, LPCTSTR path, LPCTSTR fo
        if (FAILED(hr))
                return hr;
 
-       hr = pFileOperation->SetOperationFlags(0);
+       pFileOperation->SetOperationFlags(0);
 
        IShellItemPtr pShellItemDest, pShellItem;
        IEnumShellItemsPtr pEnumShellItems;
index 2b4f0c4..5e5f934 100644 (file)
@@ -1044,22 +1044,15 @@ bool CMergeDoc::SanityCheckDiff(DIFFRANGE dr) const
 {
        const int cd_dbegin = dr.dbegin;
        const int cd_dend = dr.dend;
-       int nBuffer;
-
-       // Must ensure line number is in range before getting line flags
-       if (cd_dend >= m_ptBuf[0]->GetLineCount())
-               return false;
-       DWORD dwLeftFlags = m_ptBuf[0]->GetLineFlags(cd_dend);
 
-       // Must ensure line number is in range before getting line flags
-       if (cd_dend >= m_ptBuf[1]->GetLineCount())
-               return false;
-       DWORD dwRightFlags = m_ptBuf[1]->GetLineFlags(cd_dend);
-
-       // Optimization - check last line first so we don't need to
-       // check whole diff for obvious cases
-       for (nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
+       for (int nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
        {
+               // Must ensure line number is in range before getting line flags
+               if (cd_dend >= m_ptBuf[nBuffer]->GetLineCount())
+                       return false;
+
+               // Optimization - check last line first so we don't need to
+               // check whole diff for obvious cases
                DWORD dwFlags = m_ptBuf[nBuffer]->GetLineFlags(cd_dend);
                if (!(dwFlags & LF_WINMERGE_FLAGS))
                        return false;
@@ -1067,7 +1060,7 @@ bool CMergeDoc::SanityCheckDiff(DIFFRANGE dr) const
 
        for (int line = cd_dbegin; line < cd_dend; line++)
        {
-               for (nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
+               for (int nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
                {
                        DWORD dwFlags = m_ptBuf[nBuffer]->GetLineFlags(cd_dend);
                        if (!(dwFlags & LF_WINMERGE_FLAGS))
index 2125797..c732670 100644 (file)
@@ -81,10 +81,12 @@ bool CMergeDoc::DoFileEncodingDialog()
                for (int pane = 0; pane < m_nBuffers; pane++)
                {
                        bRO[pane] = m_ptBuf[pane]->GetReadOnly();
-                       if ((pane == 0 && doLeft) ||
+                       if (!bRO[pane] && (
+                               (pane == 0 && doLeft) ||
                                (pane == 1 && doRight  && m_nBuffers <  3) ||
                                (pane == 1 && doMiddle && m_nBuffers == 3) ||
-                               (pane == 2 && doRight  && m_nBuffers == 3))
+                               (pane == 2 && doRight  && m_nBuffers == 3)
+                               ))
                        {
                                m_ptBuf[pane]->setCodepage(nSaveCodepage);
                                m_ptBuf[pane]->SetModified();
index 8a4b149..6a4dd31 100644 (file)
@@ -2484,22 +2484,6 @@ void CMergeEditView::OnUpdateStatusRO(CCmdUI* pCmdUI)
 }
 
 /**
- * @brief Call ::AppendMenu, and if it fails get error string into local variable
- *
- * This only provides functionality for debugging.
- */
-static bool DoAppendMenu(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpNewItem)
-{
-       bool ok = ::AppendMenu(hMenu, uFlags, uIDNewItem, lpNewItem) != false;
-       if (!ok)
-       {
-               int nerr = GetLastError();
-               String syserr = GetSysError(nerr);
-       }
-       return ok;
-}
-
-/**
  * @brief Create the dynamic submenu for scripts
  */
 HMENU CMergeEditView::createScriptsSubmenu(HMENU hMenu)
@@ -2516,20 +2500,20 @@ HMENU CMergeEditView::createScriptsSubmenu(HMENU hMenu)
        if (functionNamesList.size() == 0)
        {
                // no script : create a <empty> entry
-               DoAppendMenu(hMenu, MF_STRING, ID_NO_EDIT_SCRIPTS, _("< Empty >").c_str());
+               AppendMenu(hMenu, MF_STRING, ID_NO_EDIT_SCRIPTS, _("< Empty >").c_str());
        }
        else
        {
                // or fill in the submenu with the scripts names
                int ID = ID_SCRIPT_FIRST;       // first ID in menu
                for (i = 0 ; i < functionNamesList.size() ; i++, ID++)
-                       DoAppendMenu(hMenu, MF_STRING, ID, functionNamesList[i].c_str());
+                       AppendMenu(hMenu, MF_STRING, ID, functionNamesList[i].c_str());
 
                functionNamesList.clear();
        }
 
        if (!IsWindowsScriptThere())
-               DoAppendMenu(hMenu, MF_STRING, ID_NO_SCT_SCRIPTS, _("WSH not found - .sct scripts disabled").c_str());
+               AppendMenu(hMenu, MF_STRING, ID_NO_SCT_SCRIPTS, _("WSH not found - .sct scripts disabled").c_str());
 
        return hMenu;
 }
@@ -2558,7 +2542,7 @@ HMENU CMergeEditView::createPrediffersSubmenu(HMENU hMenu)
        ASSERT(pd);
 
        // title
-       DoAppendMenu(hMenu, MF_STRING, ID_NO_PREDIFFER, _("No prediffer (normal)").c_str());
+       AppendMenu(hMenu, MF_STRING, ID_NO_PREDIFFER, _("No prediffer (normal)").c_str());
 
        // get the scriptlet files
        PluginArray * piScriptArray = 
@@ -2568,8 +2552,8 @@ HMENU CMergeEditView::createPrediffersSubmenu(HMENU hMenu)
 
        // build the menu : first part, suggested plugins
        // title
-       DoAppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
-       DoAppendMenu(hMenu, MF_STRING, ID_SUGGESTED_PLUGINS, _("Suggested plugins").c_str());
+       AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
+       AppendMenu(hMenu, MF_STRING, ID_SUGGESTED_PLUGINS, _("Suggested plugins").c_str());
 
        int ID = ID_PREDIFFERS_FIRST;   // first ID in menu
        int iScript;
@@ -2579,7 +2563,7 @@ HMENU CMergeEditView::createPrediffersSubmenu(HMENU hMenu)
                if (plugin->m_disabled || !plugin->TestAgainstRegList(pd->m_strBothFilenames))
                        continue;
 
-               DoAppendMenu(hMenu, MF_STRING, ID, plugin->m_name.c_str());
+               AppendMenu(hMenu, MF_STRING, ID, plugin->m_name.c_str());
        }
        for (iScript = 0 ; iScript < piScriptArray2->size() ; iScript++, ID ++)
        {
@@ -2587,13 +2571,13 @@ HMENU CMergeEditView::createPrediffersSubmenu(HMENU hMenu)
                if (plugin->m_disabled || !plugin->TestAgainstRegList(pd->m_strBothFilenames))
                        continue;
 
-               DoAppendMenu(hMenu, MF_STRING, ID, plugin->m_name.c_str());
+               AppendMenu(hMenu, MF_STRING, ID, plugin->m_name.c_str());
        }
 
        // build the menu : second part, others plugins
        // title
-       DoAppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
-       DoAppendMenu(hMenu, MF_STRING, ID_NOT_SUGGESTED_PLUGINS, _("Other plugins").c_str());
+       AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
+       AppendMenu(hMenu, MF_STRING, ID_NOT_SUGGESTED_PLUGINS, _("Other plugins").c_str());
 
        ID = ID_PREDIFFERS_FIRST;       // first ID in menu
        for (iScript = 0 ; iScript < piScriptArray->size() ; iScript++, ID ++)
@@ -2602,7 +2586,7 @@ HMENU CMergeEditView::createPrediffersSubmenu(HMENU hMenu)
                if (plugin->m_disabled || plugin->TestAgainstRegList(pd->m_strBothFilenames) != false)
                        continue;
 
-               DoAppendMenu(hMenu, MF_STRING, ID, plugin->m_name.c_str());
+               AppendMenu(hMenu, MF_STRING, ID, plugin->m_name.c_str());
        }
        for (iScript = 0 ; iScript < piScriptArray2->size() ; iScript++, ID ++)
        {
@@ -2610,7 +2594,7 @@ HMENU CMergeEditView::createPrediffersSubmenu(HMENU hMenu)
                if (plugin->m_disabled || plugin->TestAgainstRegList(pd->m_strBothFilenames) != false)
                        continue;
 
-               DoAppendMenu(hMenu, MF_STRING, ID, plugin->m_name.c_str());
+               AppendMenu(hMenu, MF_STRING, ID, plugin->m_name.c_str());
        }
 
        // compute the m_CurrentPredifferID (to set the radio button)
@@ -3791,13 +3775,13 @@ void CMergeEditView::OnUpdateViewChangeScheme(CCmdUI *pCmdUI)
        const HMENU hSubMenu = pCmdUI->m_pSubMenu->m_hMenu;
 
        String name = theApp.LoadString(ID_COLORSCHEME_FIRST);
-       DoAppendMenu(hSubMenu, MF_STRING, ID_COLORSCHEME_FIRST, name.c_str());
-       DoAppendMenu(hSubMenu, MF_SEPARATOR, 0, NULL);
+       AppendMenu(hSubMenu, MF_STRING, ID_COLORSCHEME_FIRST, name.c_str());
+       AppendMenu(hSubMenu, MF_SEPARATOR, 0, NULL);
 
        for (int i = ID_COLORSCHEME_FIRST + 1; i <= ID_COLORSCHEME_LAST; ++i)
        {
                name = theApp.LoadString(i);
-               DoAppendMenu(hSubMenu, MF_STRING, i, name.c_str());
+               AppendMenu(hSubMenu, MF_STRING, i, name.c_str());
        }
 
        pCmdUI->Enable(true);
index 0855e44..111ba64 100644 (file)
@@ -294,7 +294,7 @@ static void CopyFromLMtoCU(HKEY lmKey, HKEY cuKey, LPCTSTR valname)
                        retval = RegQueryValueEx(lmKey, valname, 0, &type, &buf[0], &len);
                        if (retval == ERROR_SUCCESS)
                        {
-                               retval = RegSetValueEx(cuKey, valname , 0, type,
+                               RegSetValueEx(cuKey, valname , 0, type,
                                        &buf[0], len);
                        }
                }
index e985d63..29ecdd5 100644 (file)
@@ -117,14 +117,13 @@ int GetFunctionsFromScript(IDispatch *piDispatch, vector<String>& namesArray, ve
        UINT iValidFunc = 0;
        if (piDispatch)
        {
-               HRESULT hr;
                ITypeInfo *piTypeInfo=0;
                unsigned  iTInfo = 0; // 0 for type information of IDispatch itself
                LCID  lcid=0; // locale for localized method names (ignore if no localized names)
-               if (SUCCEEDED(hr = piDispatch->GetTypeInfo(iTInfo, lcid, &piTypeInfo)))
+               if (SUCCEEDED(piDispatch->GetTypeInfo(iTInfo, lcid, &piTypeInfo)))
                {
                        TYPEATTR *pTypeAttr=0;
-                       if (SUCCEEDED(hr = piTypeInfo->GetTypeAttr(&pTypeAttr)))
+                       if (SUCCEEDED(piTypeInfo->GetTypeAttr(&pTypeAttr)))
                        {
                                // allocate arrays for the returned structures
                                // the names array is NULL terminated
@@ -136,7 +135,7 @@ int GetFunctionsFromScript(IDispatch *piDispatch, vector<String>& namesArray, ve
                                {
                                        UINT iFuncDesc = iMaxFunc - iFunc;
                                        FUNCDESC *pFuncDesc;
-                                       if (SUCCEEDED(hr = piTypeInfo->GetFuncDesc(iFuncDesc, &pFuncDesc)))
+                                       if (SUCCEEDED(piTypeInfo->GetFuncDesc(iFuncDesc, &pFuncDesc)))
                                        {
                                                // exclude properties
                                                // exclude IDispatch inherited methods
@@ -144,7 +143,7 @@ int GetFunctionsFromScript(IDispatch *piDispatch, vector<String>& namesArray, ve
                                                {
                                                        BSTR bstrName;
                                                        UINT cNames;
-                                                       if (SUCCEEDED(hr = piTypeInfo->GetNames(pFuncDesc->memid,
+                                                       if (SUCCEEDED(piTypeInfo->GetNames(pFuncDesc->memid,
                                                                &bstrName, 1, &cNames)))
                                                        {
                                                                IdArray[iValidFunc] = pFuncDesc->memid;
index 3bdfdcf..680cb1a 100644 (file)
@@ -486,7 +486,7 @@ String ExpandShortcut(const String &inFile)
                        {
                                // find the path from that
                                TCHAR buf[MAX_PATH] = {0};
-                               HRESULT hres = psl->GetPath(buf, MAX_PATH, NULL, SLGP_UNCPRIORITY);
+                               psl->GetPath(buf, MAX_PATH, NULL, SLGP_UNCPRIORITY);
                                outFile = buf;
                        }
                        ppf->Release();
index 187f464..bfdef98 100644 (file)
@@ -673,7 +673,7 @@ isWordBreak(int breakType, const TCHAR *str, int index)
 #ifdef _UNICODE
        if ((ch & 0xff00) == 0)
        {
-               TCHAR nextCh = str[index + 1];
+//             TCHAR nextCh = str[index + 1];
                // breakType==0 means whitespace only
                if (!breakType)
                        return false;