From 4d9d1a538063cf10b2d01941cb39f6987b7f56cd Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 22 Mar 2020 09:45:51 +0100 Subject: [PATCH] Fix a few compil minor warnings and Coverity minor issues --- common/eda_base_frame.cpp | 2 +- common/marker_base.cpp | 2 +- eeschema/autoplace_fields.cpp | 3 +++ eeschema/dialogs/dialog_fields_editor_global.cpp | 7 ++++--- eeschema/dialogs/panel_setup_pinmap.cpp | 4 ++-- gerbview/gerbview_frame.cpp | 2 ++ pcbnew/pcb_base_frame.cpp | 2 +- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 7a625e9f28..e26f6a8483 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -680,7 +680,7 @@ void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event ) if( manager ) static_cast( manager )->InstallPreferences( &dlg, hotkeysPanel ); - for( int i = 0; i < book->GetPageCount(); ++i ) + for( size_t i = 0; i < book->GetPageCount(); ++i ) book->GetPage( i )->Layout(); if( dlg.ShowModal() == wxID_OK ) diff --git a/common/marker_base.cpp b/common/marker_base.cpp index a8cbd35d67..486417c3d3 100644 --- a/common/marker_base.cpp +++ b/common/marker_base.cpp @@ -69,7 +69,7 @@ MARKER_BASE::MARKER_BASE( int aScalingFactor, RC_ITEM* aItem, TYPEMARKER aType ) wxPoint start( point_shape->x, point_shape->y ); wxPoint end = start; - for( int ii = 1; ii < CORNERS_COUNT; ii++ ) + for( unsigned ii = 1; ii < CORNERS_COUNT; ii++ ) { ++point_shape; start.x = std::min( start.x, point_shape->x); diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index 60486690a2..80bcd8198e 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -131,6 +131,9 @@ public: auto cfg = dynamic_cast( Kiface().KifaceSettings() ); wxASSERT( cfg ); + m_allow_rejustify = false; + m_align_to_grid = true; + if( cfg ) { m_allow_rejustify = cfg->m_AutoplaceFields.allow_rejustify; diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp index 2fa584bffb..40db962dd5 100644 --- a/eeschema/dialogs/dialog_fields_editor_global.cpp +++ b/eeschema/dialogs/dialog_fields_editor_global.cpp @@ -884,7 +884,7 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::AddField( const wxString& aName, wxVector fieldsCtrlRow; - auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + auto cfg = static_cast( Kiface().KifaceSettings() ); bool show = defaultShow; bool sort_by = defaultSortBy; @@ -932,6 +932,7 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::LoadFieldNames() // Force References to always be shown auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + wxASSERT( cfg ); cfg->m_FieldEditorPanel.fields_show["Reference"] = true; // *DO NOT* use translated mandatory field names: @@ -986,7 +987,7 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnAddField( wxCommandEvent& event ) std::string key( fieldName.ToUTF8() ); - auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + auto cfg = static_cast( Kiface().KifaceSettings() ); cfg->m_FieldEditorPanel.fields_show[key] = true; AddField( fieldName, true, false ); @@ -1006,7 +1007,7 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnAddField( wxCommandEvent& event ) void DIALOG_FIELDS_EDITOR_GLOBAL::OnColumnItemToggled( wxDataViewEvent& event ) { - auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + auto cfg = static_cast( Kiface().KifaceSettings() ); wxDataViewItem item = event.GetItem(); int row = m_fieldsCtrl->ItemToRow( item ); diff --git a/eeschema/dialogs/panel_setup_pinmap.cpp b/eeschema/dialogs/panel_setup_pinmap.cpp index 74e2b84447..666033760f 100644 --- a/eeschema/dialogs/panel_setup_pinmap.cpp +++ b/eeschema/dialogs/panel_setup_pinmap.cpp @@ -148,8 +148,8 @@ void PANEL_SETUP_PINMAP::ReBuildMatrixPanel() wxPoint txtpos; txtpos.x = x + (bitmap_size.x / 2); txtpos.y = y - text_height; - WX_ANGLE_TEXT* txt = new WX_ANGLE_TEXT( m_matrixPanel, wxID_ANY, CommentERC_V[ii], - txtpos, 450 ); + new WX_ANGLE_TEXT( m_matrixPanel, wxID_ANY, CommentERC_V[ii], + txtpos, 450 ); } int event_id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 3081f21c1c..bb5ec9f8ac 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -309,6 +309,7 @@ void GERBVIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) EDA_DRAW_FRAME::LoadSettings( aCfg ); GERBVIEW_SETTINGS* cfg = dynamic_cast( aCfg ); + wxCHECK( cfg, /*void*/ ); SetElementVisibility( LAYER_WORKSHEET, cfg->m_Appearance.show_border_and_titleblock ); @@ -330,6 +331,7 @@ void GERBVIEW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) EDA_DRAW_FRAME::SaveSettings( aCfg ); GERBVIEW_SETTINGS* cfg = dynamic_cast( aCfg ); + wxCHECK( cfg, /*void*/ ); cfg->m_Appearance.page_type = GetPageSettings().GetType(); cfg->m_Appearance.show_border_and_titleblock = m_showBorderAndTitleBlock; diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index dc76de9566..d2af3ba93a 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -745,7 +745,7 @@ void PCB_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) EDA_DRAW_FRAME::SaveSettings( aCfg ); auto cfg = dynamic_cast( aCfg ); - wxASSERT( cfg ); + wxCHECK( cfg, /*void*/ ); cfg->m_UserGrid.size_x = To_User_Unit( m_userUnits, m_UserGridSize.x ); cfg->m_UserGrid.size_y = To_User_Unit( m_userUnits, m_UserGridSize.y );