From e6a10faab70c073137046d534e710a362eaceaea Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Mar 2015 11:06:54 +0100 Subject: [PATCH] FIxed a few clang warnings. --- common/CMakeLists.txt | 1 - common/gal/graphics_abstraction_layer.cpp | 8 +++--- common/geometry/shape_collisions.cpp | 3 --- common/geometry/shape_index.cpp | 32 ----------------------- common/view/wx_view_controls.cpp | 2 +- include/geometry/seg.h | 2 +- include/geometry/shape_index.h | 9 ------- pcbnew/dialogs/dialog_create_array.cpp | 4 +-- pcbnew/router/length_tuner_tool.cpp | 11 ++++---- pcbnew/router/pns_diff_pair.cpp | 2 +- pcbnew/router/pns_line_placer.h | 14 ---------- pcbnew/router/pns_router.cpp | 9 +++---- pcbnew/router/pns_shove.h | 1 - pcbnew/router/pns_tune_status_popup.cpp | 2 +- pcbnew/router/pns_tune_status_popup.h | 2 +- 15 files changed, 20 insertions(+), 82 deletions(-) delete mode 100644 common/geometry/shape_index.cpp diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 509d99ba14..a42474fe60 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -242,7 +242,6 @@ set( COMMON_SRCS geometry/seg.cpp geometry/shape_line_chain.cpp geometry/shape_collisions.cpp - geometry/shape_index.cpp ) add_library( common STATIC ${COMMON_SRCS} ) add_dependencies( common lib-dependencies ) diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index d21b12b783..0142a36bab 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -157,10 +157,10 @@ void GAL::DrawGrid() assert( gridEndY >= gridStartY ); // Correct the index, else some lines are not correctly painted - gridStartX -= abs( gridOrigin.x / gridSize.x ) + 1; - gridStartY -= abs( gridOrigin.y / gridSize.y ) + 1; - gridEndX += abs( gridOrigin.x / gridSize.x ) + 1; - gridEndY += abs( gridOrigin.y / gridSize.y ) + 1; + gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1; + gridStartY -= std::abs( gridOrigin.y / gridSize.y ) + 1; + gridEndX += std::abs( gridOrigin.x / gridSize.x ) + 1; + gridEndY += std::abs( gridOrigin.y / gridSize.y ) + 1; // Draw the grid behind all other layers SetLayerDepth( depthRange.y * 0.75 ); diff --git a/common/geometry/shape_collisions.cpp b/common/geometry/shape_collisions.cpp index c21ecc6054..f3bac90524 100644 --- a/common/geometry/shape_collisions.cpp +++ b/common/geometry/shape_collisions.cpp @@ -137,12 +137,9 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_LINE_CHAIN& aB, bool aNeedMTV, VECTOR2I& aMTV ) { bool found = false; - VECTOR2I::extended_type clSq = (VECTOR2I::extended_type) aClearance * aClearance; - for( int s = 0; s < aB.SegmentCount(); s++ ) { - if( aA.Collide( aB.CSegment( s ), aClearance ) ) { found = true; diff --git a/common/geometry/shape_index.cpp b/common/geometry/shape_index.cpp deleted file mode 100644 index 0af0e444ab..0000000000 --- a/common/geometry/shape_index.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2013 CERN - * @author Jacobo Aragunde PĂ©rez - * @author Tomasz Wlostowski - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -template <> -const SHAPE* shapeFunctor( SHAPE* aItem ) -{ - return aItem; -} diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 848814e460..e7bce79733 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -138,7 +138,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) ( (double) aEvent.GetWheelRotation() * wheelPanSpeed ); double scrollSpeed; - if( abs( scrollVec.x ) > abs( scrollVec.y ) ) + if( std::abs( scrollVec.x ) > std::abs( scrollVec.y ) ) scrollSpeed = scrollVec.x; else scrollSpeed = scrollVec.y; diff --git a/include/geometry/seg.h b/include/geometry/seg.h index 06adfef52d..164457b93f 100644 --- a/include/geometry/seg.h +++ b/include/geometry/seg.h @@ -344,7 +344,7 @@ inline int SEG::LineDistance( const VECTOR2I& aP, bool aDetermineSide ) const ecoord dist = ( p * aP.x + q * aP.y + r ) / sqrt( p * p + q * q ); - return aDetermineSide ? dist : abs( dist ); + return aDetermineSide ? dist : std::abs( dist ); } inline SEG::ecoord SEG::TCoef( const VECTOR2I& aP ) const diff --git a/include/geometry/shape_index.h b/include/geometry/shape_index.h index 0c5822520f..94703ce903 100644 --- a/include/geometry/shape_index.h +++ b/include/geometry/shape_index.h @@ -46,13 +46,6 @@ static const SHAPE* shapeFunctor( T aItem ) return aItem->Shape(); } - -/** - * shapeFunctor template function: specialization for T = SHAPE* - */ -template <> -const SHAPE* shapeFunctor( SHAPE* aItem ); - /** * boundingBox template method * @@ -68,7 +61,6 @@ BOX2I boundingBox( T aObject ) return shapeFunctor( aObject )->BBox(); } - /** * acceptVisitor template method * @@ -84,7 +76,6 @@ void acceptVisitor( T aObject, V aVisitor ) aVisitor( aObject ); } - /** * collide template method * diff --git a/pcbnew/dialogs/dialog_create_array.cpp b/pcbnew/dialogs/dialog_create_array.cpp index a7d95e38fa..b70ae8c1f2 100644 --- a/pcbnew/dialogs/dialog_create_array.cpp +++ b/pcbnew/dialogs/dialog_create_array.cpp @@ -446,9 +446,9 @@ void DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::TransformItem( int n, BOARD_ITEM* point.x = coords.x * m_delta.x + coords.y * m_offset.x; point.y = coords.y * m_delta.y + coords.x * m_offset.y; - if( abs( m_stagger ) > 1 ) + if( std::abs( m_stagger ) > 1 ) { - const int stagger = abs( m_stagger ); + const int stagger = std::abs( m_stagger ); const bool sr = m_stagger_rows; const int stagger_idx = ( ( sr ? coords.y : coords.x ) % stagger ); diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 792f514429..1e80c20438 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -140,7 +140,7 @@ void LENGTH_TUNER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent ) if( settingsDlg.ShowModal() ) { - placer->UpdateSettings ( settings ); + placer->UpdateSettings( settings ); } m_savedMeanderSettings = placer->MeanderSettings(); @@ -149,12 +149,12 @@ void LENGTH_TUNER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent ) void LENGTH_TUNER_TOOL::updateStatusPopup( PNS_TUNE_STATUS_POPUP& aPopup ) { - wxPoint p = wxGetMousePosition(); + wxPoint p = wxGetMousePosition(); p.x += 20; p.y += 20; - aPopup.Update( m_router ); + aPopup.UpdateStatus( m_router ); aPopup.Move( p ); } @@ -181,7 +181,7 @@ void LENGTH_TUNER_TOOL::performTuning() } PNS_MEANDER_PLACER_BASE* placer = static_cast( m_router->Placer() ); - + placer->UpdateSettings( m_savedMeanderSettings ); VECTOR2I end( m_startSnapPoint ); @@ -192,7 +192,7 @@ void LENGTH_TUNER_TOOL::performTuning() m_router->Move( end, NULL ); updateStatusPopup( statusPopup ); - + while( OPT_TOOL_EVENT evt = Wait() ) { if( evt->IsCancel() || evt->IsActivate() ) @@ -207,7 +207,6 @@ void LENGTH_TUNER_TOOL::performTuning() end = evt->Position(); m_router->Move( end, NULL ); updateStatusPopup( statusPopup ); - } else if( evt->IsClick( BUT_LEFT ) ) { diff --git a/pcbnew/router/pns_diff_pair.cpp b/pcbnew/router/pns_diff_pair.cpp index 2af6f3ee56..1acc0729d8 100644 --- a/pcbnew/router/pns_diff_pair.cpp +++ b/pcbnew/router/pns_diff_pair.cpp @@ -332,7 +332,7 @@ bool PNS_DP_GATEWAYS::FitGateways( PNS_DP_GATEWAYS& aEntry, PNS_DP_GATEWAYS& aTa int bestScore = -1000; DP_CANDIDATE best; - bool found; + bool found = false; BOOST_FOREACH( DP_CANDIDATE c, candidates ) { diff --git a/pcbnew/router/pns_line_placer.h b/pcbnew/router/pns_line_placer.h index cfa6228f66..2b8743a2cd 100644 --- a/pcbnew/router/pns_line_placer.h +++ b/pcbnew/router/pns_line_placer.h @@ -362,9 +362,6 @@ private: ///> routing "tail": part of the track that has been already fixed due to collisions with obstacles PNS_LINE m_tail; - ///> current algorithm iteration - int m_iteration; - ///> pointer to world to search colliding items PNS_NODE* m_world; @@ -385,20 +382,9 @@ private: ///> Are we placing a via? bool m_placingVia; - ///> current via diameter - int m_viaDiameter; - - ///> current via drill - int m_viaDrill; - - ///> current track width - int m_currentWidth; - int m_currentNet; int m_currentLayer; - bool m_startsOnVia; - VECTOR2I m_currentEnd, m_currentStart; PNS_LINE m_currentTrace; diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index d35973c878..16f0657608 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -72,7 +72,7 @@ PNS_PCBNEW_CLEARANCE_FUNC::PNS_PCBNEW_CLEARANCE_FUNC( PNS_ROUTER *aRouter ) : PNS_TOPOLOGY topo( world ); m_clearanceCache.resize( brd->GetNetCount() ); - + for( unsigned int i = 0; i < brd->GetNetCount(); i++ ) { NETINFO_ITEM* ni = brd->FindNet( i ); @@ -84,11 +84,11 @@ PNS_PCBNEW_CLEARANCE_FUNC::PNS_PCBNEW_CLEARANCE_FUNC( PNS_ROUTER *aRouter ) : wxString netClassName = ni->GetClassName(); NETCLASSPTR nc = brd->GetDesignSettings().m_NetClasses.Find( netClassName ); - + int clearance = nc->GetClearance(); ent.clearance = clearance; m_clearanceCache[i] = ent; - + TRACE( 1, "Add net %d netclass %s clearance %d", i % netClassName.mb_str() % clearance ); } @@ -333,7 +333,6 @@ void PNS_ROUTER::SyncWorld() m_world->SetClearanceFunctor( m_clearanceFunc ); m_world->SetMaxClearance( 4 * worstClearance ); } - PNS_ROUTER::PNS_ROUTER() @@ -947,7 +946,7 @@ void PNS_ROUTER::DumpLog() bool PNS_ROUTER::IsPlacingVia() const { if( !m_placer ) - return NULL; + return false; return m_placer->IsPlacingVia(); } diff --git a/pcbnew/router/pns_shove.h b/pcbnew/router/pns_shove.h index cf8ae3f383..d6e79cd29d 100644 --- a/pcbnew/router/pns_shove.h +++ b/pcbnew/router/pns_shove.h @@ -161,7 +161,6 @@ private: int m_iter; int m_forceClearance; bool m_multiLineMode; - bool m_headModified; }; #endif // __PNS_SHOVE_H diff --git a/pcbnew/router/pns_tune_status_popup.cpp b/pcbnew/router/pns_tune_status_popup.cpp index a1e8b82734..4b4fd54827 100644 --- a/pcbnew/router/pns_tune_status_popup.cpp +++ b/pcbnew/router/pns_tune_status_popup.cpp @@ -36,7 +36,7 @@ PNS_TUNE_STATUS_POPUP::~PNS_TUNE_STATUS_POPUP() } -void PNS_TUNE_STATUS_POPUP::Update( PNS_ROUTER* aRouter ) +void PNS_TUNE_STATUS_POPUP::UpdateStatus( PNS_ROUTER* aRouter ) { PNS_MEANDER_PLACER_BASE* placer = dynamic_cast( aRouter->Placer() ); diff --git a/pcbnew/router/pns_tune_status_popup.h b/pcbnew/router/pns_tune_status_popup.h index 3776882ad0..c6fe469fcd 100644 --- a/pcbnew/router/pns_tune_status_popup.h +++ b/pcbnew/router/pns_tune_status_popup.h @@ -35,7 +35,7 @@ public: PNS_TUNE_STATUS_POPUP( PCB_EDIT_FRAME* aParent ); ~PNS_TUNE_STATUS_POPUP(); - void Update( PNS_ROUTER* aRouter ); + void UpdateStatus( PNS_ROUTER* aRouter ); private: wxStaticText* m_statusLine;