← Back to team overview

kicad-developers team mailing list archive

[PATCH 2/2] Remove questionable useless casts

 

These are also reported by gcc -Wuseless-casts as having the same source
and destination type, so the new code is equivalent to the old, but it is
less immediately obvious that this interpretation was originally intended.
---
 .../3d_render_raytracing/c3d_render_raytracing.cpp            | 2 +-
 pcbnew/swig/pcbnew_action_plugins.cpp                         | 4 ++--
 pcbnew/tools/selection_tool.cpp                               | 2 +-
 polygon/clipper.cpp                                           | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp
index 0940caa8a..967daaf93 100644
--- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp
+++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp
@@ -1126,7 +1126,7 @@ void C3D_RENDER_RAYTRACING::render_preview( GLubyte *ptrPBO )
 
                 for( unsigned int y = 0; y < RAYPACKET_DIM; ++y )
                 {
-                    const float posYfactor = (float)(windowsPos.y + y * 4.0f) / (float)m_windowSize.y;
+                    const float posYfactor = windowsPos.y + y * 4.0f / (float)m_windowSize.y;
 
                     bgColor[y] = (SFVEC3F)m_settings.m_BgColorTop * SFVEC3F(posYfactor) +
                                  (SFVEC3F)m_settings.m_BgColorBot * ( SFVEC3F(1.0f) - SFVEC3F(posYfactor) );
diff --git a/pcbnew/swig/pcbnew_action_plugins.cpp b/pcbnew/swig/pcbnew_action_plugins.cpp
index d00a5c459..f91f4487f 100644
--- a/pcbnew/swig/pcbnew_action_plugins.cpp
+++ b/pcbnew/swig/pcbnew_action_plugins.cpp
@@ -396,7 +396,7 @@ void PCB_EDIT_FRAME::buildActionPluginMenus( ACTION_MENU* actionMenu )
         item = AddMenuItem( actionMenu, wxID_ANY,  ap->GetName(), ap->GetDescription(), bitmap );
 
         Connect( item->GetId(), wxEVT_COMMAND_MENU_SELECTED,
-                 (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) &
+                 (wxEventFunction) (wxCommandEventFunction) &
                  PCB_EDIT_FRAME::OnActionPluginMenu );
 
         ACTION_PLUGINS::SetActionMenu( ii, item->GetId() );
@@ -432,7 +432,7 @@ void PCB_EDIT_FRAME::AddActionPluginTools()
                     wxID_ANY, wxEmptyString, bitmap, ap->GetName() );
 
             Connect( button->GetId(), wxEVT_COMMAND_MENU_SELECTED,
-                    (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) &
+                    (wxEventFunction) (wxCommandEventFunction) &
                     PCB_EDIT_FRAME::OnActionPluginButton );
 
             // Link action plugin to button
diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp
index 3b45a9237..3e760b4bd 100644
--- a/pcbnew/tools/selection_tool.cpp
+++ b/pcbnew/tools/selection_tool.cpp
@@ -2064,7 +2064,7 @@ void SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector,
                         if( track->GetNetCode() != via->GetNetCode() )
                             continue;
 
-                        double lenRatio = (double) ( track->GetLength() + track->GetWidth() ) /
+                        double lenRatio = ( track->GetLength() + track->GetWidth() ) /
                                           (double) via->GetWidth();
 
                         if( lenRatio > trackViaLengthRatio )
diff --git a/polygon/clipper.cpp b/polygon/clipper.cpp
index fc9cb8f67..05841ab60 100644
--- a/polygon/clipper.cpp
+++ b/polygon/clipper.cpp
@@ -388,10 +388,10 @@ public:
         if( hi < 0 )
         {
             if( lo == 0 ) return (double) hi * shift64;
-            else return -(double) (~lo + ~hi * shift64);
+            else return -(~lo + ~hi * shift64);
         }
         else
-            return (double) (lo + hi * shift64);
+            return (lo + hi * shift64);
     }
 };
 // ------------------------------------------------------------------------------

Follow ups

References