Fix Coverity warnings.

This commit is contained in:
Wayne Stambaugh 2022-10-26 14:39:44 -04:00
parent ee92ace419
commit 6a0db3e7e2
10 changed files with 37 additions and 14 deletions

View File

@ -78,6 +78,7 @@ int CLI::EXPORT_PCB_SVG_COMMAND::Perform( KIWAY& aKiway ) const
if( !wxFile::Exists( svgJob->m_filename ) ) if( !wxFile::Exists( svgJob->m_filename ) )
{ {
wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) ); wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
delete svgJob;
return EXIT_CODES::ERR_INVALID_INPUT_FILE; return EXIT_CODES::ERR_INVALID_INPUT_FILE;
} }
@ -89,5 +90,7 @@ int CLI::EXPORT_PCB_SVG_COMMAND::Perform( KIWAY& aKiway ) const
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob ); int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob );
delete svgJob;
return exitCode; return exitCode;
} }

View File

@ -446,6 +446,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
void SCH_LABEL_BASE::GetIntersheetRefs( std::vector<std::pair<wxString, wxString>>* pages ) void SCH_LABEL_BASE::GetIntersheetRefs( std::vector<std::pair<wxString, wxString>>* pages )
{ {
wxCHECK( pages, /* void */ );
if( Schematic() ) if( Schematic() )
{ {
auto it = Schematic()->GetPageRefsMap().find( GetText() ); auto it = Schematic()->GetPageRefsMap().find( GetText() );

View File

@ -159,7 +159,7 @@ public:
IBIS_CORNER m_Cpin = IBIS_CORNER::TYP; IBIS_CORNER m_Cpin = IBIS_CORNER::TYP;
IBIS_CORNER m_Ccomp = IBIS_CORNER::TYP; IBIS_CORNER m_Ccomp = IBIS_CORNER::TYP;
IBIS_CORNER m_supply = IBIS_CORNER::TYP; IBIS_CORNER m_supply = IBIS_CORNER::TYP;
KIBIS_WAVEFORM* m_waveform; KIBIS_WAVEFORM* m_waveform = nullptr;
KIBIS_ACCURACY m_accuracy = KIBIS_ACCURACY::LEVEL_2; KIBIS_ACCURACY m_accuracy = KIBIS_ACCURACY::LEVEL_2;
void SetCornerFromString( IBIS_CORNER& aCorner, std::string aString ); void SetCornerFromString( IBIS_CORNER& aCorner, std::string aString );

View File

@ -81,7 +81,10 @@ public:
} }
const PARAM& GetParam( unsigned aParamIndex ) const override { return m_params.at( aParamIndex ); }; const PARAM& GetParam( unsigned aParamIndex ) const override
{
return m_params.at( aParamIndex );
};
/** @brief update the list of available models based on the pin number. /** @brief update the list of available models based on the pin number.
* */ * */
@ -93,8 +96,10 @@ public:
bool CanDifferential() { return m_enableDiff; }; bool CanDifferential() { return m_enableDiff; };
bool m_enableDiff; bool m_enableDiff;
void ReadDataSchFields( unsigned aSymbolPinCount, const std::vector<SCH_FIELD>* aFields ) override; void ReadDataSchFields( unsigned aSymbolPinCount,
void ReadDataLibFields( unsigned aSymbolPinCount, const std::vector<LIB_FIELD>* aFields ) override; const std::vector<SCH_FIELD>* aFields ) override;
void ReadDataLibFields( unsigned aSymbolPinCount,
const std::vector<LIB_FIELD>* aFields ) override;
protected: protected:
void CreatePins( unsigned aSymbolPinCount ) override; void CreatePins( unsigned aSymbolPinCount ) override;

View File

@ -2077,8 +2077,11 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) ) if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) )
bbox.Inflate( -label->GetLabelBoxExpansion() ); bbox.Inflate( -label->GetLabelBoxExpansion() );
EDA_TEXT* textItem = dynamic_cast<EDA_TEXT*>( item );
wxCHECK(textItem, 0 );
// Careful: GetTextMargin() is dependent on font size... // Careful: GetTextMargin() is dependent on font size...
new_textbox->SetTextSize( dynamic_cast<EDA_TEXT*>( item )->GetTextSize() ); new_textbox->SetTextSize( textItem->GetTextSize() );
int margin = new_textbox->GetTextMargin(); int margin = new_textbox->GetTextMargin();
bbox.Inflate( margin ); bbox.Inflate( margin );

