From b6c5b291a23e90e63ffab5f4cfddc23c70ccc030 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 11 Mar 2015 14:17:43 +0100 Subject: [PATCH] Coverity fixes. --- common/gal/opengl/gpu_manager.cpp | 6 +++--- common/geometry/seg.cpp | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 4 ++-- pcbnew/tools/selection_tool.cpp | 12 +++++++++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/gal/opengl/gpu_manager.cpp b/common/gal/opengl/gpu_manager.cpp index 36d66a0f60..85aa4cdb3f 100644 --- a/common/gal/opengl/gpu_manager.cpp +++ b/common/gal/opengl/gpu_manager.cpp @@ -55,7 +55,7 @@ GPU_MANAGER* GPU_MANAGER::MakeManager( VERTEX_CONTAINER* aContainer ) GPU_MANAGER::GPU_MANAGER( VERTEX_CONTAINER* aContainer ) : - m_isDrawing( false ), m_container( aContainer ), m_shader( NULL ) + m_isDrawing( false ), m_container( aContainer ), m_shader( NULL ), m_shaderAttrib( 0 ) { } @@ -80,8 +80,8 @@ void GPU_MANAGER::SetShader( SHADER& aShader ) // Cached manager GPU_CACHED_MANAGER::GPU_CACHED_MANAGER( VERTEX_CONTAINER* aContainer ) : - GPU_MANAGER( aContainer ), m_buffersInitialized( false ), - m_indicesSize( 0 ) + GPU_MANAGER( aContainer ), m_buffersInitialized( false ), m_indicesPtr( NULL ), + m_verticesBuffer( 0 ), m_indicesBuffer( 0 ), m_indicesSize( 0 ) { // Allocate the biggest possible buffer for indices m_indices.reset( new GLuint[aContainer->GetSize()] ); diff --git a/common/geometry/seg.cpp b/common/geometry/seg.cpp index 2cf5cf4365..f1796b64cf 100644 --- a/common/geometry/seg.cpp +++ b/common/geometry/seg.cpp @@ -52,7 +52,7 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int aDist ) const int cb = sgn( d.x ); int cc = -ca * A.x - cb * A.y; - ecoord num = ca * aP.x + cb * aP.y + cc; + ecoord num = (ecoord) ca * aP.x + (ecoord) cb * aP.y + cc; num *= num; if( ca && cb ) diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 48426322a6..2cbc4cb4b4 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -930,11 +930,11 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) { const NETINFO_ITEM* netinfo = m_board->FindNet( padNetname ); - if( !padNetname.IsEmpty() && netinfo == NULL ) + if( !padNetname.IsEmpty() && netinfo == NULL ) { DisplayError( NULL, _( "Unknown netname, netname not changed" ) ); } - else + else if( netinfo ) { rastnestIsChanged = true; m_currentPad->SetNetCode( netinfo->GetNet() ); diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index c77ec32539..88070c2ed3 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -1302,8 +1302,18 @@ void SELECTION_TOOL::generateMenu() // Filter out entries that does not apply to the current selection for( int i = m_menuCopy.GetMenuItemCount() - 1; i >= 0; --i ) { - if( !m_menuConditions[i]( m_selection ) ) + try { + if( !m_menuConditions[i]( m_selection ) ) + { + wxMenuItem* item = m_menuCopy.FindItemByPosition( i ); + m_menuCopy.Destroy( item ); + } + } + catch( boost::bad_function_call ) + { + // If it is not possible to determine if a menu entry should be + // shown or not - do not let users pick non-existing options wxMenuItem* item = m_menuCopy.FindItemByPosition( i ); m_menuCopy.Destroy( item ); }