From a550ff84db8ab04a5270dfcdede2ff58743137de Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 4 Mar 2015 10:26:00 +0100 Subject: [PATCH] Fix some coverity and cppcheck warnings (most are very minor issues: not initialized members and initialized but not used variables) --- common/build_version.cpp | 2 +- eeschema/lib_bezier.cpp | 6 +++--- eeschema/lib_polyline.cpp | 6 +++--- pagelayout_editor/page_layout_writer.cpp | 2 +- pcb_calculator/attenuators/attenuator_classes.cpp | 6 ++++++ pcb_calculator/transline/c_microstrip.cpp | 8 ++++++++ pcb_calculator/transline/coax.cpp | 7 +++++++ pcb_calculator/transline/coplanar.cpp | 7 +++++++ pcb_calculator/transline/microstrip.cpp | 7 +++++++ pcb_calculator/transline/rectwaveguide.cpp | 7 +++++++ pcb_calculator/transline/stripline.cpp | 7 +++++++ pcb_calculator/transline/transline.cpp | 7 +++++++ pcb_calculator/transline/twistedpair.cpp | 7 +++++++ pcb_calculator/transline_ident.cpp | 3 ++- pcbnew/autorouter/auto_place_footprints.cpp | 3 +++ 15 files changed, 76 insertions(+), 9 deletions(-) diff --git a/common/build_version.cpp b/common/build_version.cpp index b9e5868237..310ea40916 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -30,7 +30,7 @@ #endif #ifndef KICAD_BUILD_VERSION -# define KICAD_BUILD_VERSION "(after 2015-jan-16 BZR unknown)" +# define KICAD_BUILD_VERSION "(after 2015-mar-04 BZR unknown)" #endif /** diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 8744ff30b9..b1869fc5bf 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -90,9 +90,9 @@ bool LIB_BEZIER::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) return false; } - p = strtok( line + 2, " \t\n" ); - p = strtok( NULL, " \t\n" ); - p = strtok( NULL, " \t\n" ); + strtok( line + 2, " \t\n" ); // Skip field + strtok( NULL, " \t\n" ); // Skip field + strtok( NULL, " \t\n" ); // Skip field p = strtok( NULL, " \t\n" ); for( i = 0; i < ccount; i++ ) diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 8dae0a7580..23c1224c78 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -95,9 +95,9 @@ bool LIB_POLYLINE::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) return false; } - p = strtok( line + 2, " \t\n" ); - p = strtok( NULL, " \t\n" ); - p = strtok( NULL, " \t\n" ); + strtok( line + 2, " \t\n" ); // Skip field + strtok( NULL, " \t\n" ); // Skip field + strtok( NULL, " \t\n" ); // Skip field p = strtok( NULL, " \t\n" ); for( i = 0; i < ccount; i++ ) diff --git a/pagelayout_editor/page_layout_writer.cpp b/pagelayout_editor/page_layout_writer.cpp index 81d4f6b182..f2f539f0d3 100644 --- a/pagelayout_editor/page_layout_writer.cpp +++ b/pagelayout_editor/page_layout_writer.cpp @@ -58,7 +58,7 @@ class WORKSHEET_LAYOUT_IO protected: OUTPUTFORMATTER* m_out; - WORKSHEET_LAYOUT_IO() {} + WORKSHEET_LAYOUT_IO() { m_out = NULL; } virtual ~WORKSHEET_LAYOUT_IO() {} public: diff --git a/pcb_calculator/attenuators/attenuator_classes.cpp b/pcb_calculator/attenuators/attenuator_classes.cpp index ebec3d887e..058d0dd2f6 100644 --- a/pcb_calculator/attenuators/attenuator_classes.cpp +++ b/pcb_calculator/attenuators/attenuator_classes.cpp @@ -37,6 +37,12 @@ ATTENUATOR::ATTENUATOR( ATTENUATORS_TYPE aTopology ) m_MinimumATT = 0.0; // dB m_SchBitMap = NULL; m_FormulaBitMap = NULL; + + // Initialize these variables mainly to avoid warnings from a static analyzer + m_R1 = 0.0; + m_R2 = 0.0; + m_R3 = 0.0; + Lmin = L = A = 0.0; // internal variable for temporary use } diff --git a/pcb_calculator/transline/c_microstrip.cpp b/pcb_calculator/transline/c_microstrip.cpp index 154f8edc03..624fe64e9f 100644 --- a/pcb_calculator/transline/c_microstrip.cpp +++ b/pcb_calculator/transline/c_microstrip.cpp @@ -40,6 +40,14 @@ C_MICROSTRIP::C_MICROSTRIP() : TRANSLINE() { m_name = "Coupled_MicroStrip"; aux_ms = NULL; + + // Initialize these variables mainly to avoid warnings from a static analyzer + er_eff = 0.0; // dummy + w_eff = 0.0; // Effective width of line + atten_dielectric_e = 0.0; // even-mode dielectric losses (dB) + atten_cond_e = 0.0; // even-mode conductors losses (dB) + atten_dielectric_o = 0.0; // odd-mode conductors losses (dB) + atten_cond_o = 0.0; // odd-mode conductors losses (dB) } diff --git a/pcb_calculator/transline/coax.cpp b/pcb_calculator/transline/coax.cpp index ac336b7480..d325dd0982 100644 --- a/pcb_calculator/transline/coax.cpp +++ b/pcb_calculator/transline/coax.cpp @@ -41,6 +41,13 @@ COAX::COAX() : TRANSLINE() { m_name = "Coax"; + + // Initialize these variables mainly to avoid warnings from a static analyzer + Z0 = 0.0; // characteristic impedance + ang_l = 0.0; // Electrical length in angle + atten_dielectric = 0.0; // Loss in dielectric (dB) + atten_cond = 0.0; // Loss in conductors (dB) + fc = 0.0; // Cutoff frequency for higher order modes } diff --git a/pcb_calculator/transline/coplanar.cpp b/pcb_calculator/transline/coplanar.cpp index 3bfd16eba9..dbca49e08c 100644 --- a/pcb_calculator/transline/coplanar.cpp +++ b/pcb_calculator/transline/coplanar.cpp @@ -36,6 +36,13 @@ COPLANAR::COPLANAR() : TRANSLINE() { m_name = "CoPlanar"; backMetal = false; + + // Initialize these variables mainly to avoid warnings from a static analyzer + Z0 = 0.0; // characteristic impedance + ang_l = 0.0; // Electrical length in angle + atten_dielectric = 0.0; // Loss in dielectric (dB) + atten_cond = 0.0; // Loss in conductors (dB) + er_eff = 1.0; // Effective dielectric constant } diff --git a/pcb_calculator/transline/microstrip.cpp b/pcb_calculator/transline/microstrip.cpp index cc06d584a1..a7800f9bb1 100644 --- a/pcb_calculator/transline/microstrip.cpp +++ b/pcb_calculator/transline/microstrip.cpp @@ -41,6 +41,13 @@ MICROSTRIP::MICROSTRIP() : TRANSLINE() { m_name = "MicroStrip"; + + // Initialize these variables mainly to avoid warnings from a static analyzer + mur_eff = 0.0; // Effective mag. permeability + w_eff = 0.0; // Effective width of line + atten_dielectric = 0.0; // Loss in dielectric (dB) + atten_cond = 0.0; // Loss in conductors (dB) + Z0_h_1 = 0.0; // homogeneous stripline impedance } diff --git a/pcb_calculator/transline/rectwaveguide.cpp b/pcb_calculator/transline/rectwaveguide.cpp index d325331fba..1e7f5a9834 100644 --- a/pcb_calculator/transline/rectwaveguide.cpp +++ b/pcb_calculator/transline/rectwaveguide.cpp @@ -32,6 +32,13 @@ RECTWAVEGUIDE::RECTWAVEGUIDE() : TRANSLINE() { m_name = "RectWaveGuide"; + + // Initialize these here variables mainly to avoid warnings from a static analyzer + er_eff = 0.0; // Effective dielectric constant + mur_eff = 0.0; // Effective mag. permeability + atten_dielectric = 0.0; // Loss in dielectric (dB) + atten_cond = 0.0; // Loss in conductors (dB) + fc10 = 0.0; // Cutoff frequency for TE10 mode } diff --git a/pcb_calculator/transline/stripline.cpp b/pcb_calculator/transline/stripline.cpp index f44e311ca8..bc6f59b541 100644 --- a/pcb_calculator/transline/stripline.cpp +++ b/pcb_calculator/transline/stripline.cpp @@ -34,6 +34,13 @@ STRIPLINE::STRIPLINE() : TRANSLINE() { m_name = "StripLine"; + + // Initialize these variables mainly to avoid warnings from a static analyzer + Z0 = 0.0; // characteristic impedance + ang_l = 0.0; // Electrical length in angle + er_eff = 0.0; // effective dielectric constant + atten_dielectric = 0.0; // Loss in dielectric (dB) + atten_cond = 0.0; // Loss in conductors (dB) } diff --git a/pcb_calculator/transline/transline.cpp b/pcb_calculator/transline/transline.cpp index 8d65ca00d4..fe608cbb07 100644 --- a/pcb_calculator/transline/transline.cpp +++ b/pcb_calculator/transline/transline.cpp @@ -62,6 +62,13 @@ TRANSLINE::TRANSLINE() { murC = 1.0; m_name = (const char*) 0; + + // Initialize these variables mainly to avoid warnings from a static analyzer + f = 0.0; // Frequency of operation + er = 0.0; // dielectric constant + tand = 0.0; // Dielectric Loss Tangent + sigma = 0.0; // Conductivity of the metal + skindepth = 0.0; // Skin depth } diff --git a/pcb_calculator/transline/twistedpair.cpp b/pcb_calculator/transline/twistedpair.cpp index c75130d034..0a7c5408ea 100644 --- a/pcb_calculator/transline/twistedpair.cpp +++ b/pcb_calculator/transline/twistedpair.cpp @@ -34,6 +34,13 @@ TWISTEDPAIR::TWISTEDPAIR() : TRANSLINE() { m_name = "TwistedPair"; + + // Initialize these variables mainly to avoid warnings from a static analyzer + Z0 = 0.0; // characteristic impedance + ang_l = 0.0; // Electrical length in angle + atten_dielectric = 0.0; // Loss in dielectric (dB) + atten_cond = 0.0; // Loss in conductors (dB) + er_eff = 1.0; // Effective dielectric constant } diff --git a/pcb_calculator/transline_ident.cpp b/pcb_calculator/transline_ident.cpp index 91b7974bde..36cd44854a 100644 --- a/pcb_calculator/transline_ident.cpp +++ b/pcb_calculator/transline_ident.cpp @@ -72,7 +72,8 @@ TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, m_ValueCtrl = NULL; m_UnitCtrl = NULL; m_UnitSelection = 0; -} + m_NormalizedValue = 0; + } #define TRANSLINE_PRM_KEY wxT( "translineprm%d" ) diff --git a/pcbnew/autorouter/auto_place_footprints.cpp b/pcbnew/autorouter/auto_place_footprints.cpp index db39ee93ba..277aaca1bc 100644 --- a/pcbnew/autorouter/auto_place_footprints.cpp +++ b/pcbnew/autorouter/auto_place_footprints.cpp @@ -690,7 +690,10 @@ int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame, MODULE* aModule, wxDC* aD if( aFrame->GetCanvas()->GetAbortRequest() ) { if( IsOK( aFrame, _( "OK to abort?" ) ) ) + { + displ_opts->m_Show_Module_Ratsnest = showRats; return ESC; + } else aFrame->GetCanvas()->SetAbortRequest( false ); }