From: Takashi Sawanaka Date: Sun, 31 Jan 2016 00:38:08 +0000 (+0900) Subject: Cppcheck: C-style pointer casting X-Git-Tag: 2.16.4+-jp-10~786 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1ec7a254d16f97874dd7eff5cfd402b620f6602d;p=winmerge-jp%2Fwinmerge-jp.git Cppcheck: C-style pointer casting --- diff --git a/Src/ChildFrm.cpp b/Src/ChildFrm.cpp index 14c8be8ac..e09e77659 100644 --- a/Src/ChildFrm.cpp +++ b/Src/ChildFrm.cpp @@ -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(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(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(pWnd)->SetFrameHwnd(GetSafeHwnd()); m_wndLocationBar.SetFrameHwnd(GetSafeHwnd()); m_wndDetailBar.SetFrameHwnd(GetSafeHwnd()); diff --git a/Src/DiffItem.cpp b/Src/DiffItem.cpp index 0acdcbdf8..6d63ed495 100644 --- a/Src/DiffItem.cpp +++ b/Src/DiffItem.cpp @@ -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(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(children.Flink); p->RemoveSelf(); delete p; } diff --git a/Src/DiffItemList.cpp b/Src/DiffItemList.cpp index f30a568c3..c755cb1a4 100644 --- a/Src/DiffItemList.cpp +++ b/Src/DiffItemList.cpp @@ -44,7 +44,7 @@ DIFFITEM* DiffItemList::AddDiff(DIFFITEM *parent) */ void DiffItemList::RemoveDiff(uintptr_t diffpos) { - DIFFITEM *p = (DIFFITEM *)diffpos; + DIFFITEM *p = reinterpret_cast(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(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(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(diffpos); if (p->parent) diffpos = (uintptr_t)p->parent->children.IsSibling(p->Flink); else diff --git a/Src/DirView.cpp b/Src/DirView.cpp index 73bd15bd9..652954f0f 100644 --- a/Src/DirView.cpp +++ b/Src/DirView.cpp @@ -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(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(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(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(pCmdUI->m_pSubMenu); if (pPopup == NULL) return; diff --git a/Src/DirView.h b/Src/DirView.h index b2521bcb8..a3dc599fb 100644 --- a/Src/DirView.h +++ b/Src/DirView.h @@ -410,7 +410,7 @@ public: #ifndef _DEBUG // debug version in DirView.cpp inline CDirDoc* CDirView::GetDocument() -{ return (CDirDoc*)m_pDocument; } +{ return reinterpret_cast(m_pDocument); } #endif diff --git a/Src/HexMergeFrm.cpp b/Src/HexMergeFrm.cpp index 61655825a..8450cd4bc 100644 --- a/Src/HexMergeFrm.cpp +++ b/Src/HexMergeFrm.cpp @@ -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(m_wndSplitter.GetPane(0, pane)); // Update mod indicators TCHAR ind[2]; diff --git a/Src/LocationView.h b/Src/LocationView.h index ee3bb8531..a7c0ea9b0 100644 --- a/Src/LocationView.h +++ b/Src/LocationView.h @@ -135,7 +135,7 @@ protected: #ifndef _DEBUG // debug version in DiffView.cpp inline CMergeDoc* CLocationView::GetDocument() - { return (CMergeDoc*)m_pDocument; } + { return reinterpret_cast(m_pDocument); } #endif ///////////////////////////////////////////////////////////////////////////// diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index fc0590dc5..b5af728cb 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -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(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(theApp.m_pDirTemplate->OpenDocumentFile(NULL)); } else { - pDirDoc = (CDirDoc*)theApp.m_pDirTemplate->CreateNewDocument(); + pDirDoc = static_cast(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(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(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(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(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(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(pFrame->GetActiveDocument()); const CDiffContext& ctxt = pDoc->GetDiffContext(); left = paths_AddTrailingSlash(ctxt.GetNormalizedLeft()); right = paths_AddTrailingSlash(ctxt.GetNormalizedRight()); diff --git a/Src/MergeEditView.cpp b/Src/MergeEditView.cpp index 05517f451..1e9638beb 100644 --- a/Src/MergeEditView.cpp +++ b/Src/MergeEditView.cpp @@ -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(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); } /** diff --git a/Src/MergeEditView.h b/Src/MergeEditView.h index 6caa3fb54..6d9454b6a 100644 --- a/Src/MergeEditView.h +++ b/Src/MergeEditView.h @@ -348,7 +348,7 @@ protected: #ifndef _DEBUG // debug version in DiffView.cpp inline CMergeDoc* CMergeEditView::GetDocument() - { return (CMergeDoc*)m_pDocument; } + { return reinterpret_cast(m_pDocument); } #endif ///////////////////////////////////////////////////////////////////////////// diff --git a/Src/OpenView.cpp b/Src/OpenView.cpp index 069cab500..a12b15c13 100644 --- a/Src/OpenView.cpp +++ b/Src/OpenView.cpp @@ -603,7 +603,7 @@ static UINT UpdateButtonStatesThread(LPVOID lpParam) int iStatusMsgId; int iUnpackerStatusMsgId; - UpdateButtonStatesThreadParams *pParams = (UpdateButtonStatesThreadParams *)msg.wParam; + UpdateButtonStatesThreadParams *pParams = reinterpret_cast(msg.wParam); PathContext paths = pParams->m_paths; HWND hWnd = pParams->m_hWnd; delete pParams; diff --git a/Src/SourceControl.cpp b/Src/SourceControl.cpp index 4bba2cf78..9d1059b74 100644 --- a/Src/SourceControl.cpp +++ b/Src/SourceControl.cpp @@ -76,6 +76,7 @@ SourceControl::SourceControl() : m_CheckOutMulti(false) , m_bVCProjSync(false) , m_bVssSuppressPathCheck(false) +, m_bCheckinVCS(false) { }