Fix a few shadowed local vars, and coding style issues.

This commit is contained in:
jean-pierre charras 2016-04-22 12:44:08 +02:00
parent baa5f0ddfb
commit 53c031257d
7 changed files with 36 additions and 44 deletions

View File

@ -39,8 +39,6 @@ static const wxString HOSTNAME( wxT( "localhost" ) );
#define IPC_BUF_SIZE 4096 #define IPC_BUF_SIZE 4096
static char client_ipc_buffer[IPC_BUF_SIZE]; static char client_ipc_buffer[IPC_BUF_SIZE];
static wxSocketServer* server;
/**********************************/ /**********************************/
/* Routines related to the server */ /* Routines related to the server */
@ -59,7 +57,7 @@ wxSocketServer* CreateServer( wxWindow* window, int service, bool local )
if( local ) if( local )
addr.Hostname( HOSTNAME ); addr.Hostname( HOSTNAME );
server = new wxSocketServer( addr ); wxSocketServer* server = new wxSocketServer( addr );
if( server ) if( server )
{ {

View File

@ -48,7 +48,7 @@
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
#include <wx/regex.h> #include <wx/regex.h>
#define duplicate_name_msg \ #define DUPLICATE_NAME_MSG \
_( "Library '%s' has duplicate entry name '%s'.\n" \ _( "Library '%s' has duplicate entry name '%s'.\n" \
"This may cause some unexpected behavior when loading components into a schematic." ) "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 ) bool PART_LIB::Load( wxString& aErrorMsg )
{ {
FILE* file;
char* line;
wxString msg;
if( fileName.GetFullPath().IsEmpty() ) if( fileName.GetFullPath().IsEmpty() )
{ {
aErrorMsg = _( "The component library file name is not set." ); aErrorMsg = _( "The component library file name is not set." );
return false; return false;
} }
file = wxFopen( fileName.GetFullPath(), wxT( "rt" ) ); FILE* file = wxFopen( fileName.GetFullPath(), wxT( "rt" ) );
if( file == NULL ) if( file == NULL )
{ {
@ -486,7 +482,7 @@ bool PART_LIB::Load( wxString& aErrorMsg )
// There is no header if this is a symbol library. // There is no header if this is a symbol library.
if( type == LIBRARY_TYPE_EESCHEMA ) if( type == LIBRARY_TYPE_EESCHEMA )
{ {
line = reader.Line(); char* line = reader.Line();
header = FROM_UTF8( line ); header = FROM_UTF8( line );
@ -546,7 +542,7 @@ bool PART_LIB::Load( wxString& aErrorMsg )
while( reader.ReadLine() ) while( reader.ReadLine() )
{ {
line = reader.Line(); char * line = reader.Line();
if( type == LIBRARY_TYPE_EESCHEMA && strnicmp( line, "$HEADER", 7 ) == 0 ) if( type == LIBRARY_TYPE_EESCHEMA && strnicmp( line, "$HEADER", 7 ) == 0 )
{ {
@ -559,6 +555,8 @@ bool PART_LIB::Load( wxString& aErrorMsg )
continue; continue;
} }
wxString msg;
if( strnicmp( line, "DEF", 3 ) == 0 ) if( strnicmp( line, "DEF", 3 ) == 0 )
{ {
// Read one DEF/ENDDEF part entry from library: // Read one DEF/ENDDEF part entry from library:
@ -570,9 +568,7 @@ bool PART_LIB::Load( wxString& aErrorMsg )
// the potential conflict. // the potential conflict.
if( FindEntry( part->GetName() ) != NULL ) if( FindEntry( part->GetName() ) != NULL )
{ {
wxString msg = duplicate_name_msg; wxLogWarning( DUPLICATE_NAME_MSG,
wxLogWarning( msg,
GetChars( fileName.GetName() ), GetChars( fileName.GetName() ),
GetChars( part->GetName() ) ); GetChars( part->GetName() ) );
} }
@ -604,9 +600,7 @@ void PART_LIB::LoadAliases( LIB_PART* aPart )
{ {
if( FindEntry( aPart->m_aliases[i]->GetName() ) != NULL ) if( FindEntry( aPart->m_aliases[i]->GetName() ) != NULL )
{ {
wxString msg = duplicate_name_msg; wxLogError( DUPLICATE_NAME_MSG,
wxLogError( msg,
GetChars( fileName.GetName() ), GetChars( fileName.GetName() ),
GetChars( aPart->m_aliases[i]->GetName() ) ); GetChars( aPart->m_aliases[i]->GetName() ) );
} }

View File

@ -2274,8 +2274,6 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
unsigned i; unsigned i;
wxPoint bestPosition; wxPoint bestPosition;
wxString msg; wxString msg;
D_PAD* pad;
MODULE* footprint;
std::vector<MODULE*> newFootprints; std::vector<MODULE*> newFootprints;
if( !IsEmpty() ) if( !IsEmpty() )
@ -2303,6 +2301,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
for( i = 0; i < aNetlist.GetCount(); i++ ) for( i = 0; i < aNetlist.GetCount(); i++ )
{ {
COMPONENT* component = aNetlist.GetComponent( i ); COMPONENT* component = aNetlist.GetComponent( i );
MODULE* footprint;
if( aReporter ) if( aReporter )
{ {
@ -2466,7 +2465,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
continue; continue;
// At this point, the component footprint is updated. Now update the nets. // 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() ); COMPONENT_NET net = component->GetNet( pad->GetPadName() );
@ -2564,9 +2563,9 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
D_PAD* pad = NULL; D_PAD* pad = NULL;
D_PAD* previouspad = 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() ) if( pad->GetNetname().IsEmpty() )
continue; continue;

View File

@ -439,7 +439,6 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
{ {
VECTOR2D size;
VECTOR2D position( aPad->GetPosition() ); VECTOR2D position( aPad->GetPosition() );
PAD_SHAPE_T shape; PAD_SHAPE_T shape;
double m, n; 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 ); m_gal->Rotate( -aPad->GetOrientation() * M_PI / 1800.0 );
// Choose drawing settings depending on if we are drawing a pad itself or a hole // 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 ) ) if( aLayer == ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ) )
{ {
// Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL // 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->SetIsStroke( true );
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
const CPolyLine* outline = aZone->Outline(); const CPolyLine* polygon = aZone->Outline();
for( int i = 0; i < outline->GetCornersCount(); ++i ) 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 // The last point for closing the polyline
corners.push_back( corners[0] ); corners.push_back( corners[0] );

View File

@ -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 ); 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 ) if( session )
{ {
FILE_OUTPUTFORMATTER formatter( filename, wxT( "wt" ), quote_char[0] ); FILE_OUTPUTFORMATTER formatter( aFilename, wxT( "wt" ), quote_char[0] );
session->Format( &formatter, 0 ); session->Format( &formatter, 0 );
} }

View File

@ -1246,7 +1246,7 @@ public:
out->Print( nestLevel+1, "(use_net" ); out->Print( nestLevel+1, "(use_net" );
for( STRINGS::const_iterator i = use_net.begin(); i!=use_net.end(); ++i ) 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, " %s%s%s", quote, i->c_str(), quote );
} }
out->Print( 0, ")\n" ); out->Print( 0, ")\n" );
@ -2831,8 +2831,8 @@ class CONNECT : public ELEM
// @todo not completed. // @todo not completed.
public: public:
CONNECT( ELEM* parent ) : CONNECT( ELEM* aParent ) :
ELEM( T_connect, parent ) {} ELEM( T_connect, aParent ) {}
}; };
@ -3012,7 +3012,7 @@ public:
out->Print( 0, "\n" ); out->Print( 0, "\n" );
perLine = out->Print( nestLevel+1, "%s", "" ); 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 ); perLine += out->Print( 0, "(net %s%s%s)", quote, net_id.c_str(), quote );
} }
@ -3045,7 +3045,7 @@ public:
} }
if( attr == T_virtual_pin ) 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)", perLine += out->Print( 0, "(attr virtual_pin %s%s%s)",
quote, virtual_pin_name.c_str(), quote ); quote, virtual_pin_name.c_str(), quote );
} }
@ -3070,7 +3070,7 @@ public:
for( STRINGS::iterator i=contact_layers.begin(); i!=contact_layers.end(); ++i ) 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+2, "%s%s%s\n", quote, i->c_str(), quote );
} }
out->Print( nestLevel+1, "))\n" ); out->Print( nestLevel+1, "))\n" );
@ -3914,10 +3914,10 @@ public:
* tool (Pcbnew) and should be used to update a BOARD object with the new * tool (Pcbnew) and should be used to update a BOARD object with the new
* tracks, vias, and component locations. * 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. * @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 * Function ExportPCB

View File

@ -444,7 +444,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
// Walk the NET_OUTs and create tracks and vias anew. // Walk the NET_OUTs and create tracks and vias anew.
NET_OUTS& net_outs = session->route->net_outs; 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; int netCode = 0;
@ -452,10 +452,10 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
if( net->net_id.size() ) if( net->net_id.size() )
{ {
wxString netName = FROM_UTF8( net->net_id.c_str() ); wxString netName = FROM_UTF8( net->net_id.c_str() );
NETINFO_ITEM* netinfo = aBoard->FindNet( netName );
NETINFO_ITEM* net = aBoard->FindNet( netName ); if( netinfo )
if( net ) netCode = netinfo->GetNet();
netCode = net->GetNet();
else // else netCode remains 0 else // else netCode remains 0
{ {
// int breakhere = 1; // int breakhere = 1;
@ -463,7 +463,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
} }
WIRES& wires = net->wires; WIRES& wires = net->wires;
for( unsigned i=0; i<wires.size(); ++i ) for( unsigned i = 0; i<wires.size(); ++i )
{ {
WIRE* wire = &wires[i]; WIRE* wire = &wires[i];
DSN_T shape = wire->shape->Type(); DSN_T shape = wire->shape->Type();