Coverity fixes: 280374, 313611, 313648, 313649, and 314720.

This commit is contained in:
Wayne Stambaugh 2020-12-11 13:29:52 -05:00
parent 0ef63aca47
commit dd4298bb94
5 changed files with 39 additions and 23 deletions

View File

@ -53,6 +53,7 @@ EE_GRID_HELPER::EE_GRID_HELPER( TOOL_MANAGER* aToolMgr ) :
{
m_enableSnap = true;
m_enableSnapLine = true;
m_enableGrid = true;
m_snapItem = nullptr;
KIGFX::VIEW* view = m_toolMgr->GetView();

View File

@ -43,8 +43,8 @@
- DRCE_TOO_MANY_VIAS
Todo:
- arc support.
- improve recognition of coupled segments (now anything that's parallel is considered coupled, causing
DRC errors on meanders)
- improve recognition of coupled segments (now anything that's parallel is considered
coupled, causing DRC errors on meanders)
*/
namespace test {
@ -169,7 +169,10 @@ struct DIFF_PAIR_COUPLED_SEGMENTS
DIFF_PAIR_COUPLED_SEGMENTS() :
parentN( nullptr ),
parentP( nullptr )
parentP( nullptr ),
computedGap( 0 ),
layer( UNDEFINED_LAYER ),
couplingOK( false )
{}
};
@ -349,7 +352,8 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
wxString nameP = niP->GetNetname();
wxString nameN = niN->GetNetname();
reportAux( wxString::Format( "Rule '%s', DP: (+) %s - (-) %s", it.first.parentRule->m_Name, nameP, nameN ) );
reportAux( wxString::Format( "Rule '%s', DP: (+) %s - (-) %s",
it.first.parentRule->m_Name, nameP, nameN ) );
extractDiffPairCoupledItems( it.second, copperTree );
@ -359,8 +363,10 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
drc_dbg(10, " coupled prims : %d\n", (int) it.second.coupled.size() );
OPT<DRC_CONSTRAINT> gapConstraint = it.first.parentRule->FindConstraint( DIFF_PAIR_GAP_CONSTRAINT );
OPT<DRC_CONSTRAINT> maxUncoupledConstraint = it.first.parentRule->FindConstraint( DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT );
OPT<DRC_CONSTRAINT> gapConstraint =
it.first.parentRule->FindConstraint( DIFF_PAIR_GAP_CONSTRAINT );
OPT<DRC_CONSTRAINT> maxUncoupledConstraint =
it.first.parentRule->FindConstraint( DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT );
for( auto& item : it.second.itemsN )
{
@ -401,7 +407,8 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
overlay->Line( cpair.coupledN );
}
drc_dbg(10, " len %d gap %d l %d\n", length, gap, cpair.parentP->GetLayer() );
drc_dbg( 10, " len %d gap %d l %d\n", length, gap,
cpair.parentP->GetLayer() );
if( gapConstraint )
{
@ -412,7 +419,6 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
if ( val.HasMax() && gap > val.Max() )
insideRange = false;
// if(val.HasMin() && val.HasMax() )
// drc_dbg(10, "Vmin %d vmax %d\n", val.Min(), val.Max() );
@ -424,10 +430,10 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
}
int totalLen = std::max( it.second.totalLengthN, it.second.totalLengthP );
reportAux( wxString::Format( " - coupled length: %s, total length: %s",
reportAux( wxString::Format( " - coupled length: %s, total length: %s",
MessageTextFromValue( userUnits(), it.second.totalCoupled ),
MessageTextFromValue( userUnits(), totalLen ) ) );
MessageTextFromValue( userUnits(), it.second.totalCoupled ),
MessageTextFromValue( userUnits(), totalLen ) ) );
int totalUncoupled = totalLen - it.second.totalCoupled;
@ -471,16 +477,16 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
auto val = gapConstraint->GetValue();
auto drcItem = DRC_ITEM::Create( DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE );
m_msg = drcItem->GetErrorText() + " (" + gapConstraint->GetParentRule()->m_Name + " ";
m_msg = drcItem->GetErrorText() + " (" +
gapConstraint->GetParentRule()->m_Name + " ";
if( val.HasMin() )
m_msg += wxString::Format( _( "minimum gap: %s; " ),
MessageTextFromValue( userUnits(), val.Min() ) );
MessageTextFromValue( userUnits(), val.Min() ) );
if( val.HasMax() )
m_msg += wxString::Format( _( "maximum gap: %s; " ),
MessageTextFromValue( userUnits(), val.Max() ) );
MessageTextFromValue( userUnits(), val.Max() ) );
m_msg += wxString::Format( _( "actual: %s)" ),
MessageTextFromValue( userUnits(), cpair.computedGap ) );

