← Back to team overview

kicad-developers team mailing list archive

[PATCH] Some warning fixes

 

Hi,

I've attached some patches to quiet warnings. Additionally number 0002
may actually fix a genuine uninitialized access. Any objections to
pushing these?

-- 
Chris
>From c3c826dd03f6d6e8858a7d102142931e8e617d8b Mon Sep 17 00:00:00 2001
From: Chris Pavlina <pavlina.chris@xxxxxxxxx>
Date: Fri, 30 Sep 2016 00:05:41 -0400
Subject: [PATCH 1/7] Dismiss unused variable warning in ratsnest_data.cpp

---
 pcbnew/ratsnest_data.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pcbnew/ratsnest_data.cpp b/pcbnew/ratsnest_data.cpp
index 3f1d448..0302c97 100644
--- a/pcbnew/ratsnest_data.cpp
+++ b/pcbnew/ratsnest_data.cpp
@@ -2,6 +2,7 @@
  * This program source code file is part of KICAD, a free EDA CAD application.
  *
  * Copyright (C) 2013-2015 CERN
+ * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
  * @author Maciej Suminski <maciej.suminski@xxxxxxx>
  *
  * This program is free software; you can redistribute it and/or
@@ -1201,6 +1202,7 @@ bool RN_DATA::Update( const BOARD_ITEM* aItem )
     {
         bool res = Add( aItem );
         assert( res );
+        (void) res;
         return true;
     }
 
-- 
2.10.0

>From 43ead51efa3c3efe03023ca6e7c3610c0bc6bf44 Mon Sep 17 00:00:00 2001
From: Chris Pavlina <pavlina.chris@xxxxxxxxx>
Date: Fri, 30 Sep 2016 00:31:59 -0400
Subject: [PATCH 2/7] Fix uninitialized variable in drawing_tool.cpp

---
 pcbnew/tools/drawing_tool.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp
index 746041b..7ab44a9 100644
--- a/pcbnew/tools/drawing_tool.cpp
+++ b/pcbnew/tools/drawing_tool.cpp
@@ -2,6 +2,7 @@
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
  * Copyright (C) 2014 CERN
+ * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
  * @author Maciej Suminski <maciej.suminski@xxxxxxx>
  *
  * This program is free software; you can redistribute it and/or
@@ -605,7 +606,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
                 {
                     // Modules use different types for the same things,
                     // so we need to convert imported items to appropriate classes.
-                    BOARD_ITEM* converted;
+                    BOARD_ITEM* converted = NULL;
 
                     switch( item->Type() )
                     {
@@ -658,12 +659,15 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
                         break;
                     }
 
-                    converted->SetLayer( item->GetLayer() );
+                    if( converted )
+                        converted->SetLayer( item->GetLayer() );
+
                     delete item;
                     item = converted;
                 }
 
-                commit.Add( item );
+                if( item )
+                    commit.Add( item );
             }
 
             commit.Push( _( "Place a DXF drawing" ) );
-- 
2.10.0

>From 8fe190e4d8dfe90d4b55a4e69811f0a65f1fa8aa Mon Sep 17 00:00:00 2001
From: Chris Pavlina <pavlina.chris@xxxxxxxxx>
Date: Fri, 30 Sep 2016 01:31:48 -0400
Subject: [PATCH 3/7] Fix GetBoundingBox hiding overloaded virtual

---
 eeschema/class_libentry.cpp                  | 4 ++--
 eeschema/class_libentry.h                    | 7 ++++++-
 eeschema/dialogs/dialog_choose_component.cpp | 4 ++--
 eeschema/dialogs/dialog_rescue_each.cpp      | 6 +++---
 eeschema/libedit_plot_component.cpp          | 4 ++--
 eeschema/libeditframe.cpp                    | 2 +-
 eeschema/viewlib_frame.cpp                   | 4 ++--
 7 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp
index 9041ab9..3a63093 100644
--- a/eeschema/class_libentry.cpp
+++ b/eeschema/class_libentry.cpp
@@ -431,7 +431,7 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
     /* Enable this to draw the bounding box around the component to validate
      * the bounding box calculations. */
 #if 0
-    EDA_RECT bBox = GetBoundingBox( aMulti, aConvert );
+    EDA_RECT bBox = GetUnitBoundingBox( aMulti, aConvert );
     bBox.RevertYAxis();
     bBox = aTransform.TransformCoordinate( bBox );
     bBox.Move( aOffset );
@@ -1158,7 +1158,7 @@ bool LIB_PART::LoadFootprints( LINE_READER& aLineReader, wxString& aErrorMsg )
 }
 
 
-const EDA_RECT LIB_PART::GetBoundingBox( int aUnit, int aConvert ) const
+const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const
 {
     EDA_RECT bBox;
     bool initialized = false;
diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h
index 4cf3535..1e62251 100644
--- a/eeschema/class_libentry.h
+++ b/eeschema/class_libentry.h
@@ -291,7 +291,7 @@ public:
      *  if aConvert == 0 Convert is non used
      *  Invisible fields are not taken in account
      **/
-    const EDA_RECT GetBoundingBox( int aUnit, int aConvert ) const;
+    const EDA_RECT GetUnitBoundingBox( int aUnit, int aConvert ) const;
 
     /**
      * Function GetBodyBoundingBox
@@ -304,6 +304,11 @@ public:
      **/
     const EDA_RECT GetBodyBoundingBox( int aUnit, int aConvert ) const;
 
+    const EDA_RECT GetBoundingBox() const override
+    {
+        return GetUnitBoundingBox( 0, 0 );
+    }
+
     /**
      * Function SaveDateAndTime
      * write the date and time of part to \a aFile in the format:
diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp
index 3183c1d..b7aec6e 100644
--- a/eeschema/dialogs/dialog_choose_component.cpp
+++ b/eeschema/dialogs/dialog_choose_component.cpp
@@ -2,7 +2,7 @@
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
  * Copyright (C) 2014 Henner Zeller <h.zeller@xxxxxxx>
- * Copyright (C) 2014 KiCad Developers, see change_log.txt for contributors.
+ * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -344,7 +344,7 @@ void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit )
     dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
 
     // Find joint bounding box for everything we are about to draw.
-    EDA_RECT bBox = aComponent->GetBoundingBox( aUnit, m_deMorganConvert );
+    EDA_RECT bBox = aComponent->GetUnitBoundingBox( aUnit, m_deMorganConvert );
     const double xscale = (double) dc_size.x / bBox.GetWidth();
     const double yscale = (double) dc_size.y / bBox.GetHeight();
     const double scale  = std::min( xscale, yscale ) * 0.85;
diff --git a/eeschema/dialogs/dialog_rescue_each.cpp b/eeschema/dialogs/dialog_rescue_each.cpp
index 1c0b9e5..363b915 100644
--- a/eeschema/dialogs/dialog_rescue_each.cpp
+++ b/eeschema/dialogs/dialog_rescue_each.cpp
@@ -1,8 +1,8 @@
 /*
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
- * Copyright (C) 2015 Chris Pavlina <pavlina.chris@xxxxxxxxx>
- * Copyright (C) 2015 Kicad Developers, see change_log.txt for contributors.
+ * Copyright (C) 2015-2016 Chris Pavlina <pavlina.chris@xxxxxxxxx>
+ * Copyright (C) 2015-2016 Kicad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -222,7 +222,7 @@ void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel
     dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
 
     // Find joint bounding box for everything we are about to draw.
-    EDA_RECT bBox = aComponent->GetBoundingBox( aUnit, /* deMorganConvert */ 1 );
+    EDA_RECT bBox = aComponent->GetUnitBoundingBox( aUnit, /* deMorganConvert */ 1 );
     const double xscale = (double) dc_size.x / bBox.GetWidth();
     const double yscale = (double) dc_size.y / bBox.GetHeight();
     const double scale  = std::min( xscale, yscale ) * 0.85;
