From b3b791961acdeea11a75c6a4e0a2f0f7278d8dc3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Mar 2015 17:04:20 +0100 Subject: [PATCH] coverity common folder fixes (mainly not initialized members). --- CMakeModules/TokenList2DsnLexer.cmake | 10 +++------- common/class_layer_box_selector.cpp | 8 +++----- common/common_plotHPGL_functions.cpp | 4 +++- common/dsnlexer.cpp | 16 ++++++++++++++++ common/richio.cpp | 19 +++++++------------ common/tool/tool_dispatcher.cpp | 3 +++ common/tool/tool_manager.cpp | 6 +++++- common/wx_unit_binder.cpp | 14 +++++++++----- eeschema/schedit.cpp | 2 ++ .../dialog_pns_length_tuning_settings.cpp | 2 +- 10 files changed, 52 insertions(+), 32 deletions(-) diff --git a/CMakeModules/TokenList2DsnLexer.cmake b/CMakeModules/TokenList2DsnLexer.cmake index df2ea8adf9..d11bc5c741 100644 --- a/CMakeModules/TokenList2DsnLexer.cmake +++ b/CMakeModules/TokenList2DsnLexer.cmake @@ -374,14 +374,10 @@ const char* ${LEXERCLASS}::TokenName( T aTok ) { const char* ret; - if( (unsigned) aTok < keyword_count ) - { - ret = keywords[aTok].name; - } - else if( aTok < 0 ) - { + if( aTok < 0 ) ret = DSNLEXER::Syntax( aTok ); - } + else if( (unsigned) aTok < keyword_count ) + ret = keywords[aTok].name; else ret = \"token too big\"; diff --git a/common/class_layer_box_selector.cpp b/common/class_layer_box_selector.cpp index 885479a631..9916157bfe 100644 --- a/common/class_layer_box_selector.cpp +++ b/common/class_layer_box_selector.cpp @@ -35,10 +35,10 @@ #include -LAYER_SELECTOR::LAYER_SELECTOR() +LAYER_SELECTOR::LAYER_SELECTOR() : + m_layerhotkeys( true ), + m_hotkeys( NULL ) { - m_layerhotkeys = true; - m_hotkeys = NULL; } @@ -81,8 +81,6 @@ LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id, { if( choices != NULL ) ResyncBitmapOnly(); - - m_hotkeys = NULL; } diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp index 81b462de4f..514b53df3b 100644 --- a/common/common_plotHPGL_functions.cpp +++ b/common/common_plotHPGL_functions.cpp @@ -203,8 +203,10 @@ static const double PLUsPERDECIMIL = 0.102041; HPGL_PLOTTER::HPGL_PLOTTER() { - SetPenSpeed( 40 ); // Default pen speed = 40 cm/s + SetPenSpeed( 40 ); // Default pen speed = 40 cm/s; Pen speed is *always* in cm SetPenNumber( 1 ); // Default pen num = 1 + SetPenDiameter( 0.0 ); + SetPenOverlap( 0.0 ); } void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp index e6d9e9319c..2211427dd0 100644 --- a/common/dsnlexer.cpp +++ b/common/dsnlexer.cpp @@ -76,6 +76,10 @@ void DSNLEXER::init() DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, FILE* aFile, const wxString& aFilename ) : iOwnReaders( true ), + start( NULL ), + next( NULL ), + limit( NULL ), + reader( NULL ), keywords( aKeywordTable ), keywordCount( aKeywordCount ) { @@ -88,6 +92,10 @@ DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, const std::string& aClipboardTxt, const wxString& aSource ) : iOwnReaders( true ), + start( NULL ), + next( NULL ), + limit( NULL ), + reader( NULL ), keywords( aKeywordTable ), keywordCount( aKeywordCount ) { @@ -101,6 +109,10 @@ DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, LINE_READER* aLineReader ) : iOwnReaders( false ), + start( NULL ), + next( NULL ), + limit( NULL ), + reader( NULL ), keywords( aKeywordTable ), keywordCount( aKeywordCount ) { @@ -114,6 +126,10 @@ static const KEYWORD empty_keywords[1] = {}; DSNLEXER::DSNLEXER( const std::string& aSExpression, const wxString& aSource ) : iOwnReaders( true ), + start( NULL ), + next( NULL ), + limit( NULL ), + reader( NULL ), keywords( empty_keywords ), keywordCount( 0 ) { diff --git a/common/richio.cpp b/common/richio.cpp index ec1cf8c57d..344becbbff 100644 --- a/common/richio.cpp +++ b/common/richio.cpp @@ -120,18 +120,15 @@ void PARSE_ERROR::init( const char* aThrowersFile, const char* aThrowersLoc, //----------------------------------------------------------- -LINE_READER::LINE_READER( unsigned aMaxLineLength ) +LINE_READER::LINE_READER( unsigned aMaxLineLength ) : + length( 0 ), + lineNum( 0 ), + line( NULL ), + capacity( 0 ), + maxLineLength( aMaxLineLength ) { - lineNum = 0; - - if( aMaxLineLength == 0 ) + if( aMaxLineLength != 0 ) { - line = 0; - } - else - { - maxLineLength = aMaxLineLength; - // start at the INITIAL size, expand as needed up to the MAX size in maxLineLength capacity = LINE_READER_LINE_INITIAL_SIZE; @@ -143,8 +140,6 @@ LINE_READER::LINE_READER( unsigned aMaxLineLength ) line[0] = '\0'; } - - length = 0; } diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index 7166f6596d..7b3131e3ac 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -42,6 +42,9 @@ struct TOOL_DISPATCHER::BUTTON_STATE { BUTTON_STATE( TOOL_MOUSE_BUTTONS aButton, const wxEventType& aDownEvent, const wxEventType& aUpEvent, const wxEventType& aDblClickEvent ) : + dragging( false ), + pressed( false ), + dragMaxDelta( 0.0f ), button( aButton ), downEvent( aDownEvent ), upEvent( aUpEvent ), diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 39ce08fe32..ff6ada4725 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -195,7 +195,11 @@ private: TOOL_MANAGER::TOOL_MANAGER() : - m_model( NULL ), m_view( NULL ), m_viewControls( NULL ), m_editFrame( NULL ) + m_model( NULL ), + m_view( NULL ), + m_viewControls( NULL ), + m_editFrame( NULL ), + m_passEvent( false ) { m_actionMgr = new ACTION_MANAGER( this ); diff --git a/common/wx_unit_binder.cpp b/common/wx_unit_binder.cpp index 90a66ae12e..9498d3a232 100644 --- a/common/wx_unit_binder.cpp +++ b/common/wx_unit_binder.cpp @@ -35,13 +35,17 @@ #include "wx_unit_binder.h" -WX_UNIT_BINDER::WX_UNIT_BINDER( wxWindow* aParent, wxTextCtrl* aTextInput, wxStaticText* aUnitLabel, wxSpinButton* aSpinButton ) +WX_UNIT_BINDER::WX_UNIT_BINDER( wxWindow* aParent, wxTextCtrl* aTextInput, + wxStaticText* aUnitLabel, wxSpinButton* aSpinButton ) : + m_textCtrl( aTextInput ), + m_unitLabel( aUnitLabel ), + m_units( g_UserUnit ), + m_step( 1 ), + m_min( 0 ), + m_max( 1 ) { // Use the currently selected units - m_units = g_UserUnit; - m_textCtrl = aTextInput; m_textCtrl->SetValue( wxT( "0" ) ); - m_unitLabel = aUnitLabel; m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); } @@ -73,4 +77,4 @@ void WX_UNIT_BINDER::Enable( bool aEnable ) { m_textCtrl->Enable( aEnable ); m_unitLabel->Enable( aEnable ); -} \ No newline at end of file +} diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 521cb18fa2..8e0df2b4d3 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -459,6 +459,8 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) // Moving a marker has no sense wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ), GetChars( item->GetClass() ) ) ); + break; + default: // Unknown items cannot be moved wxFAIL_MSG( wxString::Format( diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp index b817a0b1a4..dccb74e815 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp @@ -99,7 +99,7 @@ void DIALOG_PNS_LENGTH_TUNING_SETTINGS::OnOkClick( wxCommandEvent& aEvent ) m_settings.m_targetLength = m_targetLength.GetValue(); if( m_settings.m_maxAmplitude < m_settings.m_minAmplitude ) - m_settings.m_maxAmplitude = m_settings.m_maxAmplitude; + m_settings.m_maxAmplitude = m_settings.m_minAmplitude; m_settings.m_cornerType = m_miterStyle->GetSelection() ? PNS_MEANDER_SETTINGS::CHAMFER : PNS_MEANDER_SETTINGS::ROUND;