From 00e58cd974bdaf21defd99d3fa1bb1041a223b3e Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 12 Jan 2020 13:00:42 +0000 Subject: [PATCH] Fix unintialized values (from coverity scan) --- common/painter.cpp | 19 ++++++------ eeschema/connection_graph.h | 7 +++-- eeschema/dialogs/dialog_migrate_buses.cpp | 5 ++-- eeschema/sch_component.cpp | 11 +++---- eeschema/sim/sim_plot_panel.cpp | 11 +++++-- pcbnew/autorouter/ar_matrix.cpp | 25 +++++++++------- pcbnew/board_design_settings.cpp | 4 +++ .../class_board_stackup.cpp | 18 ++++++----- .../exporters/export_footprints_placefile.cpp | 5 ++-- pcbnew/exporters/export_hyperlynx.cpp | 30 +++++++++++-------- pcbnew/exporters/gerber_placefile_writer.cpp | 9 +++--- pcbnew/router/pns_dp_meander_placer.cpp | 9 ++++-- 12 files changed, 92 insertions(+), 61 deletions(-) diff --git a/common/painter.cpp b/common/painter.cpp index 018fa847c2..f853827f22 100644 --- a/common/painter.cpp +++ b/common/painter.cpp @@ -32,16 +32,17 @@ using namespace KIGFX; RENDER_SETTINGS::RENDER_SETTINGS() { // Set the default initial values - m_highlightFactor = 0.5f; - m_selectFactor = 0.5f; - m_layerOpacity = 0.8f; - m_highlightEnabled = false; - m_hiContrastEnabled = false; - m_hiContrastFactor = 0.2f; //TODO: Make this user-configurable - m_highlightNetcode = -1; - m_outlineWidth = 1; + m_highlightFactor = 0.5f; + m_selectFactor = 0.5f; + m_layerOpacity = 0.8f; + m_highlightItems = false; + m_highlightEnabled = false; + m_hiContrastEnabled = false; + m_hiContrastFactor = 0.2f; //TODO: Make this user-configurable + m_highlightNetcode = -1; + m_outlineWidth = 1; m_worksheetLineWidth = 100000; - m_showPageLimits = false; + m_showPageLimits = false; } diff --git a/eeschema/connection_graph.h b/eeschema/connection_graph.h index cce4705566..75dfde3206 100644 --- a/eeschema/connection_graph.h +++ b/eeschema/connection_graph.h @@ -205,8 +205,11 @@ public: class CONNECTION_GRAPH { public: - CONNECTION_GRAPH( SCH_EDIT_FRAME* aFrame) : - m_frame( aFrame ) + CONNECTION_GRAPH( SCH_EDIT_FRAME* aFrame ) + : m_last_net_code( 1 ), + m_last_bus_code( 1 ), + m_last_subgraph_code( 1 ), + m_frame( aFrame ) {} ~CONNECTION_GRAPH() diff --git a/eeschema/dialogs/dialog_migrate_buses.cpp b/eeschema/dialogs/dialog_migrate_buses.cpp index d5300747cc..7df2c0bf96 100644 --- a/eeschema/dialogs/dialog_migrate_buses.cpp +++ b/eeschema/dialogs/dialog_migrate_buses.cpp @@ -53,9 +53,8 @@ */ -DIALOG_MIGRATE_BUSES::DIALOG_MIGRATE_BUSES( SCH_EDIT_FRAME* aParent ) : - DIALOG_MIGRATE_BUSES_BASE( aParent ), - m_frame( aParent ) +DIALOG_MIGRATE_BUSES::DIALOG_MIGRATE_BUSES( SCH_EDIT_FRAME* aParent ) + : DIALOG_MIGRATE_BUSES_BASE( aParent ), m_frame( aParent ), m_selected_index( 0 ) { m_migration_list->Bind( wxEVT_LIST_ITEM_SELECTED, &DIALOG_MIGRATE_BUSES::onItemSelected, this ); diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 2c93ed00a7..43a699fb64 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -171,11 +171,12 @@ SCH_COMPONENT::SCH_COMPONENT( SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) : SCH_ITEM( aComponent ) { - m_Parent = aComponent.m_Parent; - m_Pos = aComponent.m_Pos; - m_unit = aComponent.m_unit; - m_convert = aComponent.m_convert; - m_lib_id = aComponent.m_lib_id; + m_Parent = aComponent.m_Parent; + m_Pos = aComponent.m_Pos; + m_unit = aComponent.m_unit; + m_convert = aComponent.m_convert; + m_lib_id = aComponent.m_lib_id; + m_isInNetlist = aComponent.m_isInNetlist; if( aComponent.m_part ) m_part.reset( new LIB_PART( *aComponent.m_part.get() ) ); diff --git a/eeschema/sim/sim_plot_panel.cpp b/eeschema/sim/sim_plot_panel.cpp index 56de7cc2cd..632220cb2b 100644 --- a/eeschema/sim/sim_plot_panel.cpp +++ b/eeschema/sim/sim_plot_panel.cpp @@ -362,9 +362,14 @@ void CURSOR::UpdateReference() SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, wxWindowID id, const wxPoint& pos, - const wxSize& size, long style, const wxString& name ) - : mpWindow( parent, id, pos, size, style ), m_colorIdx( 0 ), - m_axis_x( nullptr ), m_axis_y1( nullptr ), m_axis_y2( nullptr ), m_type( aType ) + const wxSize& size, long style, const wxString& name ) + : mpWindow( parent, id, pos, size, style ), + m_colorIdx( 0 ), + m_axis_x( nullptr ), + m_axis_y1( nullptr ), + m_axis_y2( nullptr ), + m_dotted_cp( false ), + m_type( aType ) { LimitView( true ); SetMargins( 50, 80, 50, 80 ); diff --git a/pcbnew/autorouter/ar_matrix.cpp b/pcbnew/autorouter/ar_matrix.cpp index d808453671..d0de1f5ddc 100644 --- a/pcbnew/autorouter/ar_matrix.cpp +++ b/pcbnew/autorouter/ar_matrix.cpp @@ -39,17 +39,22 @@ AR_MATRIX::AR_MATRIX() { - m_BoardSide[0] = m_BoardSide[1] = nullptr; - m_DistSide[0] = m_DistSide[1] = nullptr; - m_DirSide[0] = m_DirSide[1] = nullptr; - m_opWriteCell = nullptr; - m_InitMatrixDone = false; - m_Nrows = 0; - m_Ncols = 0; - m_MemSize = 0; + m_BoardSide[0] = nullptr; + m_BoardSide[1] = nullptr; + m_DistSide[0] = nullptr; + m_DistSide[1] = nullptr; + m_DirSide[0] = nullptr; + m_DirSide[1] = nullptr; + m_opWriteCell = nullptr; + m_InitMatrixDone = false; + m_Nrows = 0; + m_Ncols = 0; + m_MemSize = 0; m_RoutingLayersCount = 1; - m_GridRouting = 0; - m_RouteCount = 0; + m_GridRouting = 0; + m_RouteCount = 0; + m_routeLayerBottom = B_Cu; + m_routeLayerTop = F_Cu; } diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index c98472b147..37a5fe216b 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -517,6 +517,10 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() : m_trackWidthIndex = 0; m_diffPairIndex = 0; + // Courtyard defaults + m_RequireCourtyards = false; + m_ProhibitOverlappingCourtyards = true; + // Default ref text on fp creation. If empty, use footprint name as default m_RefDefaultText = wxT( "REF**" ); m_RefDefaultVisibility = true; diff --git a/pcbnew/board_stackup_manager/class_board_stackup.cpp b/pcbnew/board_stackup_manager/class_board_stackup.cpp index 05ddda14c6..4b56afe1f2 100644 --- a/pcbnew/board_stackup_manager/class_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/class_board_stackup.cpp @@ -320,11 +320,12 @@ BOARD_STACKUP::BOARD_STACKUP() BOARD_STACKUP::BOARD_STACKUP( BOARD_STACKUP& aOther ) { - m_HasDielectricConstrains = aOther.m_HasDielectricConstrains; + m_HasDielectricConstrains = aOther.m_HasDielectricConstrains; + m_HasThicknessConstrains = aOther.m_HasThicknessConstrains; m_EdgeConnectorConstraints = aOther.m_EdgeConnectorConstraints; - m_CastellatedPads = aOther.m_CastellatedPads; - m_EdgePlating = aOther.m_EdgePlating; - m_FinishType = aOther.m_FinishType; + m_CastellatedPads = aOther.m_CastellatedPads; + m_EdgePlating = aOther.m_EdgePlating; + m_FinishType = aOther.m_FinishType; // All items in aOther.m_list have to be duplicated, because aOther.m_list // manage pointers to these items @@ -338,11 +339,12 @@ BOARD_STACKUP::BOARD_STACKUP( BOARD_STACKUP& aOther ) BOARD_STACKUP& BOARD_STACKUP::operator=( const BOARD_STACKUP& aOther ) { - m_HasDielectricConstrains = aOther.m_HasDielectricConstrains; + m_HasDielectricConstrains = aOther.m_HasDielectricConstrains; + m_HasThicknessConstrains = aOther.m_HasThicknessConstrains; m_EdgeConnectorConstraints = aOther.m_EdgeConnectorConstraints; - m_CastellatedPads = aOther.m_CastellatedPads; - m_EdgePlating = aOther.m_EdgePlating; - m_FinishType = aOther.m_FinishType; + m_CastellatedPads = aOther.m_CastellatedPads; + m_EdgePlating = aOther.m_EdgePlating; + m_FinishType = aOther.m_FinishType; RemoveAll(); diff --git a/pcbnew/exporters/export_footprints_placefile.cpp b/pcbnew/exporters/export_footprints_placefile.cpp index 62ce8782ce..6778fc1ef7 100644 --- a/pcbnew/exporters/export_footprints_placefile.cpp +++ b/pcbnew/exporters/export_footprints_placefile.cpp @@ -74,9 +74,10 @@ PLACE_FILE_EXPORTER::PLACE_FILE_EXPORTER( BOARD* aBoard, bool aUnitsMM, bool aForceSmdItems, bool aTopSide, bool aBottomSide, bool aFormatCSV ) { - m_board = aBoard; - m_unitsMM = aUnitsMM; + m_board = aBoard; + m_unitsMM = aUnitsMM; m_forceSmdItems = aForceSmdItems; + m_fpCount = 0; if( aTopSide && aBottomSide ) m_side = PCB_BOTH_SIDES; diff --git a/pcbnew/exporters/export_hyperlynx.cpp b/pcbnew/exporters/export_hyperlynx.cpp index fe639a5fad..f65054a59d 100644 --- a/pcbnew/exporters/export_hyperlynx.cpp +++ b/pcbnew/exporters/export_hyperlynx.cpp @@ -148,7 +148,10 @@ private: class HYPERLYNX_EXPORTER : public BOARD_EXPORTER_BASE { public: - HYPERLYNX_EXPORTER(){}; + HYPERLYNX_EXPORTER() : m_polyId( 1 ) + { + } + ~HYPERLYNX_EXPORTER(){}; virtual bool Run() override; @@ -226,8 +229,8 @@ private: HYPERLYNX_PAD_STACK::HYPERLYNX_PAD_STACK( BOARD* aBoard, const D_PAD* aPad ) { m_board = aBoard; - m_sx = aPad->GetSize().x; - m_sy = aPad->GetSize().y; + m_sx = aPad->GetSize().x; + m_sy = aPad->GetSize().y; m_angle = 180.0 - ( aPad->GetOrientation() / 10.0 ); if( m_angle < 0.0 ) @@ -236,21 +239,24 @@ HYPERLYNX_PAD_STACK::HYPERLYNX_PAD_STACK( BOARD* aBoard, const D_PAD* aPad ) } m_layers = aPad->GetLayerSet(); - m_drill = aPad->GetDrillSize().x; - m_shape = aPad->GetShape(); - m_type = PAD_ATTRIB_STANDARD; + m_drill = aPad->GetDrillSize().x; + m_shape = aPad->GetShape(); + m_type = PAD_ATTRIB_STANDARD; + m_id = 0; } HYPERLYNX_PAD_STACK::HYPERLYNX_PAD_STACK( BOARD* aBoard, const VIA* aVia ) { - m_board = aBoard; - m_sx = m_sy = aVia->GetWidth(); - m_angle = 0; + m_board = aBoard; + m_sx = aVia->GetWidth(); + m_sy = aVia->GetWidth(); + m_angle = 0; m_layers = LSET::AllCuMask(); - m_drill = aVia->GetDrillValue(); - m_shape = PAD_SHAPE_CIRCLE; - m_type = PAD_ATTRIB_STANDARD; + m_drill = aVia->GetDrillValue(); + m_shape = PAD_SHAPE_CIRCLE; + m_type = PAD_ATTRIB_STANDARD; + m_id = 0; } diff --git a/pcbnew/exporters/gerber_placefile_writer.cpp b/pcbnew/exporters/gerber_placefile_writer.cpp index e3c5dd6787..1b57ff5b84 100644 --- a/pcbnew/exporters/gerber_placefile_writer.cpp +++ b/pcbnew/exporters/gerber_placefile_writer.cpp @@ -49,10 +49,11 @@ PLACEFILE_GERBER_WRITER::PLACEFILE_GERBER_WRITER( BOARD* aPcb ) { m_pcb = aPcb; /* Set conversion scale depending on drill file units */ - m_conversionUnits = 1.0 / IU_PER_MM; // Gerber units = mm - m_forceSmdItems = false; - m_plotPad1Marker = true; // Place a marker to pin 1 (or A1) position - m_plotOtherPadsMarker = true; // Place a marker to other pins position + m_conversionUnits = 1.0 / IU_PER_MM; // Gerber units = mm + m_forceSmdItems = false; + m_plotPad1Marker = true; // Place a marker to pin 1 (or A1) position + m_plotOtherPadsMarker = true; // Place a marker to other pins position + m_layer = PCB_LAYER_ID::UNDEFINED_LAYER; // No layer set } diff --git a/pcbnew/router/pns_dp_meander_placer.cpp b/pcbnew/router/pns_dp_meander_placer.cpp index 50280fd763..d76dbc941a 100644 --- a/pcbnew/router/pns_dp_meander_placer.cpp +++ b/pcbnew/router/pns_dp_meander_placer.cpp @@ -36,13 +36,16 @@ namespace PNS { DP_MEANDER_PLACER::DP_MEANDER_PLACER( ROUTER* aRouter ) : MEANDER_PLACER_BASE( aRouter ) { - m_world = NULL; + m_world = NULL; m_currentNode = NULL; + m_padToDieP = 0; + m_padToDieN = 0; + // Init temporary variables (do not leave uninitialized members) m_initialSegment = NULL; - m_lastLength = 0; - m_lastStatus = TOO_SHORT; + m_lastLength = 0; + m_lastStatus = TOO_SHORT; }