From e4feb8826bad661723e7649c1447310970eeeca0 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sun, 27 Aug 2023 15:16:29 -0400 Subject: [PATCH] Coverity issue fixes. --- eeschema/eeschema_jobs_handler.cpp | 5 ++++- pcbnew/collectors.cpp | 2 ++ pcbnew/dialogs/dialog_export_svg.cpp | 1 + pcbnew/router/pns_diff_pair.cpp | 4 ++-- pcbnew/router/pns_item.cpp | 1 + pcbnew/router/pns_itemset.h | 2 +- pcbnew/router/pns_router.cpp | 13 ++++++++----- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/eeschema/eeschema_jobs_handler.cpp b/eeschema/eeschema_jobs_handler.cpp index 14588004c8..1b3796a92c 100644 --- a/eeschema/eeschema_jobs_handler.cpp +++ b/eeschema/eeschema_jobs_handler.cpp @@ -461,6 +461,9 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, if( symbol->IsAlias() ) { LIB_SYMBOL_SPTR parent = symbol->GetRootSymbol().lock(); + + wxCHECK( parent, CLI::EXIT_CODES::ERR_UNKNOWN ); + symbolToPlot = parent.get(); } @@ -815,4 +818,4 @@ DS_PROXY_VIEW_ITEM* EESCHEMA_JOBS_HANDLER::getDrawingSheetProxyView( SCHEMATIC* drawingSheet->SetSheetPath( "" ); return drawingSheet; -} \ No newline at end of file +} diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 2024fd72e1..b2b836fff8 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -431,6 +431,8 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* aTestItem, void* aTestData } else if( aTestItem->Type() == PCB_FOOTPRINT_T ) { + wxCHECK( footprint, INSPECT_RESULT::CONTINUE ); + if( footprint->HitTest( m_refPos, accuracy ) && footprint->HitTestAccurate( m_refPos, accuracy ) ) { diff --git a/pcbnew/dialogs/dialog_export_svg.cpp b/pcbnew/dialogs/dialog_export_svg.cpp index 1bd1c59337..d2714369da 100644 --- a/pcbnew/dialogs/dialog_export_svg.cpp +++ b/pcbnew/dialogs/dialog_export_svg.cpp @@ -292,6 +292,7 @@ void DIALOG_EXPORT_SVG::ExportSVGFile( bool aOnlyOneFile ) svgPlotOptions.m_colorTheme = ""; // will use default svgPlotOptions.m_mirror = m_printMirror; svgPlotOptions.m_plotFrame = svgPlotOptions.m_pageSizeMode == 0; + svgPlotOptions.m_drillShapeOption = 2; // actual size hole. for( LSEQ seq = all_selected.Seq(); seq; ++seq ) { diff --git a/pcbnew/router/pns_diff_pair.cpp b/pcbnew/router/pns_diff_pair.cpp index 74bee6021a..64ec6e5920 100644 --- a/pcbnew/router/pns_diff_pair.cpp +++ b/pcbnew/router/pns_diff_pair.cpp @@ -424,8 +424,8 @@ void DP_GATEWAYS::BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool a { VECTOR2I majorDirection; VECTOR2I p0_p, p0_n; - int orthoFanDistance; - int diagFanDistance; + int orthoFanDistance = 0; + int diagFanDistance = 0; const SHAPE* shP = nullptr; if( aPair.PrimP() == nullptr ) diff --git a/pcbnew/router/pns_item.cpp b/pcbnew/router/pns_item.cpp index e4c3aa8b5d..144d77b419 100644 --- a/pcbnew/router/pns_item.cpp +++ b/pcbnew/router/pns_item.cpp @@ -239,6 +239,7 @@ bool ITEM::collideSimple( const ITEM* aHead, const NODE* aNode, obs.m_head = const_cast( aHead ); obs.m_item = const_cast( this ); obs.m_clearance = clearance; + obs.m_distFirst = 0; aCtx->obstacles.insert( obs ); } else diff --git a/pcbnew/router/pns_itemset.h b/pcbnew/router/pns_itemset.h index 88138785c2..e619f6baaa 100644 --- a/pcbnew/router/pns_itemset.h +++ b/pcbnew/router/pns_itemset.h @@ -41,7 +41,7 @@ public: if( aInitialItem ) m_items.emplace_back( aInitialItem ); - if( aBecomeOwner ) + if( aBecomeOwner && aInitialItem ) aInitialItem->SetOwner( this ); } diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 4b9a62e9d0..e3242bde00 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -124,8 +124,8 @@ bool ROUTER::RoutingInProgress() const const ITEM_SET ROUTER::QueryHoverItems( const VECTOR2I& aP, bool aUseClearance ) { - NODE* node; - int clearance; + NODE* node = nullptr; + int clearance = 0; if( m_state == IDLE || m_placer == nullptr ) { @@ -154,12 +154,15 @@ const ITEM_SET ROUTER::QueryHoverItems( const VECTOR2I& aP, bool aUseClearance ) opts.m_differentNetsOnly = false; opts.m_overrideClearance = clearance; - node->QueryColliding( &test, obs, opts ); PNS::ITEM_SET ret; - for( const OBSTACLE& obstacle : obs ) - ret.Add( obstacle.m_item, false ); + wxCHECK( node, ret ); + + node->QueryColliding( &test, obs, opts ); + + for( const OBSTACLE& obstacle : obs ) + ret.Add( obstacle.m_item, false ); return ret; }