Coverity cleanup and remove unused variables

This commit is contained in:
Ian McInerney 2020-09-20 02:20:41 +01:00
parent 65bd1ee9a4
commit 89dcc46898
11 changed files with 57 additions and 45 deletions

View File

@ -264,20 +264,18 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
{ {
KIGFX::VIEW* view = getView(); KIGFX::VIEW* view = getView();
EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas(); EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas();
EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>(); EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
BOX2I bBox = frame->GetDocumentExtents(); BOX2I bBox = frame->GetDocumentExtents();
BOX2I defaultBox = canvas->GetDefaultViewBBox(); BOX2I defaultBox = canvas->GetDefaultViewBBox();
VECTOR2D scrollbarSize = VECTOR2D( canvas->GetSize() - canvas->GetClientSize() );
view->SetScale( 1.0 ); // The best scale will be determined later, but this initial view->SetScale( 1.0 ); // The best scale will be determined later, but this initial
// value ensures all view parameters are up to date (especially // value ensures all view parameters are up to date (especially
// at init time) // at init time)
VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false ); VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
// Currently "Zoom to Objects" is only supported on Eeschema. Support for other // Currently "Zoom to Objects" is only supported on Eeschema. Support for other
// programs in the suite can be added as needed. // programs in the suite can be added as needed.
if( aFitType == ZOOM_FIT_OBJECTS ) if( aFitType == ZOOM_FIT_OBJECTS )
{ {
if( frame->IsType( FRAME_SCH ) ) if( frame->IsType( FRAME_SCH ) )
@ -287,7 +285,6 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
} }
// If the screen is empty then use the default view bbox // If the screen is empty then use the default view bbox
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 ) if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
bBox = defaultBox; bBox = defaultBox;
@ -302,7 +299,6 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
{ {
case ZOOM_FIT_ALL: case ZOOM_FIT_ALL:
// Leave a bigger margin for library editors & viewers // Leave a bigger margin for library editors & viewers
if( frame->IsType( FRAME_FOOTPRINT_VIEWER ) || frame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL ) if( frame->IsType( FRAME_FOOTPRINT_VIEWER ) || frame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL )
|| frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) ) || frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
{ {

View File

@ -343,7 +343,7 @@ int ERC_TESTER::TestMultiunitFootprints()
const wxString secondFp = secondRef.GetFootprint(); const wxString secondFp = secondRef.GetFootprint();
wxString msg; wxString msg;
if( !secondFp.IsEmpty() && unitFP != secondFp ) if( unit && !secondFp.IsEmpty() && unitFP != secondFp )
{ {
msg.Printf( _( "Different footprints assigned to %s and %s" ), msg.Printf( _( "Different footprints assigned to %s and %s" ),
unitName, secondName ); unitName, secondName );

View File

@ -2117,7 +2117,7 @@ wxString BOARD::GroupsSanityCheckInternal( bool repair )
// This check of childIdx should never fail, because if a group // This check of childIdx should never fail, because if a group
// is not found in the groups list, then the board.GetItem() // is not found in the groups list, then the board.GetItem()
// check above should have failed. // check above should have failed.
wxCHECK( childIdx >= 0 && childIdx < groups.size(), wxCHECK( childIdx < groups.size(),
wxString::Format( "Group %s not found in groups list", wxString::Format( "Group %s not found in groups list",
item->m_Uuid.AsString() ) ); item->m_Uuid.AsString() ) );
wxCHECK( parentGroupIdx[childIdx] == -1, wxCHECK( parentGroupIdx[childIdx] == -1,

View File

@ -671,7 +671,6 @@ void VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
wxString msg; wxString msg;
wxString msg2; wxString msg2;
wxString source; wxString source;
BOARD* board = GetBoard();
// Display basic infos // Display basic infos
switch( GetViaType() ) switch( GetViaType() )

View File

@ -402,12 +402,15 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
{ {
MARKER_PCB* marker = dynamic_cast<MARKER_PCB*>( node->m_RcItem->GetParent() ); MARKER_PCB* marker = dynamic_cast<MARKER_PCB*>( node->m_RcItem->GetParent() );
marker->SetExcluded( false ); if( marker )
m_brdEditor->GetCanvas()->GetView()->Update( marker ); {
marker->SetExcluded( false );
m_brdEditor->GetCanvas()->GetView()->Update( marker );
// Update view // Update view
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node ); static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
modified = true; modified = true;
}
} }
break; break;
@ -415,16 +418,19 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
{ {
MARKER_PCB* marker = dynamic_cast<MARKER_PCB*>( node->m_RcItem->GetParent() ); MARKER_PCB* marker = dynamic_cast<MARKER_PCB*>( node->m_RcItem->GetParent() );
marker->SetExcluded( true ); if( marker )
m_brdEditor->GetCanvas()->GetView()->Update( marker ); {
marker->SetExcluded( true );
m_brdEditor->GetCanvas()->GetView()->Update( marker );
// Update view // Update view
if( m_severities & RPT_SEVERITY_EXCLUSION ) if( m_severities & RPT_SEVERITY_EXCLUSION )
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node ); static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
else else
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem( false ); static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem( false );
modified = true; modified = true;
}
} }
break; break;

View File

@ -554,7 +554,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
// Unfortunately implicit rules don't work for local clearances (such as zones) because // Unfortunately implicit rules don't work for local clearances (such as zones) because
// they have to be max'ed with netclass values (which are already implicit rules), and our // they have to be max'ed with netclass values (which are already implicit rules), and our
// rule selection paradigm is "winner takes all". // rule selection paradigm is "winner takes all".
if( aConstraintId == DRC_CONSTRAINT_TYPE_CLEARANCE && implicit ) if( constraintRef && aConstraintId == DRC_CONSTRAINT_TYPE_CLEARANCE && implicit )
{ {
int global = constraintRef->m_Value.Min(); int global = constraintRef->m_Value.Min();
int localA = connectedA ? connectedA->GetLocalClearance( nullptr ) : 0; int localA = connectedA ? connectedA->GetLocalClearance( nullptr ) : 0;

View File

@ -532,7 +532,10 @@ int CONVERT_TOOL::SegmentToArc( const TOOL_EVENT& aEvent )
BOARD_ITEM_CONTAINER* parent = frame->GetModel(); BOARD_ITEM_CONTAINER* parent = frame->GetModel();
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( source ); BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( source );
wxASSERT( boardItem );
// Don't continue processing if we don't actually have a board item
if( !boardItem )
return 0;
PCB_LAYER_ID layer = boardItem->GetLayer(); PCB_LAYER_ID layer = boardItem->GetLayer();

View File

@ -208,7 +208,8 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aTestTracksA
m_drcEngine->SetProgressReporter( nullptr ); m_drcEngine->SetProgressReporter( nullptr );
m_drcEngine->ClearViolationHandler(); m_drcEngine->ClearViolationHandler();
m_drcDialog->SetDrcRun(); if( m_drcDialog )
m_drcDialog->SetDrcRun();
if( !netlist.IsEmpty() ) if( !netlist.IsEmpty() )
m_drcDialog->SetFootprintTestsRun(); m_drcDialog->SetFootprintTestsRun();

View File

@ -294,10 +294,9 @@ int PCB_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
r->Report( _( "Items belong to the same net. Clearance is 0." ) ); r->Report( _( "Items belong to the same net. Clearance is 0." ) );
} }
} }
else else if( ac )
{ {
// Different nets (or second unconnected).... // Different nets (or second unconnected)....
reportCopperClearance( layer, ac, b, r ); reportCopperClearance( layer, ac, b, r );
} }
} }