View File

@ -116,7 +116,8 @@ static const TOOL_ACTION ACT_PlaceMicroVia( "pcbnew.InteractiveRouter.PlaceMicro
_( "Place Microvia" ), _( "Adds a microvia at the end of currently routed track." ),
via_microvia_xpm, AF_NONE, (void*) VIA_ACTION_FLAGS::MICROVIA );
static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia( "pcbnew.InteractiveRouter.SelLayerAndPlaceVia",
static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia(
"pcbnew.InteractiveRouter.SelLayerAndPlaceVia",
AS_CONTEXT,
'<', LEGACY_HK_NAME( "Select Layer and Add Through Via" ),
_( "Select Layer and Place Through Via..." ),
@ -124,7 +125,8 @@ static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia( "pcbnew.InteractiveRout
select_w_layer_xpm, AF_NONE,
(void*) ( VIA_ACTION_FLAGS::VIA | VIA_ACTION_FLAGS::SELECT_LAYER ) );
static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia( "pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia",
static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia(
"pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia",
AS_CONTEXT,
MD_ALT + '<', LEGACY_HK_NAME( "Select Layer and Add Blind/Buried Via" ),
_( "Select Layer and Place Blind/Buried Via..." ),
@ -488,6 +490,7 @@ void ROUTER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent )
case '0':
{
auto logger = m_router->Logger();
if( ! logger )
return;
@ -502,17 +505,18 @@ void ROUTER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent )
if( evt.item && evt.item->Parent() )
id = evt.item->Parent()->m_Uuid.AsString();
fprintf(f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type, (const char*) id.c_str() );
fprintf( f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type,
(const char*) id.c_str() );
}
fclose(f);
fclose( f );
// Export as *.kicad_pcb format, using a strategy which is specifically chosen
// as an example on how it could also be used to send it to the system clipboard.
PCB_IO pcb_io;
pcb_io.Save("/tmp/pns.dump", m_iface->GetBoard(), nullptr );
pcb_io.Save( "/tmp/pns.dump", m_iface->GetBoard(), nullptr );
break;
}
@ -662,6 +666,8 @@ int ROUTER_TOOL::onViaCommand( const TOOL_EVENT& aEvent )
int ROUTER_TOOL::handleLayerSwitch( const TOOL_EVENT& aEvent, bool aForceVia )
{
wxCHECK( m_router, 0 );
if( !IsToolActive() )
return 0;
@ -747,7 +753,7 @@ int ROUTER_TOOL::handleLayerSwitch( const TOOL_EVENT& aEvent, bool aForceVia )
targetLayer = frame()->SelectLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
LSET::AllNonCuMask(), dlgPosition );
// Reset the cursor to the position where the event occured
// Reset the cursor to the position where the event occurred
controls()->SetCursorPosition( aEvent.HasPosition() ? aEvent.Position() : dlgPosition );
}
}
@ -1010,7 +1016,7 @@ void ROUTER_TOOL::performRouting()
{
setCursor();
// Don't crash if we missed an operation that cancelled routing.
// Don't crash if we missed an operation that canceled routing.
if( !m_router->RoutingInProgress() )
{
if( evt->IsCancelInteractive() )

View File

@ -692,6 +692,8 @@ int EDIT_TOOL::ChangeTrackWidth( const TOOL_EVENT& aEvent )
{
TRACK* track = dynamic_cast<TRACK*>( item );
wxCHECK( track, 0 );
m_commit->Modify( track );
int new_width = board()->GetDesignSettings().GetCurrentTrackWidth();

View File

@ -2,6 +2,7 @@
* This program source code file is part kicad2mcad
*
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -1069,7 +1070,7 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString&
i2 += nchars;
}
if( aString[i2] != '"' )
if( i2 >= aString.size() || aString[i2] != '"' )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";