Clean up unused variable usage

Unused variables in function calls can be commented out.  Unused
return variables get a new routine `ignore_unused()` that silences the
warnings with zero overhead.
This commit is contained in:
Seth Hillbrand 2021-10-05 09:57:25 -07:00
parent 043c326278
commit 548e5f49bd
29 changed files with 97 additions and 96 deletions

View File

@ -837,10 +837,8 @@ void EDA_3D_CANVAS::OnMiddleUp( wxMouseEvent& event )
}
void EDA_3D_CANVAS::OnTimerTimeout_Editing( wxTimerEvent& event )
void EDA_3D_CANVAS::OnTimerTimeout_Editing( wxTimerEvent& /* event */ )
{
(void)event;
m_mouse_is_moving = false;
m_mouse_was_moved = false;

View File

@ -131,11 +131,9 @@ public:
void SetDirection( const SFVEC3F& aDir ) { m_inv_direction = -aDir; }
// Imported functions from LIGHT
void GetLightParameters( const SFVEC3F& aHitPoint, SFVEC3F& aOutVectorToLight,
void GetLightParameters( const SFVEC3F& /* aHitPoint */, SFVEC3F& aOutVectorToLight,
SFVEC3F& aOutLightColor, float& aOutDistance ) const override
{
(void)aHitPoint; // unused
aOutVectorToLight = m_inv_direction;
aOutDistance = std::numeric_limits<float>::infinity();
aOutLightColor = m_color;

View File

@ -839,10 +839,8 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
}
void RENDER_3D_RAYTRACE::postProcessShading( GLubyte* ptrPBO, REPORTER* aStatusReporter )
void RENDER_3D_RAYTRACE::postProcessShading( GLubyte* /* ptrPBO */, REPORTER* aStatusReporter )
{
(void)ptrPBO; // unused
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
{
if( aStatusReporter )
@ -894,10 +892,8 @@ void RENDER_3D_RAYTRACE::postProcessShading( GLubyte* ptrPBO, REPORTER* aStatusR
}
void RENDER_3D_RAYTRACE::postProcessBlurFinish( GLubyte* ptrPBO, REPORTER* aStatusReporter )
void RENDER_3D_RAYTRACE::postProcessBlurFinish( GLubyte* ptrPBO, REPORTER* /* aStatusReporter */ )
{
(void) aStatusReporter; //unused
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
{
// Now blurs the shader result and compute the final color

View File

@ -167,9 +167,7 @@ bool CYLINDER::Intersects( const BBOX_3D& aBBox ) const
}
SFVEC3F CYLINDER::GetDiffuseColor( const HITINFO& aHitInfo ) const
SFVEC3F CYLINDER::GetDiffuseColor( const HITINFO& /* aHitInfo */ ) const
{
(void)aHitInfo; // unused
return m_diffusecolor;
}

View File

@ -86,9 +86,7 @@ bool DUMMY_BLOCK::Intersects( const BBOX_3D& aBBox ) const
}
SFVEC3F DUMMY_BLOCK::GetDiffuseColor( const HITINFO& aHitInfo ) const
SFVEC3F DUMMY_BLOCK::GetDiffuseColor( const HITINFO& /* aHitInfo */ ) const
{
(void)aHitInfo; // unused
return m_diffusecolor;
}

View File

@ -475,9 +475,7 @@ bool LAYER_ITEM::Intersects( const BBOX_3D& aBBox ) const
}
SFVEC3F LAYER_ITEM::GetDiffuseColor( const HITINFO& aHitInfo ) const
SFVEC3F LAYER_ITEM::GetDiffuseColor( const HITINFO& /* aHitInfo */ ) const
{
(void)aHitInfo; // unused
return m_diffusecolor;
}

View File

@ -118,9 +118,7 @@ bool XY_PLANE::Intersects( const BBOX_3D& aBBox ) const
}
SFVEC3F XY_PLANE::GetDiffuseColor( const HITINFO& aHitInfo ) const
SFVEC3F XY_PLANE::GetDiffuseColor( const HITINFO& /* aHitInfo */ ) const
{
(void)aHitInfo; // unused
return m_diffusecolor;
}

View File

@ -415,9 +415,7 @@ bool ROUND_SEGMENT::Intersects( const BBOX_3D& aBBox ) const
}
SFVEC3F ROUND_SEGMENT::GetDiffuseColor( const HITINFO& aHitInfo ) const
SFVEC3F ROUND_SEGMENT::GetDiffuseColor( const HITINFO& /* aHitInfo */ ) const
{
(void)aHitInfo; // unused
return m_diffusecolor;
}

View File

@ -23,6 +23,7 @@
*/
#include <dialog_shim.h>
#include <ignore.h>
#include <kiway_player.h>
#include <pgm_base.h>
#include <tool/tool_manager.h>
@ -336,6 +337,8 @@ static void selectAllInTextCtrls( wxWindowList& children )
{
childTextCtrl->SelectAll();
}
#else
ignore_unused( childTextCtrl );
#endif
}
else if( wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( child ) )
@ -536,8 +539,7 @@ void DIALOG_SHIM::OnButton( wxCommandEvent& aEvent )
// isn't closing anyway)
if( Validate() )
{
bool success = TransferDataFromWindow();
(void) success;
ignore_unused( TransferDataFromWindow() );
}
}
else if( id == GetEscapeId() ||

View File

@ -24,6 +24,7 @@
#include <cstring>
#include <ignore.h>
#include <macros.h>
#include <kiway.h>
#include <kiway_player.h>
@ -280,7 +281,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
if( kiface->OnKifaceStart( m_program, m_ctl ) )
{
// Tell dso's wxDynamicLibrary destructor not to Unload() the program image.
(void) dso.Detach();
ignore_unused( dso.Detach() );
return m_kiface[aFaceId] = kiface;
}

View File

@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <ignore.h>
#include <kiway.h>
#include <kiway_holder.h>
#include <project.h>
@ -47,11 +48,11 @@ void KIWAY_HOLDER::SetKiway( wxWindow* aDest, KIWAY* aKiway )
if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
{
int breakhere=1;
(void) breakhere;
ignore_unused( breakhere );
}
#endif
(void) aDest;
ignore_unused( aDest );
m_kiway = aKiway;
}

