Coverity warning fixes.

This commit is contained in:
Wayne Stambaugh 2023-12-18 16:09:13 -05:00
parent c7facfd4d4
commit a4b38fbb80
11 changed files with 122 additions and 98 deletions

View File

@ -60,6 +60,7 @@ BITMAP_BASE::BITMAP_BASE( const BITMAP_BASE& aSchBitmap )
m_isMirroredX = aSchBitmap.m_isMirroredX;
m_isMirroredY = aSchBitmap.m_isMirroredY;
m_rotation = aSchBitmap.m_rotation;
m_imageType = aSchBitmap.m_imageType;
m_image = nullptr;
m_bitmap = nullptr;

View File

@ -131,6 +131,7 @@ LIB_TREE_NODE::LIB_TREE_NODE()
m_IntrinsicRank( 0 ),
m_Score( 0 ),
m_Pinned( false ),
m_PinCount( 0 ),
m_Unit( 0 ),
m_IsRoot( false )
{}

View File

@ -565,7 +565,7 @@ CADSTAR_PARTS_LIB_MODEL readCadstarHelper( INPUT_TYPE& aInput )
}
catch( const parse_error& e )
{
const auto p = e.positions().front();
const auto& p = e.positions().front();
std::cerr << "Error at line " << p.line << ", column " << p.column << std::endl
<< aInput.line_at( p ) << std::endl
<< std::setw( p.column ) << '^' << std::endl

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2022-2023 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
@ -77,7 +77,7 @@ void SEARCH_PANE_LISTVIEW::GetSelectRowsList( std::vector<long>& aSelectedList )
void SEARCH_PANE_LISTVIEW::OnItemActivated( wxListEvent& aEvent )
{
CallAfter(
[=]()
[&]()
{
m_handler->ActivateItem( aEvent.GetIndex() );
} );

View File

@ -241,6 +241,8 @@ public:
PDF_PLOTTER() :
m_pageTreeHandle( 0 ),
m_fontResDictHandle( 0 ),
m_imgResDictHandle( 0 ),
m_jsNamesHandle( 0 ),
m_pageStreamHandle( 0 ),
m_streamLengthHandle( 0 ),
m_workFile( nullptr ),

View File

@ -224,16 +224,18 @@ void UPDATE_MANAGER::CheckForUpdate( wxWindow* aNoticeParent )
if( response.version != settings->m_lastReceivedUpdate )
{
aNoticeParent->CallAfter(
[=]()
[&]()
{
auto notice = new DIALOG_UPDATE_NOTICE(
aNoticeParent, response.version, response.details_url,
response.downloads_url );
int retCode = notice->ShowModal();
if( retCode != wxID_RETRY )
{
// basically saving the last received update prevents us from prompting again
// basically saving the last received update prevents us from
// prompting again
settings->m_lastReceivedUpdate = response.version;
}
} );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Modifications Copyright (C) 2018-2021 KiCad Developers
* Modifications Copyright (C) 2018-2023 KiCad Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -60,6 +60,8 @@ class PolygonTriangulation
{
public:
PolygonTriangulation( SHAPE_POLY_SET::TRIANGULATED_POLYGON& aResult ) :
m_prefactor_x( 0.0 ),
m_prefactor_y( 0.0 ),
m_result( aResult )
{};

View File

@ -1177,10 +1177,23 @@ DIALOG_NET_INSPECTOR::~DIALOG_NET_INSPECTOR()
g_settings.col_order = column_order;
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
PCBNEW_SETTINGS* app_settings = mgr.GetAppSettings<PCBNEW_SETTINGS>();
app_settings->m_NetInspector.group_by_text = g_settings.group_by_text;
app_settings->m_NetInspector.group_by = g_settings.group_by;
app_settings->m_NetInspector.group_by_kind = g_settings.group_by_kind;
PCBNEW_SETTINGS* app_settings = nullptr;
try
{
app_settings = mgr.GetAppSettings<PCBNEW_SETTINGS>();
}
catch( const std::runtime_error& err )
{
wxLogWarning( wxS( "%s" ), err.what() );
}
if( app_settings )
{
app_settings->m_NetInspector.group_by_text = g_settings.group_by_text;
app_settings->m_NetInspector.group_by = g_settings.group_by;
app_settings->m_NetInspector.group_by_kind = g_settings.group_by_kind;
}
// the displayed list elements are going to be deleted before the list view itself.
// in some cases it might still do queries on the data model, which would crash

View File

@ -361,18 +361,18 @@ size_t FABMASTER::processPadStackLayers( size_t aRow )
continue;
}
auto pad_name = row[pad_name_col];
auto pad_num = row[pad_num_col];
auto pad_layer = row[pad_lay_col];
auto pad_is_fixed = row[pad_fix_col];
auto pad_is_via = row[pad_via_col];
auto pad_shape = row[pad_shape_col];
auto pad_width = row[pad_width_col];
auto pad_height = row[pad_height_col];
auto pad_xoff = row[pad_xoff_col];
auto pad_yoff = row[pad_yoff_col];
auto pad_flash = row[pad_flash_col];
auto pad_shapename = row[pad_shape_name_col];
auto& pad_name = row[pad_name_col];
auto& pad_num = row[pad_num_col];
auto& pad_layer = row[pad_lay_col];
auto& pad_is_fixed = row[pad_fix_col];
auto& pad_is_via = row[pad_via_col];
auto& pad_shape = row[pad_shape_col];
auto& pad_width = row[pad_width_col];
auto& pad_height = row[pad_height_col];
auto& pad_xoff = row[pad_xoff_col];
auto& pad_yoff = row[pad_yoff_col];
auto& pad_flash = row[pad_flash_col];
auto& pad_shapename = row[pad_shape_name_col];
// This layer setting seems to be unused
if( pad_layer == "INTERNAL_PAD_DEF" || pad_layer == "internal_pad_def" )
@ -444,18 +444,18 @@ size_t FABMASTER::processPadStacks( size_t aRow )
continue;
}
auto pad_name = row[pad_name_col];
auto pad_num = row[pad_num_col];
auto pad_layer = row[pad_lay_col];
auto pad_is_fixed = row[pad_fix_col];
auto pad_is_via = row[pad_via_col];
auto pad_shape = row[pad_shape_col];
auto pad_width = row[pad_width_col];
auto pad_height = row[pad_height_col];
auto pad_xoff = row[pad_xoff_col];
auto pad_yoff = row[pad_yoff_col];
auto pad_flash = row[pad_flash_col];
auto pad_shapename = row[pad_shape_name_col];
auto& pad_name = row[pad_name_col];
auto& pad_num = row[pad_num_col];
auto& pad_layer = row[pad_lay_col];
auto& pad_is_fixed = row[pad_fix_col];
auto& pad_is_via = row[pad_via_col];
auto& pad_shape = row[pad_shape_col];
auto& pad_width = row[pad_width_col];
auto& pad_height = row[pad_height_col];
auto& pad_xoff = row[pad_xoff_col];
auto& pad_yoff = row[pad_yoff_col];
auto& pad_flash = row[pad_flash_col];
auto& pad_shapename = row[pad_shape_name_col];
// This layer setting seems to be unused
if( pad_layer == "INTERNAL_PAD_DEF" || pad_layer == "internal_pad_def" )
@ -659,7 +659,7 @@ size_t FABMASTER::processSimpleLayers( size_t aRow )
if( rownum >= rows.size() )
return -1;
auto header = rows[aRow];
auto& header = rows[aRow];
double scale_factor = processScaleFactor( aRow + 1 );
if( scale_factor <= 0.0 )
@ -803,7 +803,7 @@ size_t FABMASTER::processLayers( size_t aRow )
if( rownum >= rows.size() )
return -1;
auto header = rows[aRow];
auto& header = rows[aRow];
double scale_factor = processScaleFactor( aRow + 1 );
if( scale_factor <= 0.0 )
@ -835,14 +835,14 @@ size_t FABMASTER::processLayers( size_t aRow )
continue;
}
auto layer_sort = row[layer_sort_col];
auto layer_subclass = row[layer_subclass_col];
auto layer_art = row[layer_art_col];
auto layer_use = row[layer_use_col];
auto layer_cond = row[layer_cond_col];
auto layer_er = row[layer_er_col];
auto layer_rho = row[layer_rho_col];
auto layer_mat = row[layer_mat_col];
auto& layer_sort = row[layer_sort_col];
auto& layer_subclass = row[layer_subclass_col];
auto& layer_art = row[layer_art_col];
auto& layer_use = row[layer_use_col];
auto& layer_cond = row[layer_cond_col];
auto& layer_er = row[layer_er_col];
auto& layer_rho = row[layer_rho_col];
auto& layer_mat = row[layer_mat_col];
if( layer_mat == "AIR" )
continue;
@ -878,7 +878,7 @@ size_t FABMASTER::processCustomPads( size_t aRow )
if( rownum >= rows.size() )
return -1;
auto header = rows[aRow];
auto& header = rows[aRow];
double scale_factor = processScaleFactor( aRow + 1 );
if( scale_factor <= 0.0 )
@ -923,9 +923,9 @@ size_t FABMASTER::processCustomPads( size_t aRow )
continue;
}
auto pad_layer = row[pad_subclass_col];
auto& pad_layer = row[pad_subclass_col];
auto pad_shape_name = row[pad_shape_name_col];
auto pad_record_tag = row[pad_record_tag_col];
auto& pad_record_tag = row[pad_record_tag_col];
GRAPHIC_DATA gr_data;
gr_data.graphic_dataname = row[pad_grdata_name_col];
@ -940,9 +940,9 @@ size_t FABMASTER::processCustomPads( size_t aRow )
gr_data.graphic_data8 = row[pad_grdata8_col];
gr_data.graphic_data9 = row[pad_grdata9_col];
auto pad_stack_name = row[pad_stack_name_col];
auto pad_refdes = row[pad_refdes_col];
auto pad_pin_num = row[pad_pin_num_col];
auto& pad_stack_name = row[pad_stack_name_col];
auto& pad_refdes = row[pad_refdes_col];
auto& pad_pin_num = row[pad_pin_num_col];
// N.B. We get the FIGSHAPE records as "FIG_SHAPE name". We only want "name"
// and we don't process other pad shape records
@ -1230,7 +1230,7 @@ size_t FABMASTER::processGeometry( size_t aRow )
continue;
}
auto geo_tag = row[geo_tag_col];
auto& geo_tag = row[geo_tag_col];
GRAPHIC_DATA gr_data;
gr_data.graphic_dataname = row[geo_name_col];
@ -1245,7 +1245,7 @@ size_t FABMASTER::processGeometry( size_t aRow )
gr_data.graphic_data8 = row[geo_grdata8_col];
gr_data.graphic_data9 = row[geo_grdata9_col];
auto geo_refdes = row[geo_refdes_col];
auto& geo_refdes = row[geo_refdes_col];
// Grouped graphics are a series of records with the same record ID but incrementing
// Sequence numbers.

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018-2019, 2023 KiCad Developers, see AUTHORS.TXT for contributors.
* Copyright (C) 2018-2023, 2023 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
@ -161,7 +161,7 @@ BOOST_AUTO_TEST_CASE( WithAlpha )
for( const auto& c : cases )
{
auto col = c.start;
auto& col = c.start;
const auto with_alpha = col.WithAlpha( c.factor );
BOOST_CHECK_EQUAL( with_alpha, c.expected );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 KiCad Developers, see AUTHORS.TXT for contributors.
* Copyright (C) 2022-2023 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
@ -25,6 +25,7 @@
#include <sim/sim_model_ngspice.h>
#include <boost/algorithm/string/predicate.hpp>
class TEST_SIM_MODEL_NGSPICE_FIXTURE : public SIM_MODEL_NGSPICE
{
public:
@ -52,15 +53,16 @@ BOOST_AUTO_TEST_CASE( ParamDuplicates )
{
// Ensure there's no model parameters that have the same name.
BOOST_CHECK( std::none_of( modelParams.begin(), modelParams.end(),
[modelParam]( const auto& aOtherModelParam )
[&modelParam]( const auto& aOtherModelParam )
{
return modelParam.id != aOtherModelParam.id
&& modelParam.name == aOtherModelParam.name;
} ) );
// Ensure there's no model parameters that have the same name as an instance parameter.
// Ensure there's no model parameters that have the same name as an
// instance parameter.
BOOST_CHECK( std::none_of( instanceParams.begin(), instanceParams.end(),
[modelParam]( const auto& aInstanceParam )
[&modelParam]( const auto& aInstanceParam )
{
return modelParam.name == aInstanceParam.name;
} ) );
@ -72,7 +74,7 @@ BOOST_AUTO_TEST_CASE( ParamDuplicates )
// We append an "_" to model parameters to disambiguate from these
// corresponding instance parameters.
BOOST_CHECK( std::any_of( instanceParams.begin(), instanceParams.end(),
[modelParam]( const auto& aInstanceParam )
[&modelParam]( const auto& aInstanceParam )
{
return modelParam.name.substr( 0, modelParam.name.length() - 1 )
== aInstanceParam.name;
@ -87,7 +89,7 @@ BOOST_AUTO_TEST_CASE( ParamDuplicates )
BOOST_TEST_CONTEXT( "Instance param name: " << instanceParam.name )
{
BOOST_CHECK( std::none_of( instanceParams.begin(), instanceParams.end(),
[instanceParam]( const auto& aOtherInstanceParam )
[&instanceParam]( const auto& aOtherInstanceParam )
{
return instanceParam.id != aOtherInstanceParam.id
&& instanceParam.dir != SIM_MODEL::PARAM::DIR_OUT
@ -300,7 +302,8 @@ BOOST_AUTO_TEST_CASE( ParamCount )
default:
BOOST_FAIL( wxString::Format(
"Unhandled type: %d "
"(if you created a new type you need to handle it in this switch statement)",
"(if you created a new type you need to handle it in this switch "
"statement)",
type ) );
}
}