Coverity fixes
resource leak: #172233 negative array index write: #102363 uninitialized scalar field: #174540 #174539 structurally dead code: #169334 #169331
This commit is contained in:
parent
4e76a18d5d
commit
ce610f33a2
|
@ -68,7 +68,7 @@ void TEXTE_PCB::SetTextAngle( double aAngle )
|
||||||
void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
|
void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
|
||||||
GR_DRAWMODE DrawMode, const wxPoint& offset )
|
GR_DRAWMODE DrawMode, const wxPoint& offset )
|
||||||
{
|
{
|
||||||
wxASSERT( panel );
|
wxASSERT( panel );
|
||||||
|
|
||||||
if( !panel )
|
if( !panel )
|
||||||
return;
|
return;
|
||||||
|
@ -78,16 +78,11 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
|
||||||
if( brd->IsLayerVisible( m_Layer ) == false )
|
if( brd->IsLayerVisible( m_Layer ) == false )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto frame = static_cast<PCB_EDIT_FRAME*> ( panel->GetParent() );
|
auto frame = static_cast<PCB_EDIT_FRAME*>( panel->GetParent() );
|
||||||
auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
|
auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
|
||||||
|
|
||||||
EDA_DRAW_MODE_T fillmode = FILLED;
|
EDA_DRAW_MODE_T fillmode = FILLED;
|
||||||
PCB_DISPLAY_OPTIONS* displ_opts = nullptr;
|
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
|
||||||
|
|
||||||
if( panel )
|
|
||||||
{
|
|
||||||
displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( displ_opts && displ_opts->m_DisplayDrawItemsFill == SKETCH )
|
if( displ_opts && displ_opts->m_DisplayDrawItemsFill == SKETCH )
|
||||||
fillmode = SKETCH;
|
fillmode = SKETCH;
|
||||||
|
@ -106,8 +101,7 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
|
||||||
if( brd->IsElementVisible( LAYER_ANCHOR ) )
|
if( brd->IsElementVisible( LAYER_ANCHOR ) )
|
||||||
anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR );
|
anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR );
|
||||||
|
|
||||||
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
|
EDA_TEXT::Draw( panel->GetClipBox(), DC, offset, color,
|
||||||
EDA_TEXT::Draw( clipbox, DC, offset, color,
|
|
||||||
DrawMode, fillmode, anchor_color );
|
DrawMode, fillmode, anchor_color );
|
||||||
|
|
||||||
// Enable these line to draw the bounding box (debug tests purposes only)
|
// Enable these line to draw the bounding box (debug tests purposes only)
|
||||||
|
|
|
@ -55,6 +55,9 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) :
|
||||||
m_CornerSelection = nullptr; // no corner is selected
|
m_CornerSelection = nullptr; // no corner is selected
|
||||||
m_IsFilled = false; // fill status : true when the zone is filled
|
m_IsFilled = false; // fill status : true when the zone is filled
|
||||||
m_FillMode = ZFM_POLYGONS;
|
m_FillMode = ZFM_POLYGONS;
|
||||||
|
m_hatchStyle = DIAGONAL_EDGE;
|
||||||
|
m_hatchPitch = GetDefaultHatchPitch();
|
||||||
|
m_hv45 = false;
|
||||||
m_priority = 0;
|
m_priority = 0;
|
||||||
m_cornerSmoothingType = ZONE_SETTINGS::SMOOTHING_NONE;
|
m_cornerSmoothingType = ZONE_SETTINGS::SMOOTHING_NONE;
|
||||||
SetIsKeepout( false );
|
SetIsKeepout( false );
|
||||||
|
|
|
@ -108,9 +108,11 @@ public:
|
||||||
|
|
||||||
ROW()
|
ROW()
|
||||||
{
|
{
|
||||||
spacer = true;
|
|
||||||
color = COLOR4D::UNSPECIFIED;
|
|
||||||
id = 0;
|
id = 0;
|
||||||
|
color = COLOR4D::UNSPECIFIED;
|
||||||
|
state = true;
|
||||||
|
changeable = true;
|
||||||
|
spacer = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -134,25 +134,6 @@ const BOX2I SELECTION::ViewBBox() const
|
||||||
BOX2I r;
|
BOX2I r;
|
||||||
r.SetMaximum();
|
r.SetMaximum();
|
||||||
return r;
|
return r;
|
||||||
EDA_RECT eda_bbox;
|
|
||||||
|
|
||||||
if( Size() == 1 )
|
|
||||||
{
|
|
||||||
eda_bbox = Front()->GetBoundingBox();
|
|
||||||
}
|
|
||||||
else if( Size() > 1 )
|
|
||||||
{
|
|
||||||
eda_bbox = Front()->GetBoundingBox();
|
|
||||||
auto i = m_items.begin();
|
|
||||||
++i;
|
|
||||||
|
|
||||||
for( ; i != m_items.end(); ++i )
|
|
||||||
{
|
|
||||||
eda_bbox.Merge( (*i)->GetBoundingBox() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return BOX2I( eda_bbox.GetOrigin(), eda_bbox.GetSize() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -736,6 +736,10 @@ Triangle& Sweep::NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triangl
|
||||||
if (o == CCW) {
|
if (o == CCW) {
|
||||||
// ot is not crossing edge after flip
|
// ot is not crossing edge after flip
|
||||||
int edge_index = ot.EdgeIndex(&p, &op);
|
int edge_index = ot.EdgeIndex(&p, &op);
|
||||||
|
|
||||||
|
if(edge_index < 0)
|
||||||
|
throw std::runtime_error("Edge not found in the triangle");
|
||||||
|
|
||||||
ot.delaunay_edge[edge_index] = true;
|
ot.delaunay_edge[edge_index] = true;
|
||||||
Legalize(tcx, ot);
|
Legalize(tcx, ot);
|
||||||
ot.ClearDelunayEdges();
|
ot.ClearDelunayEdges();
|
||||||
|
@ -745,6 +749,9 @@ Triangle& Sweep::NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triangl
|
||||||
// t is not crossing edge after flip
|
// t is not crossing edge after flip
|
||||||
int edge_index = t.EdgeIndex(&p, &op);
|
int edge_index = t.EdgeIndex(&p, &op);
|
||||||
|
|
||||||
|
if(edge_index < 0)
|
||||||
|
throw std::runtime_error("Edge not found in the triangle");
|
||||||
|
|
||||||
t.delaunay_edge[edge_index] = true;
|
t.delaunay_edge[edge_index] = true;
|
||||||
Legalize(tcx, t);
|
Legalize(tcx, t);
|
||||||
t.ClearDelunayEdges();
|
t.ClearDelunayEdges();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "kicadpcb.h"
|
#include "kicadpcb.h"
|
||||||
#include "sexpr/sexpr.h"
|
#include "sexpr/sexpr.h"
|
||||||
|
@ -143,9 +144,9 @@ bool KICADPCB::ReadFile( const wxString& aFileName )
|
||||||
{
|
{
|
||||||
SEXPR::PARSER parser;
|
SEXPR::PARSER parser;
|
||||||
std::string infile( fname.GetFullPath().ToUTF8() );
|
std::string infile( fname.GetFullPath().ToUTF8() );
|
||||||
SEXPR::SEXPR* data = parser.ParseFromFile( infile );
|
std::unique_ptr<SEXPR::SEXPR> data( parser.ParseFromFile( infile ) );
|
||||||
|
|
||||||
if( NULL == data )
|
if( !data )
|
||||||
{
|
{
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
ostr << "* no data in file: '" << aFileName.ToUTF8() << "'\n";
|
ostr << "* no data in file: '" << aFileName.ToUTF8() << "'\n";
|
||||||
|
@ -154,9 +155,8 @@ bool KICADPCB::ReadFile( const wxString& aFileName )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !parsePCB( data ) )
|
if( !parsePCB( data.get() ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue