Coverity fixes

This commit is contained in:
Jon Evans 2020-05-18 22:58:28 -04:00
parent 9e79dfdb25
commit f4d7c323f5
11 changed files with 64 additions and 28 deletions

View File

@ -1990,7 +1990,7 @@ bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSu
SCH_ITEM* net_item = nullptr; SCH_ITEM* net_item = nullptr;
SCH_ITEM* bus_item = nullptr; SCH_ITEM* bus_item = nullptr;
SCH_CONNECTION conn; SCH_CONNECTION conn( this );
for( auto item : aSubgraph->m_items ) for( auto item : aSubgraph->m_items )
{ {

View File

@ -122,15 +122,17 @@ void DIALOG_MIGRATE_BUSES::updateUi()
} }
std::vector<wxString> DIALOG_MIGRATE_BUSES::getProposedLabels( const std::vector<wxString>& aLabelList ) std::vector<wxString> DIALOG_MIGRATE_BUSES::getProposedLabels(
const std::vector<wxString>& aLabelList )
{ {
int lowest_start = INT_MAX; int lowest_start = INT_MAX;
int highest_end = -1; int highest_end = -1;
int widest_bus = -1; int widest_bus = -1;
SCH_CONNECTION conn( m_frame->Schematic().ConnectionGraph() );
for( const wxString& label : aLabelList ) for( const wxString& label : aLabelList )
{ {
SCH_CONNECTION conn;
conn.ConfigureFromLabel( label ); conn.ConfigureFromLabel( label );
int start = conn.VectorStart(); int start = conn.VectorStart();
@ -146,7 +148,6 @@ std::vector<wxString> DIALOG_MIGRATE_BUSES::getProposedLabels( const std::vector
widest_bus = end - start + 1; widest_bus = end - start + 1;
} }
SCH_CONNECTION conn;
std::vector<wxString> proposals; std::vector<wxString> proposals;
for( const wxString& label : aLabelList ) for( const wxString& label : aLabelList )

View File

@ -503,7 +503,9 @@ RESCUER::RESCUER( PROJECT& aProject, SCHEMATIC* aSchematic, SCH_SHEET_PATH* aCur
wxASSERT( m_schematic ); wxASSERT( m_schematic );
if( m_schematic )
get_components( m_schematic, m_components ); get_components( m_schematic, m_components );
m_prj = &aProject; m_prj = &aProject;
m_currentSheet = aCurrentSheet; m_currentSheet = aCurrentSheet;
m_galBackEndType = aGalBackEndType; m_galBackEndType = aGalBackEndType;

View File

@ -60,7 +60,17 @@
SCH_CONNECTION::SCH_CONNECTION( SCH_ITEM* aParent, SCH_SHEET_PATH aPath ) : SCH_CONNECTION::SCH_CONNECTION( SCH_ITEM* aParent, SCH_SHEET_PATH aPath ) :
m_sheet( aPath ), m_sheet( aPath ),
m_parent( aParent ) m_parent( aParent ),
m_graph( nullptr )
{
Reset();
}
SCH_CONNECTION::SCH_CONNECTION( CONNECTION_GRAPH* aGraph ) :
m_sheet( SCH_SHEET_PATH() ),
m_parent( nullptr ),
m_graph( aGraph )
{ {
Reset(); Reset();
} }

View File

@ -63,6 +63,8 @@ class SCH_CONNECTION
public: public:
SCH_CONNECTION( SCH_ITEM* aParent = nullptr, SCH_SHEET_PATH aPath = SCH_SHEET_PATH() ); SCH_CONNECTION( SCH_ITEM* aParent = nullptr, SCH_SHEET_PATH aPath = SCH_SHEET_PATH() );
SCH_CONNECTION( CONNECTION_GRAPH* aGraph );
~SCH_CONNECTION() ~SCH_CONNECTION()
{} {}

View File

@ -358,6 +358,7 @@ SCH_EAGLE_PLUGIN::SCH_EAGLE_PLUGIN()
m_kiway = nullptr; m_kiway = nullptr;
m_rootSheet = nullptr; m_rootSheet = nullptr;
m_currentSheet = nullptr; m_currentSheet = nullptr;
m_schematic = nullptr;
} }

View File

@ -579,11 +579,12 @@ SCH_LEGACY_PLUGIN::~SCH_LEGACY_PLUGIN()
void SCH_LEGACY_PLUGIN::init( KIWAY* aKiway, const PROPERTIES* aProperties ) void SCH_LEGACY_PLUGIN::init( KIWAY* aKiway, const PROPERTIES* aProperties )
{ {
m_version = 0; m_version = 0;
m_rootSheet = NULL; m_rootSheet = nullptr;
m_props = aProperties; m_props = aProperties;
m_kiway = aKiway; m_kiway = aKiway;
m_cache = NULL; m_cache = nullptr;
m_out = NULL; m_out = nullptr;
m_schematic = nullptr;
} }
@ -640,6 +641,7 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, SC
// If we got here, the schematic loaded successfully. // If we got here, the schematic loaded successfully.
sheet = newSheet.release(); sheet = newSheet.release();
m_rootSheet = nullptr; // Quiet Coverity warning.
} }
else else
{ {

View File

@ -1294,7 +1294,12 @@ void SCH_SCREENS::ClearAnnotation()
void SCH_SCREENS::ClearAnnotationOfNewSheetPaths( SCH_SHEET_LIST& aInitialSheetPathList ) void SCH_SCREENS::ClearAnnotationOfNewSheetPaths( SCH_SHEET_LIST& aInitialSheetPathList )
{ {
SCHEMATIC* sch = GetFirst()->Schematic(); SCH_SCREEN* first = GetFirst();
if( !first )
return;
SCHEMATIC* sch = first->Schematic();
wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::ClearAnnotationOfNewSheetPaths" ); wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::ClearAnnotationOfNewSheetPaths" );
@ -1419,7 +1424,12 @@ void SCH_SCREENS::UpdateSymbolLinks( REPORTER* aReporter )
for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() ) for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
screen->UpdateSymbolLinks( aReporter ); screen->UpdateSymbolLinks( aReporter );
SCHEMATIC* sch = GetFirst()->Schematic(); SCH_SCREEN* first = GetFirst();
if( !first )
return;
SCHEMATIC* sch = first->Schematic();
wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" ); wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" );
@ -1571,7 +1581,12 @@ bool SCH_SCREENS::CanCauseCaseSensitivityIssue( const wxString& aSchematicFileNa
void SCH_SCREENS::BuildClientSheetPathList() void SCH_SCREENS::BuildClientSheetPathList()
{ {
SCHEMATIC* sch = GetFirst()->Schematic(); SCH_SCREEN* first = GetFirst();
if( !first )
return;
SCHEMATIC* sch = first->Schematic();
wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" ); wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" );

View File

@ -410,12 +410,13 @@ SCH_SEXPR_PLUGIN::~SCH_SEXPR_PLUGIN()
void SCH_SEXPR_PLUGIN::init( KIWAY* aKiway, const PROPERTIES* aProperties ) void SCH_SEXPR_PLUGIN::init( KIWAY* aKiway, const PROPERTIES* aProperties )
{ {
m_version = 0; m_version = 0;
m_rootSheet = NULL; m_rootSheet = nullptr;
m_props = aProperties; m_props = aProperties;
m_kiway = aKiway; m_kiway = aKiway;
m_cache = NULL; m_cache = nullptr;
m_out = NULL; m_out = nullptr;
m_fieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS m_fieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS
m_schematic = nullptr;
} }

View File

@ -38,6 +38,7 @@ struct PRINTOUT_SETTINGS
m_blackWhite = true; m_blackWhite = true;
m_pageCount = 0; m_pageCount = 0;
m_background = false; m_background = false;
m_colorSettings = nullptr;
} }
virtual ~PRINTOUT_SETTINGS() virtual ~PRINTOUT_SETTINGS()

View File

@ -59,7 +59,8 @@ class DRC_SELECTOR
{ {
public: public:
DRC_SELECTOR() : DRC_SELECTOR() :
m_Priority( 1 ) m_Priority( 1 ),
m_Rule( nullptr )
{ } { }
public: public: