Coverity fixes

CIDs:
174166
174170
174171
This commit is contained in:
Maciej Suminski 2018-02-15 10:22:47 +01:00
parent 1e054071fc
commit 570f4dd991
3 changed files with 15 additions and 24 deletions

View File

@ -74,11 +74,11 @@ bool SHAPE_ARC::Collide( const SEG& aSeg, int aClearance ) const
}
bool SHAPE_ARC::ConstructFromCorners( VECTOR2I aP0, VECTOR2I aP1, double aCenterAngle )
bool SHAPE_ARC::ConstructFromCorners( const VECTOR2I& aP0, const VECTOR2I& aP1, double aCenterAngle )
{
VECTOR2D mid = ( VECTOR2D( aP0 ) + VECTOR2D( aP1 ) ) * 0.5;
VECTOR2D chord = VECTOR2D( aP1 ) - VECTOR2D( aP0 );
double c = (aP1 - aP0).EuclideanNorm() / 2;
double c = (aP1 - aP0).EuclideanNorm() / 2.0;
VECTOR2D d = chord.Rotate( M_PI / 2.0 ).Resize( c );
m_pc = mid + d * ( 1.0 / tan( aCenterAngle / 2.0 * M_PI / 180.0 ) );
@ -88,7 +88,8 @@ bool SHAPE_ARC::ConstructFromCorners( VECTOR2I aP0, VECTOR2I aP1, double aCenter
return true;
}
bool SHAPE_ARC::ConstructFromCornerAndAngles( VECTOR2I aP0,
bool SHAPE_ARC::ConstructFromCornerAndAngles( const VECTOR2I& aP0,
double aStartAngle,
double aCenterAngle,
double aRadius )
@ -148,7 +149,8 @@ double SHAPE_ARC::GetCentralAngle() const
return ea - sa;
}
const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy ) const
SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy ) const
{
SHAPE_LINE_CHAIN rv;
double ca = GetCentralAngle();
@ -158,15 +160,10 @@ const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy ) const
int n;
if( r == 0.0 )
{
ca = 0;
n = 0;
}
else
{
step = 180 / M_PI * acos( r * ( 1 - aAccuracy ) / r );
n = (int) ceil(ca / step);
}
return rv;
step = 180.0 / M_PI * acos( r * ( 1.0 - aAccuracy ) / r );
n = (int) ceil( ca / step );
for( int i = 0; i <= n ; i++ )
{

View File

@ -62,6 +62,7 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
ITEM_PICKER redoWrapper = redoCommand->PopItem();
delete redoCommand;
LIB_PART* part = (LIB_PART*) redoWrapper.GetItem();
wxCHECK( part, /* void */ );
part->SetFlags( part->GetFlags() & ~UR_TRANSIENT );
UNDO_REDO_T undoRedoType = redoWrapper.GetStatus();
@ -79,9 +80,6 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
// Just set the current part to the part which come from the redo list
m_my_part = part;
if( !part )
return;
if( undoRedoType == UR_LIB_RENAME )
{
wxString lib = GetCurLib();
@ -115,6 +113,7 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
ITEM_PICKER undoWrapper = undoCommand->PopItem();
delete undoCommand;
LIB_PART* part = (LIB_PART*) undoWrapper.GetItem();
wxCHECK( part, /* void */ );
part->SetFlags( part->GetFlags() & ~UR_TRANSIENT );
UNDO_REDO_T undoRedoType = undoWrapper.GetStatus();
@ -126,17 +125,12 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
redoCommand->PushItem( redoWrapper );
GetScreen()->PushCommandToRedoList( redoCommand );
printf("RestoreCopy [%p]\n", part);
// Do not delete the previous part by calling SetCurPart( part ),
// which calls delete <previous part>.
// <previous part> is now put in redo list and is owned by this list.
// Just set the current part to the part which come from the undo list
m_my_part = part;
if( !part )
return;
if( undoRedoType == UR_LIB_RENAME )
{
wxString lib = GetCurLib();

View File

@ -105,15 +105,15 @@ public:
double GetEndAngle() const;
bool ConstructFromCorners( VECTOR2I aP0, VECTOR2I aP1, double aCenterAngle );
bool ConstructFromCorners( const VECTOR2I& aP0, const VECTOR2I& aP1, double aCenterAngle );
bool ConstructFromCornerAndAngles( VECTOR2I aP0,
bool ConstructFromCornerAndAngles( const VECTOR2I& aP0,
double aStartAngle,
double aCenterAngle,
double aRadius );
const SHAPE_LINE_CHAIN ConvertToPolyline( double aAccuracy = 0.02f ) const;
SHAPE_LINE_CHAIN ConvertToPolyline( double aAccuracy = 0.02 ) const;
private: