From 53c031257d0f373bcf723a577b73c914ca190b19 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 22 Apr 2016 12:44:08 +0200 Subject: [PATCH] Fix a few shadowed local vars, and coding style issues. --- common/eda_dde.cpp | 4 +--- eeschema/class_library.cpp | 22 ++++++++-------------- pcbnew/class_board.cpp | 9 ++++----- pcbnew/pcb_painter.cpp | 11 ++++++----- pcbnew/specctra.cpp | 8 ++++---- pcbnew/specctra.h | 16 ++++++++-------- pcbnew/specctra_import.cpp | 10 +++++----- 7 files changed, 36 insertions(+), 44 deletions(-) diff --git a/common/eda_dde.cpp b/common/eda_dde.cpp index 92f965d3ce..afddd58d22 100644 --- a/common/eda_dde.cpp +++ b/common/eda_dde.cpp @@ -39,8 +39,6 @@ static const wxString HOSTNAME( wxT( "localhost" ) ); #define IPC_BUF_SIZE 4096 static char client_ipc_buffer[IPC_BUF_SIZE]; -static wxSocketServer* server; - /**********************************/ /* Routines related to the server */ @@ -59,7 +57,7 @@ wxSocketServer* CreateServer( wxWindow* window, int service, bool local ) if( local ) addr.Hostname( HOSTNAME ); - server = new wxSocketServer( addr ); + wxSocketServer* server = new wxSocketServer( addr ); if( server ) { diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 93a5331e98..f051319c8c 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -48,7 +48,7 @@ #include #include -#define duplicate_name_msg \ +#define DUPLICATE_NAME_MSG \ _( "Library '%s' has duplicate entry name '%s'.\n" \ "This may cause some unexpected behavior when loading components into a schematic." ) @@ -457,17 +457,13 @@ LIB_ALIAS* PART_LIB::GetPreviousEntry( const wxString& aName ) bool PART_LIB::Load( wxString& aErrorMsg ) { - FILE* file; - char* line; - wxString msg; - if( fileName.GetFullPath().IsEmpty() ) { aErrorMsg = _( "The component library file name is not set." ); return false; } - file = wxFopen( fileName.GetFullPath(), wxT( "rt" ) ); + FILE* file = wxFopen( fileName.GetFullPath(), wxT( "rt" ) ); if( file == NULL ) { @@ -486,7 +482,7 @@ bool PART_LIB::Load( wxString& aErrorMsg ) // There is no header if this is a symbol library. if( type == LIBRARY_TYPE_EESCHEMA ) { - line = reader.Line(); + char* line = reader.Line(); header = FROM_UTF8( line ); @@ -546,7 +542,7 @@ bool PART_LIB::Load( wxString& aErrorMsg ) while( reader.ReadLine() ) { - line = reader.Line(); + char * line = reader.Line(); if( type == LIBRARY_TYPE_EESCHEMA && strnicmp( line, "$HEADER", 7 ) == 0 ) { @@ -559,6 +555,8 @@ bool PART_LIB::Load( wxString& aErrorMsg ) continue; } + wxString msg; + if( strnicmp( line, "DEF", 3 ) == 0 ) { // Read one DEF/ENDDEF part entry from library: @@ -570,9 +568,7 @@ bool PART_LIB::Load( wxString& aErrorMsg ) // the potential conflict. if( FindEntry( part->GetName() ) != NULL ) { - wxString msg = duplicate_name_msg; - - wxLogWarning( msg, + wxLogWarning( DUPLICATE_NAME_MSG, GetChars( fileName.GetName() ), GetChars( part->GetName() ) ); } @@ -604,9 +600,7 @@ void PART_LIB::LoadAliases( LIB_PART* aPart ) { if( FindEntry( aPart->m_aliases[i]->GetName() ) != NULL ) { - wxString msg = duplicate_name_msg; - - wxLogError( msg, + wxLogError( DUPLICATE_NAME_MSG, GetChars( fileName.GetName() ), GetChars( aPart->m_aliases[i]->GetName() ) ); } diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index eb2a78c11e..4c6db1f32e 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -2274,8 +2274,6 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, unsigned i; wxPoint bestPosition; wxString msg; - D_PAD* pad; - MODULE* footprint; std::vector newFootprints; if( !IsEmpty() ) @@ -2303,6 +2301,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, for( i = 0; i < aNetlist.GetCount(); i++ ) { COMPONENT* component = aNetlist.GetComponent( i ); + MODULE* footprint; if( aReporter ) { @@ -2466,7 +2465,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, continue; // At this point, the component footprint is updated. Now update the nets. - for( pad = footprint->Pads(); pad; pad = pad->Next() ) + for( D_PAD* pad = footprint->Pads(); pad; pad = pad->Next() ) { COMPONENT_NET net = component->GetNet( pad->GetPadName() ); @@ -2564,9 +2563,9 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, D_PAD* pad = NULL; D_PAD* previouspad = NULL; - for( unsigned ii = 0; ii < padlist.size(); ii++ ) + for( unsigned kk = 0; kk < padlist.size(); kk++ ) { - pad = padlist[ii]; + pad = padlist[kk]; if( pad->GetNetname().IsEmpty() ) continue; diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 368a48f76f..c0fb9f2b6a 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -439,7 +439,6 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer ) void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) { - VECTOR2D size; VECTOR2D position( aPad->GetPosition() ); PAD_SHAPE_T shape; double m, n; @@ -569,6 +568,8 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) m_gal->Rotate( -aPad->GetOrientation() * M_PI / 1800.0 ); // Choose drawing settings depending on if we are drawing a pad itself or a hole + VECTOR2D size; + if( aLayer == ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ) ) { // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL @@ -901,12 +902,12 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone ) m_gal->SetIsStroke( true ); m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); - const CPolyLine* outline = aZone->Outline(); - for( int i = 0; i < outline->GetCornersCount(); ++i ) + const CPolyLine* polygon = aZone->Outline(); + for( int i = 0; i < polygon->GetCornersCount(); ++i ) { - corners.push_back( VECTOR2D( outline->GetPos( i ) ) ); + corners.push_back( VECTOR2D( polygon->GetPos( i ) ) ); - if( outline->IsEndContour( i ) ) + if( polygon->IsEndContour( i ) ) { // The last point for closing the polyline corners.push_back( corners[0] ); diff --git a/pcbnew/specctra.cpp b/pcbnew/specctra.cpp index 92ac465810..38145195ae 100644 --- a/pcbnew/specctra.cpp +++ b/pcbnew/specctra.cpp @@ -259,9 +259,9 @@ void SPECCTRA_DB::LoadPCB( const wxString& filename ) throw( IO_ERROR, boost::ba } -void SPECCTRA_DB::LoadSESSION( const wxString& filename ) throw( IO_ERROR, boost::bad_pointer ) +void SPECCTRA_DB::LoadSESSION( const wxString& aFilename ) throw( IO_ERROR, boost::bad_pointer ) { - FILE_LINE_READER reader( filename ); + FILE_LINE_READER reader( aFilename ); PushReader( &reader ); @@ -3444,11 +3444,11 @@ void SPECCTRA_DB::ExportPCB( wxString filename, bool aNameChange ) throw( IO_ERR } -void SPECCTRA_DB::ExportSESSION( wxString filename ) +void SPECCTRA_DB::ExportSESSION( wxString aFilename ) { if( session ) { - FILE_OUTPUTFORMATTER formatter( filename, wxT( "wt" ), quote_char[0] ); + FILE_OUTPUTFORMATTER formatter( aFilename, wxT( "wt" ), quote_char[0] ); session->Format( &formatter, 0 ); } diff --git a/pcbnew/specctra.h b/pcbnew/specctra.h index f9ce20a861..671d68a609 100644 --- a/pcbnew/specctra.h +++ b/pcbnew/specctra.h @@ -1246,7 +1246,7 @@ public: out->Print( nestLevel+1, "(use_net" ); for( STRINGS::const_iterator i = use_net.begin(); i!=use_net.end(); ++i ) { - const char* quote = out->GetQuoteChar( i->c_str() ); + quote = out->GetQuoteChar( i->c_str() ); out->Print( 0, " %s%s%s", quote, i->c_str(), quote ); } out->Print( 0, ")\n" ); @@ -2831,8 +2831,8 @@ class CONNECT : public ELEM // @todo not completed. public: - CONNECT( ELEM* parent ) : - ELEM( T_connect, parent ) {} + CONNECT( ELEM* aParent ) : + ELEM( T_connect, aParent ) {} }; @@ -3012,7 +3012,7 @@ public: out->Print( 0, "\n" ); perLine = out->Print( nestLevel+1, "%s", "" ); } - const char* quote = out->GetQuoteChar( net_id.c_str() ); + quote = out->GetQuoteChar( net_id.c_str() ); perLine += out->Print( 0, "(net %s%s%s)", quote, net_id.c_str(), quote ); } @@ -3045,7 +3045,7 @@ public: } if( attr == T_virtual_pin ) { - const char* quote = out->GetQuoteChar( virtual_pin_name.c_str() ); + quote = out->GetQuoteChar( virtual_pin_name.c_str() ); perLine += out->Print( 0, "(attr virtual_pin %s%s%s)", quote, virtual_pin_name.c_str(), quote ); } @@ -3070,7 +3070,7 @@ public: for( STRINGS::iterator i=contact_layers.begin(); i!=contact_layers.end(); ++i ) { - const char* quote = out->GetQuoteChar( i->c_str() ); + quote = out->GetQuoteChar( i->c_str() ); out->Print( nestLevel+2, "%s%s%s\n", quote, i->c_str(), quote ); } out->Print( nestLevel+1, "))\n" ); @@ -3914,10 +3914,10 @@ public: * tool (Pcbnew) and should be used to update a BOARD object with the new * tracks, vias, and component locations. * - * @param filename The name of the dsn file to load. + * @param aFilename The name of the dsn file to load. * @throw IO_ERROR if there is a lexer or parser error. */ - void LoadSESSION( const wxString& filename ) throw( IO_ERROR, boost::bad_pointer ); + void LoadSESSION( const wxString& aFilename ) throw( IO_ERROR, boost::bad_pointer ); /** * Function ExportPCB diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index 984ab4e33c..777ebea8c7 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -444,7 +444,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR ) // Walk the NET_OUTs and create tracks and vias anew. NET_OUTS& net_outs = session->route->net_outs; - for( NET_OUTS::iterator net=net_outs.begin(); net!=net_outs.end(); ++net ) + for( NET_OUTS::iterator net = net_outs.begin(); net!=net_outs.end(); ++net ) { int netCode = 0; @@ -452,10 +452,10 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR ) if( net->net_id.size() ) { wxString netName = FROM_UTF8( net->net_id.c_str() ); + NETINFO_ITEM* netinfo = aBoard->FindNet( netName ); - NETINFO_ITEM* net = aBoard->FindNet( netName ); - if( net ) - netCode = net->GetNet(); + if( netinfo ) + netCode = netinfo->GetNet(); else // else netCode remains 0 { // int breakhere = 1; @@ -463,7 +463,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR ) } WIRES& wires = net->wires; - for( unsigned i=0; ishape->Type();