View File

@ -34,6 +34,7 @@
#include <wx/zstream.h>
#include <advanced_config.h>
#include <ignore.h>
#include <macros.h>
#include <trigo.h>
@ -535,7 +536,7 @@ void PDF_PLOTTER::closePdfStream()
int rc = fread( inbuf, 1, stream_len, workFile );
wxASSERT( rc == stream_len );
(void) rc;
ignore_unused( rc );
// We are done with the temporary file, junk it
fclose( workFile );

View File

@ -26,6 +26,7 @@
#include <cstdarg>
#include <config.h> // HAVE_FGETC_NOLOCK
#include <ignore.h>
#include <richio.h>
#include <errno.h>
@ -93,8 +94,7 @@ std::string StrPrintf( const char* format, ... )
va_list args;
va_start( args, format );
int ignore = vprint( &ret, format, args );
(void) ignore;
ignore_unused( vprint( &ret, format, args ) );
va_end( args );
return ret;

View File

@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <ignore.h>
#include <macros.h>
#include <trace_helpers.h>
@ -378,7 +379,7 @@ OPT<TOOL_EVENT> TOOL_DISPATCHER::GetToolEvent( wxKeyEvent* aKeyEvent, bool* keyI
#ifdef __APPLE__
if( unicode_key >= 'A' && unicode_key <= 'Z' && key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
#else
(void) unicode_key; //not used: avoid compil warning
ignore_unused( unicode_key );
if( key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
#endif

View File

@ -219,7 +219,7 @@ bool GAL_OPTIONS_PANEL::TransferDataToWindow()
else
m_renderingEngine->SetSelection( 1 );
#else
(void) m_drawFrame; // Quiet unused variable warning
ignore_unused( m_drawFrame );
#endif
m_gridSnapOptions->SetSelection( UTIL::GetConfigForVal( gridSnapConfigVals,

View File

@ -37,9 +37,8 @@
static wxString StartLine( wxT( "." ) );
bool NETLIST_EXPORTER_CADSTAR::WriteNetlist( const wxString& aOutFileName,
unsigned aNetlistOptions )
unsigned /* aNetlistOptions */ )
{
(void)aNetlistOptions; //unused
int ret = 0;
FILE* f = nullptr;

View File

@ -37,9 +37,8 @@
bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
unsigned aNetlistOptions )
unsigned /* aNetlistOptions */ )
{
(void)aNetlistOptions; //unused
FILE* f = nullptr;
wxString field;
wxString footprint;

View File

@ -33,6 +33,7 @@
#include <gestfich.h>
#include <hierarch.h>
#include <dialogs/html_message_box.h>
#include <ignore.h>
#include <invoke_sch_dialog.h>
#include <string_utils.h>
#include <kiface_base.h>
@ -755,7 +756,7 @@ void SCH_EDIT_FRAME::ResolveERCExclusions()
for( SCH_MARKER* marker : Schematic().ResolveERCExclusions() )
{
SCH_SHEET_PATH errorPath;
(void) sheetList.GetItem( marker->GetRCItem()->GetMainItemID(), &errorPath );
ignore_unused( sheetList.GetItem( marker->GetRCItem()->GetMainItemID(), &errorPath ) );
if( errorPath.LastScreen() )
errorPath.LastScreen()->Append( marker );

View File

@ -31,6 +31,7 @@
#include <gerbview.h>
#include <gerber_file_image.h>
#include <ignore.h>
#include <macros.h>
#include <X2_gerber_attributes.h>
#include <gbr_metadata.h>
@ -897,7 +898,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff,
break;
}
(void) seq_len; // quiet g++, or delete the unused variable.
ignore_unused( seq_len );
ok = GetEndOfBlock( aBuff, aBuffSize, aText, m_Current_File );

24
include/ignore.h Normal file
View File

@ -0,0 +1,24 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2021 KiCad Developers, see CHANGELOG.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
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
* or you may search the http://www.gnu.org website for the version 3 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
template<class T> void ignore_unused( const T& ) { }

View File

@ -27,6 +27,7 @@
#include <build_version.h>
#include <board.h>
#include <ignore.h>
#include <pad.h>
#include <pcb_group.h>
#include <pcb_shape.h>
@ -294,7 +295,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
{
wxTextDataObject data;
clipboard->GetData( data );
( void )data.GetText(); // Keep unused variable
ignore_unused( data.GetText() );
}
#endif
}
@ -373,7 +374,7 @@ void CLIPBOARD_IO::Save( const wxString& aFileName, BOARD* aBoard,
{
wxTextDataObject data;
clipboard->GetData( data );
( void )data.GetText(); // Keep unused variable
ignore_unused( data.GetText() );
}
}

View File

@ -38,6 +38,7 @@ using namespace std::placeholders;
#include <footprint_tree_pane.h>
#include <footprint_viewer_frame.h>
#include <fp_lib_table.h>
#include <ignore.h>
#include <io_mgr.h>
#include <string_utils.h>
#include <kiway.h>
@ -201,8 +202,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser()
viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER_MODAL, true, this );
wxString fpid;
int ret = viewer->ShowModal( &fpid, this );
(void) ret; // make static analyser quiet
ignore_unused( viewer->ShowModal( &fpid, this ) );
viewer->Destroy();

View File

@ -72,10 +72,8 @@ void PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString&
}
void PLUGIN::PrefetchLib( const wxString& aLibraryPath, const PROPERTIES* aProperties )
void PLUGIN::PrefetchLib( const wxString&, const PROPERTIES* )
{
(void) aLibraryPath;
(void) aProperties;
}

View File

@ -43,6 +43,7 @@
#include <footprint.h>
#include <geometry/shape_line_chain.h>
#include <ignore.h>
#include <netclass.h>
#include <pad.h>
#include <pcb_track.h>
@ -5078,7 +5079,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
break;
case T_arc_segments:
static_cast<void>( parseInt( "arc segment count" ) );
ignore_unused( parseInt( "arc segment count" ) );
NeedRIGHT();
break;

View File

@ -74,6 +74,7 @@
#include <board.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <ignore.h>
#include <pad.h>
#include <pcb_track.h>
#include <pcb_text.h>
@ -459,7 +460,7 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
loadAllSections( bool( aAppendToMe ) );
(void)boardDeleter.release(); // give it up so we dont delete it on exit
ignore_unused( boardDeleter.release() ); // give it up so we dont delete it on exit
m_progressReporter = nullptr;
return m_board;
}
@ -1876,7 +1877,7 @@ void LEGACY_PLUGIN::loadPCB_LINE()
dseg->SetLayer( leg_layer2new( m_cu_count, layer ) );
break;
case 1:
(void)intParse( data );
ignore_unused( intParse( data ) );
break;
case 2:
double angle;
@ -2397,7 +2398,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
else if( TESTLINE( "ZAux" ) ) // aux info found
{
// e.g. "ZAux 7 E"
int ignore = intParse( line + SZ( "ZAux" ), &data );
ignore_unused( intParse( line + SZ( "ZAux" ), &data ) );
char* hopt = strtok_r( (char*) data, delims, (char**) &data );
if( !hopt )
@ -2418,8 +2419,6 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
THROW_IO_ERROR( m_error );
}
(void) ignore;
// Set hatch mode later, after reading corner outline data
}
else if( TESTLINE( "ZSmoothing" ) )
@ -2473,7 +2472,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
{
// e.g. "ZOptions 0 32 F 200 200"
int fillmode = intParse( line + SZ( "ZOptions" ), &data );
static_cast<void>( intParse( data, &data ) ); // Ignored
ignore_unused( intParse( data, &data ) );
char fillstate = data[1]; // here e.g. " F"
BIU thermalReliefGap = biuParse( data += 2 , &data ); // +=2 for " F"
BIU thermalReliefCopperBridge = biuParse( data );
@ -2686,7 +2685,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
}
else if( TESTLINE( "Sb" ) )
{
int ignore = biuParse( line + SZ( "Sb" ), &data );
ignore_unused( biuParse( line + SZ( "Sb" ), &data ) );
BIU crossBarOx = biuParse( data, &data );
BIU crossBarOy = biuParse( data, &data );
BIU crossBarFx = biuParse( data, &data );
@ -2696,74 +2695,60 @@ void LEGACY_PLUGIN::loadDIMENSION()
dim->SetLineThickness( width );
dim->UpdateHeight( wxPoint( crossBarFx, crossBarFy ),
wxPoint( crossBarOx, crossBarOy ) );
(void) ignore;
}
else if( TESTLINE( "Sd" ) )
{
int ignore = intParse( line + SZ( "Sd" ), &data );
ignore_unused( intParse( line + SZ( "Sd" ), &data ) );
BIU featureLineDOx = biuParse( data, &data );
BIU featureLineDOy = biuParse( data, &data );
BIU featureLineDFx = biuParse( data, &data );
BIU featureLineDFy = biuParse( data );
ignore_unused( biuParse( data, &data ) );
ignore_unused( biuParse( data ) );
dim->SetStart( wxPoint( featureLineDOx, featureLineDOy ) );
( void )ignore;
( void )featureLineDFx;
( void )featureLineDFy;
}
else if( TESTLINE( "Sg" ) )
{
int ignore = intParse( line + SZ( "Sg" ), &data );
ignore_unused( intParse( line + SZ( "Sg" ), &data ) );
BIU featureLineGOx = biuParse( data, &data );
BIU featureLineGOy = biuParse( data, &data );
BIU featureLineGFx = biuParse( data, &data );
BIU featureLineGFy = biuParse( data );
(void) ignore;
ignore_unused( biuParse( data, &data ) );
ignore_unused( biuParse( data ) );
dim->SetEnd( wxPoint( featureLineGOx, featureLineGOy ) );
( void )ignore;
( void )featureLineGFx;
( void )featureLineGFy;
}
else if( TESTLINE( "S1" ) ) // Arrow: no longer imported
{
int ignore = intParse( line + SZ( "S1" ), &data );
ignore_unused( intParse( line + SZ( "S1" ), &data ) );
biuParse( data, &data ); // skipping excessive data
biuParse( data, &data ); // skipping excessive data
biuParse( data, &data );
biuParse( data );
(void) ignore;
}
else if( TESTLINE( "S2" ) ) // Arrow: no longer imported
{
int ignore = intParse( line + SZ( "S2" ), &data );
ignore_unused( intParse( line + SZ( "S2" ), &data ) );
biuParse( data, &data ); // skipping excessive data
biuParse( data, &data ); // skipping excessive data
biuParse( data, &data );
biuParse( data, &data );
(void) ignore;
}
else if( TESTLINE( "S3" ) ) // Arrow: no longer imported
{
int ignore = intParse( line + SZ( "S3" ), &data );
ignore_unused( intParse( line + SZ( "S3" ), &data ) );
biuParse( data, &data ); // skipping excessive data
biuParse( data, &data ); // skipping excessive data
biuParse( data, &data );
biuParse( data, &data );
(void) ignore;
}
else if( TESTLINE( "S4" ) ) // Arrow: no longer imported
{
int ignore = intParse( line + SZ( "S4" ), &data );
ignore_unused( intParse( line + SZ( "S4" ), &data ) );
biuParse( data, &data ); // skipping excessive data
biuParse( data, &data ); // skipping excessive data
biuParse( data, &data );
biuParse( data, &data );
(void) ignore;
}
}