View File

@ -331,6 +331,7 @@ bool isMaskAperture( BOARD_ITEM* aItem )
return maskLayers.count() > 0 && otherLayers.count() == 0; return maskLayers.count() > 0 && otherLayers.count() == 0;
} }
bool DRC_TEST_PROVIDER_SOLDER_MASK::checkMaskAperture( BOARD_ITEM* aMaskItem, BOARD_ITEM* aTestItem, bool DRC_TEST_PROVIDER_SOLDER_MASK::checkMaskAperture( BOARD_ITEM* aMaskItem, BOARD_ITEM* aTestItem,
PCB_LAYER_ID aTestLayer, int aTestNet, PCB_LAYER_ID aTestLayer, int aTestNet,
BOARD_ITEM** aCollidingItem ) BOARD_ITEM** aCollidingItem )
@ -373,7 +374,9 @@ bool DRC_TEST_PROVIDER_SOLDER_MASK::checkItemMask( BOARD_ITEM* aMaskItem, int aT
{ {
FOOTPRINT* fp = static_cast<FOOTPRINT*>( aMaskItem->GetParentFootprint() ); FOOTPRINT* fp = static_cast<FOOTPRINT*>( aMaskItem->GetParentFootprint() );
if( fp && ( fp->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES ) > 0 ) wxCHECK( fp, false );
if( ( fp->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES ) > 0 )
{ {
// If we're allowing bridges then we're allowing bridges. Nothing to check. // If we're allowing bridges then we're allowing bridges. Nothing to check.
return false; return false;

View File

@ -155,6 +155,8 @@ public:
void FOOTPRINT_EDIT_FRAME::UpdateLibraryTree( const wxDataViewItem& aTreeItem, void FOOTPRINT_EDIT_FRAME::UpdateLibraryTree( const wxDataViewItem& aTreeItem,
FOOTPRINT* aFootprint ) FOOTPRINT* aFootprint )
{ {
wxCHECK( aFootprint, /* void */ );
BASIC_FOOTPRINT_INFO footprintInfo( aFootprint ); BASIC_FOOTPRINT_INFO footprintInfo( aFootprint );
if( aTreeItem.IsOk() ) // Can be not found in tree if the current footprint is imported if( aTreeItem.IsOk() ) // Can be not found in tree if the current footprint is imported

View File

@ -2163,8 +2163,12 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER
bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
std::optional<VECTOR2D> aStartingPoint ) std::optional<VECTOR2D> aStartingPoint )
{ {
wxCHECK( aGraphic, false );
PCB_SHAPE*& graphic = *aGraphic; PCB_SHAPE*& graphic = *aGraphic;
wxCHECK( graphic, false );
if( m_layer != m_frame->GetActiveLayer() ) if( m_layer != m_frame->GetActiveLayer() )
{ {
m_layer = m_frame->GetActiveLayer(); m_layer = m_frame->GetActiveLayer();

View File

@ -264,8 +264,8 @@ VECTOR2I PCB_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& a
//Respect limits of coordinates representation //Respect limits of coordinates representation
BOX2I bb; BOX2I bb;
bb.SetOrigin( GetClampedCoords<double, int>( VECTOR2D( aOrigin ) - snapRange / 2 ) ); bb.SetOrigin( GetClampedCoords<double, int>( VECTOR2D( aOrigin ) - snapRange / 2.0 ) );
bb.SetEnd( GetClampedCoords<double, int>( VECTOR2D( aOrigin ) + snapRange / 2 ) ); bb.SetEnd( GetClampedCoords<double, int>( VECTOR2D( aOrigin ) + snapRange / 2.0 ) );
clearAnchors(); clearAnchors();

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.TXT for contributors. * Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -77,7 +77,8 @@ const static std::vector<EXPR_TO_TEST> introspectionExpressions = {
{ "A.Width > B.Width", false, VAL( 0.0 ) }, { "A.Width > B.Width", false, VAL( 0.0 ) },
{ "A.Width + B.Width", false, VAL( pcbIUScale.MilsToIU(10) + pcbIUScale.MilsToIU(20) ) }, { "A.Width + B.Width", false, VAL( pcbIUScale.MilsToIU(10) + pcbIUScale.MilsToIU(20) ) },
{ "A.Netclass", false, VAL( "HV" ) }, { "A.Netclass", false, VAL( "HV" ) },
{ "(A.Netclass == 'HV') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')", false, VAL( 1.0 ) }, { "(A.Netclass == 'HV') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')", false,
VAL( 1.0 ) },
{ "A.Netclass + 1.0", false, VAL( 1.0 ) }, { "A.Netclass + 1.0", false, VAL( 1.0 ) },
{ "A.type == 'Track' && B.type == 'Track' && A.layer == 'F.Cu'", false, VAL( 1.0 ) }, { "A.type == 'Track' && B.type == 'Track' && A.layer == 'F.Cu'", false, VAL( 1.0 ) },
{ "(A.type == 'Track') && (B.type == 'Track') && (A.layer == 'F.Cu')", false, VAL( 1.0 ) }, { "(A.type == 'Track') && (B.type == 'Track') && (A.layer == 'F.Cu')", false, VAL( 1.0 ) },
@ -85,7 +86,7 @@ const static std::vector<EXPR_TO_TEST> introspectionExpressions = {
}; };
static bool testEvalExpr( const wxString& expr, LIBEVAL::VALUE expectedResult, static bool testEvalExpr( const wxString& expr, const LIBEVAL::VALUE& expectedResult,
bool expectError = false, BOARD_ITEM* itemA = nullptr, bool expectError = false, BOARD_ITEM* itemA = nullptr,
BOARD_ITEM* itemB = nullptr ) BOARD_ITEM* itemB = nullptr )
{ {
@ -123,7 +124,6 @@ static bool testEvalExpr( const wxString& expr, LIBEVAL::VALUE expectedResult,
ok = ( result.EqualTo( &context, &expectedResult ) ); ok = ( result.EqualTo( &context, &expectedResult ) );
} }
if( expectedResult.GetType() == LIBEVAL::VT_NUMERIC ) if( expectedResult.GetType() == LIBEVAL::VT_NUMERIC )
{ {
BOOST_CHECK_EQUAL( result.AsDouble(), expectedResult.AsDouble() ); BOOST_CHECK_EQUAL( result.AsDouble(), expectedResult.AsDouble() );
@ -133,10 +133,10 @@ static bool testEvalExpr( const wxString& expr, LIBEVAL::VALUE expectedResult,
BOOST_CHECK_EQUAL( result.AsString(), expectedResult.AsString() ); BOOST_CHECK_EQUAL( result.AsString(), expectedResult.AsString() );
} }
return ok; return ok;
} }
BOOST_AUTO_TEST_CASE( SimpleExpressions ) BOOST_AUTO_TEST_CASE( SimpleExpressions )
{ {
for( const auto& expr : simpleExpressions ) for( const auto& expr : simpleExpressions )
@ -145,6 +145,7 @@ BOOST_AUTO_TEST_CASE( SimpleExpressions )
} }
} }
BOOST_AUTO_TEST_CASE( IntrospectedProperties ) BOOST_AUTO_TEST_CASE( IntrospectedProperties )
{ {
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();