Coverity fixes.

Reports 314745, 316271, and 316269.
This commit is contained in:
Wayne Stambaugh 2021-01-13 11:23:09 -05:00
parent 431616981b
commit 2d64613bbb
4 changed files with 37 additions and 23 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2020 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.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
@ -502,10 +502,10 @@ void RENDER_3D_RAYTRACE::renderRayPackets( const SFVEC3F* bgColorY, const RAY* a
}
void RENDER_3D_RAYTRACE::renderAnitAliasPackets( const SFVEC3F* aBgColorY,
const HITINFO_PACKET* aHitPck_X0Y0,
const HITINFO_PACKET* aHitPck_AA_X1Y1,
const RAY* aRayPck, SFVEC3F* aOutHitColor )
void RENDER_3D_RAYTRACE::renderAntiAliasPackets( const SFVEC3F* aBgColorY,
const HITINFO_PACKET* aHitPck_X0Y0,
const HITINFO_PACKET* aHitPck_AA_X1Y1,
const RAY* aRayPck, SFVEC3F* aOutHitColor )
{
const bool is_testShadow = m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS );
@ -535,12 +535,13 @@ void RENDER_3D_RAYTRACE::renderAnitAliasPackets( const SFVEC3F* aBgColorY,
unsigned int nodex0y1 = 0;
if( y < (RAYPACKET_DIM - 1) )
nodex0y1 = aHitPck_X0Y0[ idx0y1 ].m_HitInfo.m_acc_node_info;
if( y < ( RAYPACKET_DIM - 1 ) && idx0y1 < RAYPACKET_RAYS_PER_PACKET )
nodex0y1 = aHitPck_X0Y0[idx0y1].m_HitInfo.m_acc_node_info;
unsigned int nodex1y1 = 0;
if( idx1y1 < RAYPACKET_RAYS_PER_PACKET )
if( ( x < ( RAYPACKET_DIM - 1 ) ) && ( y < ( RAYPACKET_DIM - 1 ) )
&& idx1y1 < RAYPACKET_RAYS_PER_PACKET )
nodex1y1 = aHitPck_X0Y0[idx1y1].m_HitInfo.m_acc_node_info;
// If all notes are equal we assume there was no change on the object hits.
@ -763,13 +764,13 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
m_camera, (SFVEC2F) blockPosI + SFVEC2F( 0.25f - DISP_FACTOR, 0.25f - DISP_FACTOR ),
SFVEC2F( DISP_FACTOR, DISP_FACTOR ), blockRayPck_AA_X1Y1_half );
renderAnitAliasPackets( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1, blockRayPck_AA_X1Y0,
renderAntiAliasPackets( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1, blockRayPck_AA_X1Y0,
hitColor_AA_X1Y0 );
renderAnitAliasPackets( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1, blockRayPck_AA_X0Y1,
renderAntiAliasPackets( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1, blockRayPck_AA_X0Y1,
hitColor_AA_X0Y1 );
renderAnitAliasPackets( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1,
renderAntiAliasPackets( bgColor, hitPacket_X0Y0, hitPacket_AA_X1Y1,
blockRayPck_AA_X1Y1_half, hitColor_AA_X0Y1_half );
// Average the result

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2020 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.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
@ -87,12 +87,13 @@ private:
void postProcessShading( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void postProcessBlurFinish( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void renderBlockTracing( GLubyte* ptrPBO , signed int iBlock );
void renderFinalColor( GLubyte* ptrPBO, const SFVEC3F& rgbColor, bool applyColorSpaceConversion );
void renderFinalColor( GLubyte* ptrPBO, const SFVEC3F& rgbColor,
bool applyColorSpaceConversion );
void renderRayPackets( const SFVEC3F* bgColorY, const RAY* aRayPkt, HITINFO_PACKET* aHitPacket,
bool is_testShadow, SFVEC3F* aOutHitColor );
void renderAnitAliasPackets( const SFVEC3F* aBgColorY, const HITINFO_PACKET* aHitPck_X0Y0,
void renderAntiAliasPackets( const SFVEC3F* aBgColorY, const HITINFO_PACKET* aHitPck_X0Y0,
const HITINFO_PACKET* aHitPck_AA_X1Y1, const RAY* aRayPck,
SFVEC3F* aOutHitColor );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.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
@ -87,14 +87,14 @@ public:
virtual void SetPenDiameter( double diameter );
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ) override;
double aScale, bool aMirror ) override;
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill,
int width = USE_DEFAULT_LINE_WIDTH ) override;
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Circle( const wxPoint& pos, int diametre, FILL_TYPE fill,
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
FILL_TYPE aFill, int aWidth = USE_DEFAULT_LINE_WIDTH,
void * aData = NULL) override;
void * aData = NULL ) override;
virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
OUTLINE_MODE tracemode, void* aData ) override;
@ -117,7 +117,8 @@ public:
double aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount,
double aOrient, OUTLINE_MODE aTraceMode, void* aData ) override;
double aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
protected:
/// Start a new HPGL_ITEM if necessary, keeping the current one if it exists.
@ -150,7 +151,12 @@ protected:
struct HPGL_ITEM
{
HPGL_ITEM() : lift_before( false ), lift_after( false ), pen_returns( false ), pen( 0 ) {}
HPGL_ITEM() :
lift_before( false ),
lift_after( false ),
pen_returns( false ),
pen( 0 ),
dashType( PLOT_DASH_TYPE::SOLID ) {}
/// Location the pen should start at
DPOINT loc_start;
@ -195,5 +201,3 @@ protected:
std::list<HPGL_ITEM> m_items;
HPGL_ITEM* m_current_item;
};

View File

@ -291,8 +291,16 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
{
SYMBOL_EDITOR_PIN_TOOL* pinTool = m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>();
if( !pinTool->PlacePin( (LIB_PIN*) selection.Front() ) )
try
{
if( !pinTool->PlacePin( (LIB_PIN*) selection.Front() ) )
restore_state = true;
}
catch( const boost::bad_pointer& e )
{
restore_state = true;
wxLogError( "Boost pointer exception occurred: \"%s\"", e.what() );
}
}
break; // Finish