View File

@ -40,6 +40,7 @@
#include <drc/drc_engine.h>
#include <drc/drc_item.h>
#include <fp_lib_table.h>
#include <ignore.h>
#include <io_mgr.h>
#include <string_utils.h>
#include <macros.h>
@ -99,7 +100,7 @@ SETTINGS_MANAGER* GetSettingsManager()
else
{
// Ensure wx system settings stuff is available
static_cast<void>( wxTheApp );
ignore_unused( wxTheApp );
s_SettingsManager = new SETTINGS_MANAGER( true );
}
}

View File

@ -24,6 +24,7 @@
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <ignore.h>
#include <kiway.h>
#include <sch_io_mgr.h>
@ -64,7 +65,7 @@ BOOST_AUTO_TEST_CASE( Load )
BOOST_TEST_MESSAGE( fn.GetFullPath() );
(void) pi;
ignore_unused( pi );
// This doesn't work with a null KiWay.
// const SCH_SHEET* sheet = pi->Load( fn.GetFullPath(), nullptr );
// BOOST_CHECK_NE( nullptr, sheet );

View File

@ -27,6 +27,7 @@
*/
#include <convert_to_biu.h>
#include <ignore.h>
#include <sch_junction.h>
#include <sch_no_connect.h>
#include <qa_utils/wx_utils/unit_test_utils.h>
@ -65,7 +66,7 @@ BOOST_AUTO_TEST_CASE( Default )
int count = 0;
for( auto item : m_tree )
{
static_cast<void>( item );
ignore_unused( item );
count++;
}
@ -76,7 +77,7 @@ BOOST_AUTO_TEST_CASE( Default )
count = 0;
for( auto item : m_tree.OfType( KICAD_T( type ) ) )
{
static_cast<void>( item );
ignore_unused( item );
count++;
}
@ -90,7 +91,7 @@ BOOST_AUTO_TEST_CASE( Default )
count = 0;
for( auto item : m_tree.Overlapping( SCH_JUNCTION_T, bbox ) )
{
static_cast<void>( item );
ignore_unused( item );
count++;
}
@ -111,7 +112,7 @@ BOOST_AUTO_TEST_CASE( Junctions )
for( auto item : m_tree.OfType( SCH_JUNCTION_T ) )
{
static_cast<void>( item );
ignore_unused( item );
count++;
}
@ -120,7 +121,7 @@ BOOST_AUTO_TEST_CASE( Junctions )
count = 0;
for( auto item : m_tree.OfType( SCH_NO_CONNECT_T ) )
{
static_cast<void>( item );
ignore_unused( item );
count++;
}
@ -199,7 +200,7 @@ BOOST_AUTO_TEST_CASE( MixedElements )
for( auto item : m_tree.OfType( SCH_JUNCTION_T ) )
{
static_cast<void>( item );
ignore_unused( item );
count++;
}
@ -208,7 +209,7 @@ BOOST_AUTO_TEST_CASE( MixedElements )
count = 0;
for( auto item : m_tree.OfType( SCH_NO_CONNECT_T ) )
{
static_cast<void>( item );
ignore_unused( item );
count++;
}
@ -261,7 +262,7 @@ BOOST_AUTO_TEST_CASE( SingleElementTree )
for( auto item : m_tree.OfType( SCH_JUNCTION_T ) )
{
static_cast<void>( item );
ignore_unused( item );
count++;
}
@ -270,7 +271,7 @@ BOOST_AUTO_TEST_CASE( SingleElementTree )
count = 0;
for( auto item : m_tree.OfType( SCH_NO_CONNECT_T ) )
{
static_cast<void>( item );
ignore_unused( item );
count++;
}

View File

@ -32,6 +32,7 @@
#include <qa_utils/utility_registry.h>
#include <board.h>
#include <ignore.h>
#include <zone.h>
#include <profile.h>
@ -242,7 +243,7 @@ int polygon_triangulation_main( int argc, char *argv[] )
poly.CacheTriangulation();
(void) poly;
ignore_unused( poly );
#if 0
PROF_COUNTER unfrac("unfrac");
poly.Unfracture( SHAPE_POLY_SET::PM_FAST );