Fix some warnings (looking like potential bugs) detected by cppcheck, (a few from a patch from Julien Nabet <serval2412@yahoo.fr>), remove not used vars and a few coding style fixes.

This commit is contained in:
jean-pierre charras 2015-12-27 13:16:46 +01:00
parent 415c72262a
commit c4ea4dc0df
8 changed files with 14 additions and 27 deletions

View File

@ -725,8 +725,9 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
org.y += KiROUND( gridSize.y );
// Use a pixel based draw to display grid. There are a lot of calls, so the cost is
// high and grid is slowly drawn on some platforms. Please note that this should
// always be enabled until the bitmap based solution below is fixed.
// high and grid is slowly drawn on some platforms. An other way using blit transfert was used,
// a long time ago, but it did not give very good results.
// The better way is highly dependent on the platform and the graphic card.
#ifndef __WXMAC__
GRSetColorPen( aDC, GetParent()->GetGridColor() );
#else
@ -996,7 +997,7 @@ void EDA_DRAW_PANEL::OnMagnify( wxMouseEvent& event )
void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
{
int localrealbutt = 0, localbutt = 0;
int localbutt = 0;
BASE_SCREEN* screen = GetScreen();
if( !screen )
@ -1030,12 +1031,6 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if( m_ignoreMouseEvents )
return;
if( event.LeftIsDown() )
localrealbutt |= GR_M_LEFT_DOWN;
if( event.MiddleIsDown() )
localrealbutt |= GR_M_MIDDLE_DOWN;
if( event.LeftDown() )
localbutt = GR_M_LEFT_DOWN;
@ -1045,8 +1040,6 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if( event.MiddleDown() )
localbutt = GR_M_MIDDLE_DOWN;
localrealbutt |= localbutt; // compensation default wxGTK
INSTALL_UNBUFFERED_DC( DC, this );
DC.SetBackground( *wxBLACK_BRUSH );

View File

@ -498,7 +498,7 @@ void SCH_SHEET::CleanupSheet()
}
if( HLabel == NULL ) // Hlabel not found: delete sheet label.
m_pins.erase( i );
i = m_pins.erase( i );
else
++i;
}

View File

@ -882,7 +882,7 @@ SCH_SHEET* SCH_SHEET_LIST::FindSheetByName( const wxString& aSheetName )
for( int i = 0; i < m_count; i++ )
{
sheet = m_list[i].FindSheetByName( aSheetName );
SCH_SHEET* sheet = m_list[i].FindSheetByName( aSheetName );
if( sheet )
return sheet;

View File

@ -105,7 +105,7 @@ void PL_EDITOR_FRAME::GetLayoutFromRedoList( wxCommandEvent& event )
lastcmd = GetScreen()->PopCommandFromRedoList();
wrapper = lastcmd->PopItem();
copyItem = (PL_ITEM_LAYOUT*)wrapper.GetItem();
copyItem = static_cast<PL_ITEM_LAYOUT*>( wrapper.GetItem() );
pglayout.SetPageLayout( TO_UTF8(copyItem->m_Layout) );
delete copyItem;
@ -136,7 +136,7 @@ void PL_EDITOR_FRAME::GetLayoutFromUndoList( wxCommandEvent& event )
lastcmd = GetScreen()->PopCommandFromUndoList();
wrapper = lastcmd->PopItem();
copyItem = (PL_ITEM_LAYOUT*)wrapper.GetItem();
copyItem = static_cast<PL_ITEM_LAYOUT*>( wrapper.GetItem() );
pglayout.SetPageLayout( TO_UTF8(copyItem->m_Layout) );
delete copyItem;
@ -156,6 +156,6 @@ void PL_EDITOR_FRAME::RemoveLastCommandInUndoList()
PICKED_ITEMS_LIST* lastcmd = GetScreen()->PopCommandFromUndoList();
ITEM_PICKER wrapper = lastcmd->PopItem();
PL_ITEM_LAYOUT* copyItem = (PL_ITEM_LAYOUT*)wrapper.GetItem();
PL_ITEM_LAYOUT* copyItem = static_cast<PL_ITEM_LAYOUT*>( wrapper.GetItem() );
delete copyItem;
}

View File

@ -578,7 +578,7 @@ void make_hcyl( bool inch, bool axial, double dia, double length,
fprintf( fp, ".END_ELECTRICAL\n" );
fclose( fp );
return;
return;
}

View File

@ -83,7 +83,8 @@ bool IDF3::GetIDFString( const std::string& aLine, std::string& aIDFString,
if( idx < 0 || idx >= len )
return false;
while( isspace( aLine[idx] ) && idx < len ) ++idx;
while( idx < len && isspace( aLine[idx] ) )
++idx;
if( idx == len )
{
@ -95,7 +96,7 @@ bool IDF3::GetIDFString( const std::string& aLine, std::string& aIDFString,
{
hasQuotes = true;
++idx;
while( aLine[idx] != '"' && idx < len )
while( idx < len && aLine[idx] != '"' )
ostr << aLine[idx++];
if( idx == len )
@ -112,7 +113,7 @@ bool IDF3::GetIDFString( const std::string& aLine, std::string& aIDFString,
{
hasQuotes = false;
while( !isspace( aLine[idx] ) && idx < len )
while( idx < len && !isspace( aLine[idx] ) )
ostr << aLine[idx++];
}

View File

@ -2720,8 +2720,6 @@ bool IDF3_BOARD::ReadFile( const wxString& aFullFileName, bool aNoSubstituteOutl
// 2. Check if a file with extension 'emp' exists and read it
// 3. Open the specified filename and read it
std::string fname = TO_UTF8( aFullFileName );
wxFileName brdname( aFullFileName );
wxFileName libname( aFullFileName );
@ -3125,8 +3123,6 @@ bool IDF3_BOARD::WriteFile( const wxString& aFullFileName, bool aUnitMM, bool aF
// 2. Write the *.emn file according to the IDFv3 spec
// 3. Write the *.emp file according to the IDFv3 spec
std::string fname = TO_UTF8( aFullFileName );
wxFileName brdname( aFullFileName );
wxFileName libname( aFullFileName );

View File

@ -1592,9 +1592,6 @@ int VRML_LAYER::checkNContours( bool holes )
if( contours.empty() )
return 0;
std::list<int>::const_iterator begin;
std::list<int>::const_iterator end;
for( size_t i = 0; i < contours.size(); ++i )
{
if( contours[i]->size() < 3 )