From c0a539959e0f72698d1506bb79af7e36ac11826e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 4 Dec 2017 10:20:05 +0100 Subject: [PATCH] Fix a few Coverity warnings --- eeschema/cmp_tree_model.cpp | 2 +- .../dialogs/dialog_edit_components_libid.cpp | 1 + eeschema/hierarch.cpp | 4 ++- gerbview/tools/selection_tool.cpp | 2 ++ pcbnew/import_dxf/dialog_dxf_import.cpp | 2 ++ pcbnew/kicad_clipboard.cpp | 2 +- qa/common/mocks.cpp | 26 ++++++++++++++++++- 7 files changed, 35 insertions(+), 4 deletions(-) diff --git a/eeschema/cmp_tree_model.cpp b/eeschema/cmp_tree_model.cpp index 75b2b973cd..335339d76e 100644 --- a/eeschema/cmp_tree_model.cpp +++ b/eeschema/cmp_tree_model.cpp @@ -164,7 +164,7 @@ CMP_TREE_NODE_LIB_ID::CMP_TREE_NODE_LIB_ID( CMP_TREE_NODE* aParent, LIB_ALIAS* a SearchText += footprint.Lower(); } - if( part->IsMulti() ) + if( part && part->IsMulti() ) { for( int u = 1; u <= part->GetUnitCount(); ++u ) { diff --git a/eeschema/dialogs/dialog_edit_components_libid.cpp b/eeschema/dialogs/dialog_edit_components_libid.cpp index d440fc734c..22763c404b 100644 --- a/eeschema/dialogs/dialog_edit_components_libid.cpp +++ b/eeschema/dialogs/dialog_edit_components_libid.cpp @@ -58,6 +58,7 @@ public: m_InitialLibId = m_Component->GetLibId().Format(); m_Row = -1; m_IsOrphan = false; + m_Screen = nullptr; } // Returns a string like mylib:symbol_name from the LIB_ID of the component diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index c65f388c4d..2771369970 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -243,7 +243,9 @@ void HIERARCHY_NAVIG_DLG::BuildTree( SCH_SHEET_PATH* list, wxTreeItemId* previo m_TreeSize.x = std::max( m_TreeSize.x, ll ); m_TreeSize.y += 1; - if( *list == dynamic_cast< SCH_EDIT_FRAME* >( GetParent() )->GetCurrentSheet() ) + SCH_EDIT_FRAME* parent = dynamic_cast< SCH_EDIT_FRAME* >( GetParent() ); + + if( parent && *list == parent->GetCurrentSheet() ) { m_Tree->EnsureVisible( menu ); m_Tree->SelectItem( menu ); diff --git a/gerbview/tools/selection_tool.cpp b/gerbview/tools/selection_tool.cpp index a2cba93aa7..a362f2f8ad 100644 --- a/gerbview/tools/selection_tool.cpp +++ b/gerbview/tools/selection_tool.cpp @@ -144,6 +144,8 @@ GERBVIEW_SELECTION_TOOL::GERBVIEW_SELECTION_TOOL() : m_multiple( false ), m_menu( *this ) { + // these members are initialized to avoid warnings about non initialized vars + m_preliminary = true; } diff --git a/pcbnew/import_dxf/dialog_dxf_import.cpp b/pcbnew/import_dxf/dialog_dxf_import.cpp index 1d8e113efd..f5fe2dea13 100644 --- a/pcbnew/import_dxf/dialog_dxf_import.cpp +++ b/pcbnew/import_dxf/dialog_dxf_import.cpp @@ -66,6 +66,8 @@ DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent, bool aImportAsFoo m_PcbImportUnits = 0; m_PcbImportOffsetX = 0.0; // always in mm m_PcbImportOffsetY = 0.0; // always in mm + m_PCBdefaultLineWidth = 0.2; // in mm + m_PCBLineWidthUnits = 0; if( m_config ) { diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 07a621f741..1bcfc32887 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -308,7 +308,7 @@ BOARD* CLIPBOARD_IO::Load( const wxString& aFileName, } // Give the filename to the board if it's new - if( !aAppendToMe ) + if( board && !aAppendToMe ) board->SetFileName( aFileName ); return board; diff --git a/qa/common/mocks.cpp b/qa/common/mocks.cpp index f5a208cf90..2fb6ebac23 100644 --- a/qa/common/mocks.cpp +++ b/qa/common/mocks.cpp @@ -198,9 +198,12 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxString DIALOG_FIND::prevSearchString; bool DIALOG_FIND::warpMouse = true; - DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME* aParent ) : DIALOG_FIND_BASE( aParent ) { + // these members are initialized to avoid warnings about non initialized vars + parent = aParent; + itemCount = markerCount = 0; + foundItem = nullptr; } @@ -241,6 +244,13 @@ DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { + // these members are initialized only to avoid warnings about non initialized vars + m_staticText1 = nullptr; + m_SearchTextCtrl = nullptr; + m_NoMouseWarpCheckBox = nullptr; + m_button1 = nullptr; + m_button2 = nullptr; + m_button3 = nullptr; } @@ -280,6 +290,20 @@ DIALOG_BLOCK_OPTIONS_BASE::DIALOG_BLOCK_OPTIONS_BASE( wxWindow* parent, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { + // these members are initialized only to avoid warnings about non initialized vars + m_Include_Modules = nullptr; + m_Include_PcbTextes = nullptr; + m_IncludeLockedModules = nullptr; + m_Include_Draw_Items = nullptr; + m_Include_Tracks = nullptr; + m_Include_Edges_Items = nullptr; + m_Include_Zones = nullptr; + m_DrawBlockItems = nullptr; + m_staticline1 = nullptr; + m_checkBoxIncludeInvisible = nullptr; + m_sdbSizer1 = nullptr; + m_sdbSizer1OK = nullptr; + m_sdbSizer1Cancel = nullptr; }