From 6e47f147aa68462321cf57a4b66cf0d7766b2ce4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 30 Mar 2020 09:24:56 +0200 Subject: [PATCH] A few Coverity fixes. --- cvpcb/cvpcb_settings.cpp | 4 ++++ eeschema/autoplace_fields.cpp | 3 --- eeschema/libedit/libedit_settings.cpp | 4 ++++ gerbview/gerbview_settings.cpp | 4 ++++ pagelayout_editor/pl_editor_settings.cpp | 9 +++++++++ pcb_calculator/pcb_calculator_settings.cpp | 6 ++++++ pcbnew/footprint_viewer_frame.cpp | 4 ++-- pcbnew/router/pns_component_dragger.cpp | 3 +++ pcbnew/router/pns_drag_algo.h | 2 +- pcbnew/router/pns_shove.cpp | 3 ++- pcbnew/router/pns_walkaround.h | 1 + 11 files changed, 36 insertions(+), 7 deletions(-) diff --git a/cvpcb/cvpcb_settings.cpp b/cvpcb/cvpcb_settings.cpp index 75824948b6..864914d29e 100644 --- a/cvpcb/cvpcb_settings.cpp +++ b/cvpcb/cvpcb_settings.cpp @@ -32,6 +32,10 @@ const int cvpcbSchemaVersion = 0; CVPCB_SETTINGS::CVPCB_SETTINGS() : APP_SETTINGS_BASE( "cvpcb", cvpcbSchemaVersion ) { + // Make Coverity happy: + m_FilterFootprint = 0; + + // Init settings: m_params.emplace_back( new PARAM( "filter_footprint", &m_FilterFootprint, 0 ) ); addParamsForWindow( &m_FootprintViewer, "footprint_viewer" ); diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index b39981ff31..0d3059b6a8 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -134,9 +134,6 @@ public: m_allow_rejustify = false; m_align_to_grid = true; - m_allow_rejustify = false; - m_align_to_grid = true; - if( cfg ) { m_allow_rejustify = cfg->m_AutoplaceFields.allow_rejustify; diff --git a/eeschema/libedit/libedit_settings.cpp b/eeschema/libedit/libedit_settings.cpp index 05f33a67ae..49dd04f51c 100644 --- a/eeschema/libedit/libedit_settings.cpp +++ b/eeschema/libedit/libedit_settings.cpp @@ -35,6 +35,10 @@ LIBEDIT_SETTINGS::LIBEDIT_SETTINGS() : APP_SETTINGS_BASE( "libedit", libeditSche m_Defaults(), m_Repeat(), m_ShowPinElectricalType( true ), m_LibWidth(), m_EditComponentVisibleColumns() { + // Make Coverity happy + m_UseEeschemaColorSettings = true;; + + // Init settings: SetLegacyFilename( "eeschema" ); m_params.emplace_back( new PARAM( "defaults.line_width", &m_Defaults.line_width, 6 ) ); diff --git a/gerbview/gerbview_settings.cpp b/gerbview/gerbview_settings.cpp index 27dd1ba8a3..143a7538cd 100644 --- a/gerbview/gerbview_settings.cpp +++ b/gerbview/gerbview_settings.cpp @@ -36,6 +36,10 @@ const int gerbviewSchemaVersion = 0; GERBVIEW_SETTINGS::GERBVIEW_SETTINGS() : APP_SETTINGS_BASE( "gerbview", gerbviewSchemaVersion ) { + // Make Coverity happy + m_BoardLayersCount = 2; + + // Init settings: m_params.emplace_back( new PARAM( "appearance.show_border_and_titleblock", &m_Appearance.show_border_and_titleblock, false ) ); diff --git a/pagelayout_editor/pl_editor_settings.cpp b/pagelayout_editor/pl_editor_settings.cpp index 208bd0d1fa..d4ff3a75a6 100644 --- a/pagelayout_editor/pl_editor_settings.cpp +++ b/pagelayout_editor/pl_editor_settings.cpp @@ -33,6 +33,15 @@ const int plEditorSchemaVersion = 0; PL_EDITOR_SETTINGS::PL_EDITOR_SETTINGS() : APP_SETTINGS_BASE( "pl_editor", plEditorSchemaVersion ) { + // Make Coverity happy: + m_CornerOrigin = 0; + m_PropertiesFrameWidth = 150; + m_LastCustomWidth = 17000; + m_LastCustomHeight = 11000; + m_LastWasPortrait = false; + m_BlackBackground = false; + + // Build settings: m_params.emplace_back( new PARAM( "properties_frame_width", &m_PropertiesFrameWidth, 150 ) ); diff --git a/pcb_calculator/pcb_calculator_settings.cpp b/pcb_calculator/pcb_calculator_settings.cpp index 9942172f14..4069b2b47c 100644 --- a/pcb_calculator/pcb_calculator_settings.cpp +++ b/pcb_calculator/pcb_calculator_settings.cpp @@ -35,6 +35,12 @@ const int pcbCalculatorSchemaVersion = 0; PCB_CALCULATOR_SETTINGS::PCB_CALCULATOR_SETTINGS() : APP_SETTINGS_BASE( "pcb_calculator", pcbCalculatorSchemaVersion ) { + // Make Coverity happy: + m_BoardClassUnits = 0; + m_ColorCodeTolerance = 0; + m_LastPage = 0; + + // Build settings: m_params.emplace_back( new PARAM( "board_class_units", &m_BoardClassUnits, 0 ) ); m_params.emplace_back( new PARAM( "color_code_tolerance", &m_ColorCodeTolerance, 0 ) ); diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 69a9affbe4..c549bab1f9 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -714,7 +714,7 @@ void FOOTPRINT_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) void FOOTPRINT_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { auto cfg = dynamic_cast( aCfg ); - wxASSERT( cfg ); + wxCHECK( cfg, /*void*/ ); // We don't want to store anything other than the window settings EDA_BASE_FRAME::SaveSettings( cfg ); @@ -727,7 +727,7 @@ void FOOTPRINT_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) WINDOW_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg ) { auto cfg = dynamic_cast( aCfg ); - wxASSERT( cfg ); + wxCHECK_MSG( cfg, nullptr, "config not existing" ); return &cfg->m_FootprintViewer; } diff --git a/pcbnew/router/pns_component_dragger.cpp b/pcbnew/router/pns_component_dragger.cpp index f70b25503b..d8746b2725 100644 --- a/pcbnew/router/pns_component_dragger.cpp +++ b/pcbnew/router/pns_component_dragger.cpp @@ -33,6 +33,9 @@ namespace PNS COMPONENT_DRAGGER::COMPONENT_DRAGGER( ROUTER* aRouter ) : DRAG_ALGO( aRouter ) { + // ensure all variables are initialized + m_dragStatus = false; + m_currentNode = nullptr; } diff --git a/pcbnew/router/pns_drag_algo.h b/pcbnew/router/pns_drag_algo.h index ca9b7beae8..3650b00f8c 100644 --- a/pcbnew/router/pns_drag_algo.h +++ b/pcbnew/router/pns_drag_algo.h @@ -43,7 +43,7 @@ class DRAG_ALGO : public ALGO_BASE { public: DRAG_ALGO( ROUTER* aRouter ) : - ALGO_BASE( aRouter ) + ALGO_BASE( aRouter ), m_world( nullptr ) { } diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index ea0353d30d..2f15de0cf6 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -91,6 +91,7 @@ SHOVE::SHOVE( NODE* aWorld, ROUTER* aRouter ) : m_draggedVia = NULL; m_iter = 0; m_multiLineMode = false; + m_restrictSpringbackTagId = 0; } @@ -672,7 +673,7 @@ bool SHOVE::pushSpringback( NODE* aNode, const OPT_BOX2I& aAffectedArea, VIA* aD st.m_seq = (m_nodeStack.empty() ? 1 : m_nodeStack.back().m_seq + 1); st.m_locked = false; - + m_nodeStack.push_back( st ); return true; diff --git a/pcbnew/router/pns_walkaround.h b/pcbnew/router/pns_walkaround.h index b0150290f3..ddef15db7c 100644 --- a/pcbnew/router/pns_walkaround.h +++ b/pcbnew/router/pns_walkaround.h @@ -53,6 +53,7 @@ public: m_recursiveCollision[0] = m_recursiveCollision[1] = false; m_iteration = 0; m_forceCw = false; + m_forceUniqueWindingDirection = false; } ~WALKAROUND() {};