diff --git a/eeschema/libedit_plot_component.cpp b/eeschema/libedit_plot_component.cpp
index a7b70ba..afad54b 100644
--- a/eeschema/libedit_plot_component.cpp
+++ b/eeschema/libedit_plot_component.cpp
@@ -5,7 +5,7 @@
 /*
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
- * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -102,7 +102,7 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
             PAGE_INFO pageSave = GetScreen()->GetPageSettings();
             PAGE_INFO pageTemp = pageSave;
 
-            wxSize componentSize = part->GetBoundingBox( m_unit, m_convert ).GetSize();
+            wxSize componentSize = part->GetUnitBoundingBox( m_unit, m_convert ).GetSize();
 
             // Add a small margin to the plot bounding box
             pageTemp.SetWidthMils(  int( componentSize.x * 1.2 ) );
diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp
index e9256a6..ddd599c 100644
--- a/eeschema/libeditframe.cpp
+++ b/eeschema/libeditframe.cpp
@@ -369,7 +369,7 @@ double LIB_EDIT_FRAME::BestZoom()
 
     if( part )
     {
-        EDA_RECT boundingBox = part->GetBoundingBox( m_unit, m_convert );
+        EDA_RECT boundingBox = part->GetUnitBoundingBox( m_unit, m_convert );
 
         dx = boundingBox.GetWidth();
         dy = boundingBox.GetHeight();
diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp
index 36af402..c3a4886 100644
--- a/eeschema/viewlib_frame.cpp
+++ b/eeschema/viewlib_frame.cpp
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@xxxxxxxxxxx>
- * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
+ * Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -298,7 +298,7 @@ double LIB_VIEW_FRAME::BestZoom()
 
     wxSize size = m_canvas->GetClientSize();
 
-    EDA_RECT boundingBox = part->GetBoundingBox( m_unit, m_convert );
+    EDA_RECT boundingBox = part->GetUnitBoundingBox( m_unit, m_convert );
 
     // Reserve a 10% margin around component bounding box.
     double margin_scale_factor = 0.8;
-- 
2.10.0

>From a2ac274cbc24e2b29f55a0ef1af8d8d76efd6968 Mon Sep 17 00:00:00 2001
From: Chris Pavlina <pavlina.chris@xxxxxxxxx>
Date: Fri, 30 Sep 2016 01:34:25 -0400
Subject: [PATCH 4/7] Dismiss warning for inconsistent exception spec in
 ~KIWAY_PLAYER()

---
 common/kiway_player.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/kiway_player.cpp b/common/kiway_player.cpp
index a33acc1..b5df953 100644
--- a/common/kiway_player.cpp
+++ b/common/kiway_player.cpp
@@ -2,7 +2,7 @@
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
  * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@xxxxxxxxxxx>
- * Copyright (C) 2014-2015 KiCad Developers, see CHANGELOG.TXT for contributors.
+ * Copyright (C) 2014-2016 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -66,7 +66,7 @@ KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& a
 }
 
 
-KIWAY_PLAYER::~KIWAY_PLAYER(){}
+KIWAY_PLAYER::~KIWAY_PLAYER() throw() {}
 
 
 void KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent )
-- 
2.10.0

>From 0d5e688314ec4907924852cea87cc9ca2c00e940 Mon Sep 17 00:00:00 2001
From: Chris Pavlina <pavlina.chris@xxxxxxxxx>
Date: Fri, 30 Sep 2016 01:37:03 -0400
Subject: [PATCH 5/7] Dismiss signed index warning in opengl_gal.cpp

---
 common/gal/opengl/opengl_gal.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp
index 618343d..5be3c47 100644
--- a/common/gal/opengl/opengl_gal.cpp
+++ b/common/gal/opengl/opengl_gal.cpp
@@ -2,7 +2,7 @@
  * This program source code file is part of KICAD, a free EDA CAD application.
  *
  * Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
- * Copyright (C) 2012-2016 Kicad Developers, see change_log.txt for contributors.
+ * Copyright (C) 2012-2016 Kicad Developers, see AUTHORS.txt for contributors.
  * Copyright (C) 2013-2016 CERN
  * @author Maciej Suminski <maciej.suminski@xxxxxxx>
  *
@@ -1355,7 +1355,7 @@ int OPENGL_GAL::drawBitmapChar( unsigned long aChar )
 void OPENGL_GAL::drawBitmapOverbar( double aLength, double aHeight )
 {
     // To draw an overbar, simply draw an overbar
-    const bitmap_glyph& GLYPH = bitmap_chars['_'];
+    const bitmap_glyph& GLYPH = bitmap_chars[(unsigned char) '_'];
     const float H = GLYPH.maxy - GLYPH.miny;
 
     Save();
-- 
2.10.0

>From a3ce84a16b41612c1c296d852aa79c49ee3c96e3 Mon Sep 17 00:00:00 2001
From: Chris Pavlina <pavlina.chris@xxxxxxxxx>
Date: Fri, 30 Sep 2016 01:51:18 -0400
Subject: [PATCH 6/7] Fix Validate hiding overloaded virtual in 3D viewer
 dialog

---
 3d-viewer/3d_cache/dialogs/panel_prev_model.cpp       | 3 ++-
 3d-viewer/3d_cache/dialogs/panel_prev_model.h         | 9 ++++++++-
 pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp | 4 ++--
 pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp     | 4 ++--
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp
index 37c7a9d..da356df 100644
--- a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp
+++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2016 Mario Luzeiro <mrluzeiro@xxxxx>
  * Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@xxxxxxxxx>
+ * Copyright (C) 2015-2016 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -665,7 +666,7 @@ void PANEL_PREV_3D::getOrientationVars( SGPOINT& aScale, SGPOINT& aRotation, SGP
 }
 
 
-bool PANEL_PREV_3D::Validate( wxString& aErrorMessage )
+bool PANEL_PREV_3D::ValidateWithMessage( wxString& aErrorMessage )
 {
     bool invalidScale = false;
     #define MIN_SCALE 0.001
diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.h b/3d-viewer/3d_cache/dialogs/panel_prev_model.h
index 11c3145..0a2faf8 100644
--- a/3d-viewer/3d_cache/dialogs/panel_prev_model.h
+++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.h
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2016 Mario Luzeiro <mrluzeiro@xxxxx>
  * Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@xxxxxxxxx>
+ * Copyright (C) 2015-2016 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -99,7 +100,13 @@ public:
      * @return false if one (or more) value is not acceptable.
      * @param aErrorMessage is a wxString to store error messages, if any
      */