View File

@ -2173,7 +2173,7 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent )
m_lastSelectedUserPreset = ( !preset || preset->readOnly ) ? nullptr : preset; m_lastSelectedUserPreset = ( !preset || preset->readOnly ) ? nullptr : preset;
if( !preset ) if( preset )
doApplyLayerPreset( *preset ); doApplyLayerPreset( *preset );
if( !m_currentPreset->name.IsEmpty() ) if( !m_currentPreset->name.IsEmpty() )

View File

@ -161,27 +161,35 @@ public:
APPEARANCE_SETTING( const wxString& aLabel, int aId, APPEARANCE_SETTING( const wxString& aLabel, int aId,
const wxString& aTooltip = wxEmptyString, const wxString& aTooltip = wxEmptyString,
bool aCanControlOpacity = false ) bool aCanControlOpacity = false ) :
id( aId ),
label( aLabel ),
tooltip( aTooltip ),
visible( true ),
can_control_opacity( aCanControlOpacity ),
spacer( false ),
ctl_panel( nullptr ),
ctl_indicator( nullptr ),
ctl_visibility( nullptr ),
ctl_color( nullptr ),
ctl_text( nullptr ),
ctl_opacity( nullptr )
{ {
label = aLabel;
id = aId;
tooltip = aTooltip;
spacer = false;
visible = true;
can_control_opacity = aCanControlOpacity;
ctl_panel = nullptr;
ctl_indicator = nullptr;
ctl_visibility = nullptr;
ctl_color = nullptr;
ctl_text = nullptr;
ctl_opacity = nullptr;
} }
APPEARANCE_SETTING() : APPEARANCE_SETTING() :
id( -1 ), label( "" ), tooltip( "" ), visible( false ), id( -1 ),
can_control_opacity( false ), spacer( true ) label( "" ),
tooltip( "" ),
visible( false ),
can_control_opacity( false ),
spacer( true ),
ctl_panel( nullptr ),
ctl_indicator( nullptr ),
ctl_visibility( nullptr ),
ctl_color( nullptr ),
ctl_text( nullptr ),
ctl_opacity( nullptr )
{ {
} }
}; };