OSDN Git Service

Cppcheck: C-style pointer casting
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 31 Jan 2016 00:38:08 +0000 (09:38 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 31 Jan 2016 00:38:08 +0000 (09:38 +0900)
12 files changed:
Src/ChildFrm.cpp
Src/DiffItem.cpp
Src/DiffItemList.cpp
Src/DirView.cpp
Src/DirView.h
Src/HexMergeFrm.cpp
Src/LocationView.h
Src/MainFrm.cpp
Src/MergeEditView.cpp
Src/MergeEditView.h
Src/OpenView.cpp
Src/SourceControl.cpp

index 14c8be8..e09e776 100644 (file)
@@ -221,7 +221,7 @@ BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
        CMergeEditView * pView[3];
        for (pane = 0; pane < pDoc->m_nBuffers; pane++)
        {
-               pView[pane] = (CMergeEditView *)m_wndSplitter.GetPane(SWAPPARAMS_IF(bSplitVert, 0, pane));
+               pView[pane] = static_cast<CMergeEditView *>(m_wndSplitter.GetPane(SWAPPARAMS_IF(bSplitVert, 0, pane)));
                // connect merge views up to display of status info
                pView[pane]->SetStatusInterface(&m_status[pane]);
                pView[pane]->m_nThisPane = pane;
@@ -234,7 +234,7 @@ BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
        CMergeEditView * pDetail[3];
        for (pane = 0; pane < pDoc->m_nBuffers; pane++)
        {
-               pDetail[pane] = (CMergeEditView *)m_wndDetailSplitter.GetPane(SWAPPARAMS_IF(bSplitVert, pane, 0));
+               pDetail[pane] = static_cast<CMergeEditView *>(m_wndDetailSplitter.GetPane(SWAPPARAMS_IF(bSplitVert, pane, 0)));
                pDetail[pane]->m_nThisPane = pane;
        }
        // tell merge doc about these views
@@ -243,7 +243,7 @@ BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
        m_wndFilePathBar.SetPaneCount(pDoc->m_nBuffers);
        
        // Set frame window handles so we can post stage changes back
-       ((CLocationView *)pWnd)->SetFrameHwnd(GetSafeHwnd());
+       static_cast<CLocationView *>(pWnd)->SetFrameHwnd(GetSafeHwnd());
        m_wndLocationBar.SetFrameHwnd(GetSafeHwnd());
        m_wndDetailBar.SetFrameHwnd(GetSafeHwnd());
 
index 0acdcbd..6d63ed4 100644 (file)
@@ -52,7 +52,7 @@ bool DIFFITEM::IsAncestor(const DIFFITEM *pdi) const
 /** @brief Return whether the current item has children */
 bool DIFFITEM::HasChildren() const
 {
-       DIFFITEM *p = (DIFFITEM *)children.IsSibling(children.Flink);
+       DIFFITEM *p = static_cast<DIFFITEM *>(children.IsSibling(children.Flink));
        return p ? true : false;
 }
 
@@ -60,7 +60,7 @@ void DIFFITEM::RemoveChildren()
 {
        while (HasChildren())
        {
-               DIFFITEM *p = (DIFFITEM *)children.Flink;
+               DIFFITEM *p = static_cast<DIFFITEM *>(children.Flink);
                p->RemoveSelf();
                delete p;
        }
index f30a568..c755cb1 100644 (file)
@@ -44,7 +44,7 @@ DIFFITEM* DiffItemList::AddDiff(DIFFITEM *parent)
  */
 void DiffItemList::RemoveDiff(uintptr_t diffpos)
 {
-       DIFFITEM *p = (DIFFITEM *)diffpos;
+       DIFFITEM *p = reinterpret_cast<DIFFITEM *>(diffpos);
        p->RemoveSelf();
        delete p;
 }
@@ -73,7 +73,7 @@ uintptr_t DiffItemList::GetFirstDiffPosition() const
  */
 uintptr_t DiffItemList::GetFirstChildDiffPosition(uintptr_t parentdiffpos) const
 {
-       DIFFITEM *parent = (DIFFITEM *)parentdiffpos;
+       DIFFITEM *parent = reinterpret_cast<DIFFITEM *>(parentdiffpos);
        if (parent)
                return (uintptr_t)parent->children.IsSibling(parent->children.Flink);
        else
@@ -87,7 +87,7 @@ uintptr_t DiffItemList::GetFirstChildDiffPosition(uintptr_t parentdiffpos) const
  */
 const DIFFITEM &DiffItemList::GetNextDiffPosition(uintptr_t & diffpos) const
 {
-       DIFFITEM *p = (DIFFITEM *)diffpos;
+       DIFFITEM *p = reinterpret_cast<DIFFITEM *>(diffpos);
        if (p->HasChildren())
        {
                diffpos = GetFirstChildDiffPosition(diffpos);
@@ -124,7 +124,7 @@ DIFFITEM &DiffItemList::GetNextDiffRefPosition(uintptr_t & diffpos)
  */
 const DIFFITEM &DiffItemList::GetNextSiblingDiffPosition(uintptr_t & diffpos) const
 {
-       DIFFITEM *p = (DIFFITEM *)diffpos;
+       DIFFITEM *p = reinterpret_cast<DIFFITEM *>(diffpos);
        if (p->parent)
                diffpos = (uintptr_t)p->parent->children.IsSibling(p->Flink);
        else
index 73bd15b..652954f 100644 (file)
@@ -664,7 +664,7 @@ void CDirView::ListContextMenu(CPoint point, int /*i*/)
        theApp.TranslateMenu(menu.m_hMenu);
 
        // 1st submenu of IDR_POPUP_DIRVIEW is for item popup
-       BCMenu *pPopup = (BCMenu*) menu.GetSubMenu(0);
+       BCMenu *pPopup = static_cast<BCMenu*>(menu.GetSubMenu(0));
        ASSERT(pPopup != NULL);
 
        if (pDoc->m_nDirs < 3)
@@ -732,7 +732,7 @@ void CDirView::HeaderContextMenu(CPoint point, int /*i*/)
        VERIFY(menu.LoadToolbar(IDR_MAINFRAME));
        theApp.TranslateMenu(menu.m_hMenu);
        // 2nd submenu of IDR_POPUP_DIRVIEW is for header popup
-       BCMenu* pPopup = (BCMenu *)menu.GetSubMenu(1);
+       BCMenu* pPopup = static_cast<BCMenu *>(menu.GetSubMenu(1));
        ASSERT(pPopup != NULL);
 
        // invoke context menu
@@ -1945,7 +1945,7 @@ CDirFrame * CDirView::GetParentFrame()
 {
        // can't verify cast without introducing more coupling
        // (CDirView doesn't include DirFrame.h)
-       return (CDirFrame *)CListView::GetParentFrame();
+       return static_cast<CDirFrame *>(CListView::GetParentFrame());
 }
 
 void CDirView::OnRefresh()
@@ -2641,7 +2641,7 @@ void CDirView::OnUpdatePluginPredifferMode(CCmdUI* pCmdUI)
 
        pCmdUI->Enable(GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED));
 
-       BCMenu *pPopup = (BCMenu*) pCmdUI->m_pSubMenu;
+       BCMenu *pPopup = static_cast<BCMenu*>(pCmdUI->m_pSubMenu);
        if (pPopup == NULL)
                return;
 
index b2521bc..a3dc599 100644 (file)
@@ -410,7 +410,7 @@ public:
 
 #ifndef _DEBUG  // debug version in DirView.cpp
 inline CDirDoc* CDirView::GetDocument()
-{ return (CDirDoc*)m_pDocument; }
+{ return reinterpret_cast<CDirDoc*>(m_pDocument); }
 #endif
 
 
index 6165582..8450cd4 100644 (file)
@@ -354,7 +354,7 @@ void CHexMergeFrame::OnIdleUpdateCmdUI()
                int nColumns = m_wndSplitter.GetColumnCount();
                CHexMergeView *pView[3] = {0};
                for (pane = 0; pane < nColumns; ++pane)
-                       pView[pane] = (CHexMergeView *)m_wndSplitter.GetPane(0, pane);
+                       pView[pane] = static_cast<CHexMergeView *>(m_wndSplitter.GetPane(0, pane));
 
                // Update mod indicators
                TCHAR ind[2];
index ee3bb85..a7c0ea9 100644 (file)
@@ -135,7 +135,7 @@ protected:
 
 #ifndef _DEBUG  // debug version in DiffView.cpp
 inline CMergeDoc* CLocationView::GetDocument()
-   { return (CMergeDoc*)m_pDocument; }
+   { return reinterpret_cast<CMergeDoc*>(m_pDocument); }
 #endif
 
 /////////////////////////////////////////////////////////////////////////////
index fc0590d..b5af728 100644 (file)
@@ -948,7 +948,7 @@ BOOL CMainFrame::DoFileOpen(const PathContext * pFiles /*=NULL*/,
        {
                if (!m_pMenus[MENU_OPENVIEW])
                        theApp.m_pOpenTemplate->m_hMenuShared = NewOpenViewMenu();
-               COpenDoc *pOpenDoc = (COpenDoc *)theApp.m_pOpenTemplate->CreateNewDocument();
+               COpenDoc *pOpenDoc = static_cast<COpenDoc *>(theApp.m_pOpenTemplate->CreateNewDocument());
                if (dwFlags)
                {
                        pOpenDoc->m_dwFlags[0] = dwFlags[0];
@@ -1009,11 +1009,11 @@ BOOL CMainFrame::DoFileOpen(const PathContext * pFiles /*=NULL*/,
                        CDirDoc::m_nDirsTemp = files.GetSize();
                        if (!m_pMenus[MENU_DIRVIEW])
                                theApp.m_pDirTemplate->m_hMenuShared = NewDirViewMenu();
-                       pDirDoc = (CDirDoc*)theApp.m_pDirTemplate->OpenDocumentFile(NULL);
+                       pDirDoc = static_cast<CDirDoc*>(theApp.m_pDirTemplate->OpenDocumentFile(NULL));
                }
                else
                {
-                       pDirDoc = (CDirDoc*)theApp.m_pDirTemplate->CreateNewDocument();
+                       pDirDoc = static_cast<CDirDoc*>(theApp.m_pDirTemplate->CreateNewDocument());
                }
        }
 
@@ -1371,7 +1371,7 @@ DocClass * GetMergeDocForDiff(CMultiDocTemplate *pTemplate, CDirDoc *pDirDoc, in
 {
        // Create a new merge doc
        DocClass::m_nBuffersTemp = nFiles;
-       DocClass *pMergeDoc = (DocClass*)pTemplate->OpenDocumentFile(NULL);
+       DocClass *pMergeDoc = static_cast<DocClass*>(pTemplate->OpenDocumentFile(NULL));
        if (pMergeDoc)
        {
                pDirDoc->AddMergeDoc(pMergeDoc);
@@ -1411,7 +1411,7 @@ void CMainFrame::OnToolsGeneratePatch()
        // Mergedoc active?
        if (frame == FRAME_FILE)
        {
-               CMergeDoc * pMergeDoc = (CMergeDoc *) pFrame->GetActiveDocument();
+               CMergeDoc * pMergeDoc = static_cast<CMergeDoc *>(pFrame->GetActiveDocument());
                // If there are changes in files, tell user to save them first
                BOOL bModified = FALSE;
                for (int pane = 0; pane < pMergeDoc->m_nBuffers; pane++)
@@ -1433,7 +1433,7 @@ void CMainFrame::OnToolsGeneratePatch()
        // Dirview active
        else if (frame == FRAME_FOLDER)
        {
-               CDirDoc * pDoc = (CDirDoc*)pFrame->GetActiveDocument();
+               CDirDoc * pDoc = static_cast<CDirDoc*>(pFrame->GetActiveDocument());
                const CDiffContext& ctxt = pDoc->GetDiffContext();
                CDirView *pView = pDoc->GetMainView();
 
@@ -1676,7 +1676,7 @@ void CMainFrame::OnSaveConfigData()
  */
 void CMainFrame::FileNew(int nPanes) 
 {
-       CDirDoc *pDirDoc = (CDirDoc*)theApp.m_pDirTemplate->CreateNewDocument();
+       CDirDoc *pDirDoc = static_cast<CDirDoc*>(theApp.m_pDirTemplate->CreateNewDocument());
        
        // Load emptyfile descriptors and open empty docs
        // Use default codepage
@@ -2075,7 +2075,7 @@ void CMainFrame::OnSaveProject()
 
        if (frame == FRAME_FILE)
        {
-               CMergeDoc * pMergeDoc = (CMergeDoc *) pFrame->GetActiveDocument();
+               CMergeDoc * pMergeDoc = static_cast<CMergeDoc *>(pFrame->GetActiveDocument());
                left = pMergeDoc->m_filePaths.GetLeft();
                right = pMergeDoc->m_filePaths.GetRight();
                pathsDlg.SetPaths(left, right);
@@ -2085,7 +2085,7 @@ void CMainFrame::OnSaveProject()
        else if (frame == FRAME_FOLDER)
        {
                // Get paths currently in compare
-               const CDirDoc * pDoc = (const CDirDoc*)pFrame->GetActiveDocument();
+               const CDirDoc * pDoc = static_cast<const CDirDoc*>(pFrame->GetActiveDocument());
                const CDiffContext& ctxt = pDoc->GetDiffContext();
                left = paths_AddTrailingSlash(ctxt.GetNormalizedLeft());
                right = paths_AddTrailingSlash(ctxt.GetNormalizedRight());
index 05517f4..1e9638b 100644 (file)
@@ -2667,7 +2667,7 @@ void CMergeEditView::OnContextMenu(CWnd* pWnd, CPoint point)
        VERIFY(menu.LoadToolbar(IDR_MAINFRAME));
        theApp.TranslateMenu(menu.m_hMenu);
 
-       BCMenu *pSub = (BCMenu *)menu.GetSubMenu(0);
+       BCMenu *pSub = static_cast<BCMenu *>(menu.GetSubMenu(0));
        ASSERT(pSub != NULL);
 
        // Context menu opened using keyboard has no coordinates
@@ -3461,7 +3461,7 @@ void CMergeEditView::OnSize(UINT nType, int cx, int cy)
 */
 void CMergeEditView::OnBeginPrinting(CDC * pDC, CPrintInfo * pInfo)
 {
-       ((CChildFrame *)GetParentFrame())->PostMessage(WM_TIMER);
+       GetParentFrame()->PostMessage(WM_TIMER);
 
        for (int pane = 0; pane < GetDocument()->m_nBuffers; pane++)
        {
@@ -3482,7 +3482,7 @@ void CMergeEditView::OnEndPrinting(CDC * pDC, CPrintInfo * pInfo)
        for (int pane = 0; pane < GetDocument()->m_nBuffers; pane++)
                GetDocument()->GetView(pane)->CGhostTextView::OnEndPrinting(pDC, pInfo);
 
-       ((CChildFrame *)GetParentFrame())->PostMessage(WM_TIMER);
+       GetParentFrame()->PostMessage(WM_TIMER);
 }
 
 /**
index 6caa3fb..6d9454b 100644 (file)
@@ -348,7 +348,7 @@ protected:
 
 #ifndef _DEBUG  // debug version in DiffView.cpp
 inline CMergeDoc* CMergeEditView::GetDocument()
-   { return (CMergeDoc*)m_pDocument; }
+   { return reinterpret_cast<CMergeDoc*>(m_pDocument); }
 #endif
 
 /////////////////////////////////////////////////////////////////////////////
index 069cab5..a12b15c 100644 (file)
@@ -603,7 +603,7 @@ static UINT UpdateButtonStatesThread(LPVOID lpParam)
                int iStatusMsgId;
                int iUnpackerStatusMsgId;
 
-               UpdateButtonStatesThreadParams *pParams = (UpdateButtonStatesThreadParams *)msg.wParam;
+               UpdateButtonStatesThreadParams *pParams = reinterpret_cast<UpdateButtonStatesThreadParams *>(msg.wParam);
                PathContext paths = pParams->m_paths;
                HWND hWnd = pParams->m_hWnd;
                delete pParams;
index 4bba2cf..9d1059b 100644 (file)
@@ -76,6 +76,7 @@ SourceControl::SourceControl() :
   m_CheckOutMulti(false)
 , m_bVCProjSync(false)
 , m_bVssSuppressPathCheck(false)
+, m_bCheckinVCS(false)
 {
 }