-    bool Validate( wxString& aErrorMessage );
+    bool ValidateWithMessage( wxString& aErrorMessage );
+
+    bool Validate() override
+    {
+        wxString temp;
+        return ValidateWithMessage(temp);
+    }
 
 private:
     wxString                currentModelFile;   ///< Used to check if the model file was changed
diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
index 6a1589e..30548a2 100644
--- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
+++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp
@@ -8,7 +8,7 @@
  * Copyright (C) 2016 Mario Luzeiro <mrluzeiro@xxxxx>
  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  * Copyright (C) 2015 Dick Hollenbeck, dick@xxxxxxxxxxx
- * Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors.
+ * Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -729,7 +729,7 @@ bool DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow()
     // This will update the S3D_INFO list into the current module
     msg.Clear();
 
-    if( !m_PreviewPane->Validate( msg ) )   // Verify the validity of 3D parameters
+    if( !m_PreviewPane->ValidateWithMessage( msg ) )
     {
         DisplayError( this, msg );
         return false;
diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp
index 7d7ccf3..d5e88b4 100644
--- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp
+++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp
@@ -10,7 +10,7 @@
  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  * Copyright (C) 2015 Dick Hollenbeck, dick@xxxxxxxxxxx
  * Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@xxxxxxxxxxx>
- * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
+ * Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -461,7 +461,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
         }
     }
 
-    if( !m_PreviewPane->Validate( msg ) )   // Verify the validity of 3D parameters
+    if( !m_PreviewPane->ValidateWithMessage( msg ) )
     {
         DisplayError( NULL, msg );
         return;
-- 
2.10.0

>From e0871843915c0d95719652cbd0b0f0a7f1d86b6d Mon Sep 17 00:00:00 2001
From: Chris Pavlina <pavlina.chris@xxxxxxxxx>
Date: Fri, 30 Sep 2016 02:02:37 -0400
Subject: [PATCH 7/7] Remove deprecated 'register' storage spec

---
 3d-viewer/3d_rendering/trackball.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/3d-viewer/3d_rendering/trackball.cpp b/3d-viewer/3d_rendering/trackball.cpp
index 741342b..5037de9 100644
--- a/3d-viewer/3d_rendering/trackball.cpp
+++ b/3d-viewer/3d_rendering/trackball.cpp
@@ -33,6 +33,11 @@
  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  *
  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ *
+ * ====================================================================
+ * Code in this file has been modified by the KiCad project.
+ * For modifications:
+ * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
  */
 /*
  * Trackball code:
@@ -90,7 +95,7 @@ void vsub( const double *src1, const double *src2, double *dst )
 
 void vcopy( const double *v1, double *v2 )
 {
-    register int i;
+    int i;
 
     for( i = 0 ; i < 3 ; i++ )
         v2[i] = v1[i];
-- 
2.10.0


Follow ups