From 1c3df973d6a480277f0853caad0e7e255981c929 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 10 Jun 2021 10:34:27 +0200 Subject: [PATCH] Coverity warnings fixes. --- .../shapes2D/polygon_2d.h | 4 +- eeschema/dialogs/dialog_edit_label.cpp | 40 ++++++++++++++----- eeschema/dialogs/dialog_edit_label.h | 24 ++--------- include/gal/cairo/cairo_gal.h | 2 +- pcbnew/dialogs/dialog_board_reannotate.cpp | 4 +- pcbnew/dialogs/dialog_board_reannotate.h | 1 - 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/polygon_2d.h b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/polygon_2d.h index 544b15d287..a176292d9b 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/polygon_2d.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/polygon_2d.h @@ -38,8 +38,8 @@ typedef struct { SFVEC2F m_Start; - float m_inv_JY_minus_IY; - float m_JX_minus_IX; + float m_inv_JY_minus_IY = 0.0; + float m_JX_minus_IX = 0.0; } POLYSEGMENT; diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 1d83bd73d4..06f2c4e87a 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -53,15 +53,6 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe m_Parent = aParent; m_CurrentText = aTextItem; - switch( m_CurrentText->Type() ) - { - case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break; - case SCH_HIER_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break; - case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break; - case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break; - default: SetTitle( _( "Text Properties" ) ); break; - } - m_valueMultiLine->SetEOLMode( wxSTC_EOL_LF ); m_scintillaTricks = new SCINTILLA_TRICKS( m_valueMultiLine, wxT( "()" ) ); @@ -104,6 +95,15 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe m_valueCombo->SetValidator( m_netNameValidator ); } + switch( m_CurrentText->Type() ) + { + case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break; + case SCH_HIER_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break; + case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break; + case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break; + default: SetTitle( _( "Text Properties" ) ); break; + } + SetInitialFocus( m_activeTextCtrl ); m_TextShape->Show( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T || @@ -155,6 +155,28 @@ DIALOG_LABEL_EDITOR::~DIALOG_LABEL_EDITOR() } +void DIALOG_LABEL_EDITOR::SetTitle( const wxString& aTitle ) +{ + // This class is shared for numerous tasks: a couple of single line labels and + // multi-line text fields. Since the desired size of the multi-line text field editor + // is often larger, we retain separate sizes based on the dialog titles. + switch( m_CurrentText->Type() ) + { + case SCH_GLOBAL_LABEL_T: + case SCH_HIER_LABEL_T: + case SCH_LABEL_T: + // labels can share retained settings probably. + break; + + default: + m_hash_key = TO_UTF8( aTitle ); + m_hash_key += typeid(*this).name(); + } + + DIALOG_LABEL_EDITOR_BASE::SetTitle( aTitle ); +} + + bool DIALOG_LABEL_EDITOR::TransferDataToWindow() { if( !wxDialog::TransferDataToWindow() ) diff --git a/eeschema/dialogs/dialog_edit_label.h b/eeschema/dialogs/dialog_edit_label.h index 8652156662..4c46ad07f1 100644 --- a/eeschema/dialogs/dialog_edit_label.h +++ b/eeschema/dialogs/dialog_edit_label.h @@ -42,26 +42,10 @@ public: DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem ); ~DIALOG_LABEL_EDITOR(); - void SetTitle( const wxString& aTitle ) override - { - // This class is shared for numerous tasks: a couple of single line labels and - // multi-line text fields. Since the desired size of the multi-line text field editor - // is often larger, we retain separate sizes based on the dialog titles. - switch( m_CurrentText->Type() ) - { - case SCH_GLOBAL_LABEL_T: - case SCH_HIER_LABEL_T: - case SCH_LABEL_T: - // labels can share retained settings probably. - break; - - default: - m_hash_key = TO_UTF8( aTitle ); - m_hash_key += typeid(*this).name(); - } - - DIALOG_LABEL_EDITOR_BASE::SetTitle( aTitle ); - } + // This class is shared for numerous tasks: a couple of single line labels and + // multi-line text fields. Since the desired size of the multi-line text field editor + // is often larger, we retain separate sizes based on the dialog titles. + void SetTitle( const wxString& aTitle ) override; private: void onScintillaCharAdded( wxStyledTextEvent &aEvent ); diff --git a/include/gal/cairo/cairo_gal.h b/include/gal/cairo/cairo_gal.h index af3211d0c7..00033ff705 100644 --- a/include/gal/cairo/cairo_gal.h +++ b/include/gal/cairo/cairo_gal.h @@ -316,7 +316,7 @@ protected: union { double DblArg[MAX_CAIRO_ARGUMENTS]; ///< Arguments for Cairo commands bool BoolArg; ///< A bool argument - int IntArg; ///< An int argument + int IntArg = 0; ///< An int argument } m_Argument; cairo_path_t* m_CairoPath = nullptr; ///< Pointer to a Cairo path } GROUP_ELEMENT; diff --git a/pcbnew/dialogs/dialog_board_reannotate.cpp b/pcbnew/dialogs/dialog_board_reannotate.cpp index 8bfd5feade..789a3fea94 100644 --- a/pcbnew/dialogs/dialog_board_reannotate.cpp +++ b/pcbnew/dialogs/dialog_board_reannotate.cpp @@ -102,12 +102,10 @@ DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE( PCB_EDIT_FRAME* aParentFrame ) : DIALOG_BOARD_REANNOTATE_BASE( aParentFrame ), m_footprints( aParentFrame->GetBoard()->Footprints() ) { + m_frame = aParentFrame; m_Config = Kiface().KifaceSettings(); InitValues(); - m_frame = aParentFrame; - m_screen = m_frame->GetScreen(); - m_FrontRefDesStart->SetValidator( wxTextValidator( wxFILTER_DIGITS ) ); m_BackRefDesStart->SetValidator( wxTextValidator( wxFILTER_DIGITS ) ); diff --git a/pcbnew/dialogs/dialog_board_reannotate.h b/pcbnew/dialogs/dialog_board_reannotate.h index 45b2ba5420..5695021426 100644 --- a/pcbnew/dialogs/dialog_board_reannotate.h +++ b/pcbnew/dialogs/dialog_board_reannotate.h @@ -182,7 +182,6 @@ private: PCB_EDIT_FRAME* m_frame; FOOTPRINTS m_footprints; - PCB_SCREEN* m_screen; PCB_SELECTION m_selection; std::vector m_changeArray;