From 415dcf82c461f0e7f2406b943d69ba038d6c3c62 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 10 Jul 2023 17:48:06 -0400 Subject: [PATCH] Coverity issue fixes. CIDs 462497, 462496, 462495, 462494 --- .../netlist_exporters/netlist_exporter_allegro.cpp | 12 +++++++----- .../netlist_exporters/netlist_exporter_allegro.h | 7 ++++--- kicad/project_tree_pane.cpp | 6 ++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/eeschema/netlist_exporters/netlist_exporter_allegro.cpp b/eeschema/netlist_exporters/netlist_exporter_allegro.cpp index 3383c7034a..3083e2d35b 100644 --- a/eeschema/netlist_exporters/netlist_exporter_allegro.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_allegro.cpp @@ -421,7 +421,7 @@ void NETLIST_EXPORTER_ALLEGRO::toAllegroPackages() wxArrayString footprintAlt; wxArrayString footprintArray = sym->GetLibSymbolRef()->GetFPFilters(); - for( auto fp : footprintArray ) + for( const wxString& fp : footprintArray ) { if( ( fp.Find( '*' ) != wxNOT_FOUND ) || ( fp.Find( '?' ) != wxNOT_FOUND ) ) { @@ -491,10 +491,12 @@ void NETLIST_EXPORTER_ALLEGRO::toAllegroPackages() fprintf( d, "PACKAGEPROP ALT_SYMBOLS '(" ); wxString footprintAltSymbolsText; - for( auto fp : footprintAlt ) + + for( const wxString& fp : footprintAlt ) { footprintAltSymbolsText += fp + wxString( "," ); } + footprintAltSymbolsText.Truncate( footprintAltSymbolsText.Length() - 1 ); fprintf( d, "%s)'\n", TO_UTF8( footprintAltSymbolsText ) ); } @@ -609,7 +611,7 @@ wxString NETLIST_EXPORTER_ALLEGRO::formatFunction( wxString aName, LIB_PINS aPin out_str.Printf( wxT( "PINORDER %s " ), TO_UTF8( aName ) ); - for( wxString& pinName : pinNameList ) + for( const wxString& pinName : pinNameList ) { str.Printf( ",\n\t%s", TO_UTF8( pinName ) ); out_str += str; @@ -640,7 +642,7 @@ wxString NETLIST_EXPORTER_ALLEGRO::getGroupField( int aGroupIndex, const wxArray SCH_SYMBOL* sym = ( iter->second ).first; SCH_SHEET_PATH sheetPath = ( iter->second ).second; - for( auto field : aFieldArray ) + for( const wxString& field : aFieldArray ) { SCH_FIELD* fld = sym->FindField( field, true, true ); @@ -666,7 +668,7 @@ wxString NETLIST_EXPORTER_ALLEGRO::getGroupField( int aGroupIndex, const wxArray { SCH_SYMBOL* sym = ( iter->second ).first; - for( auto field : aFieldArray ) + for( const wxString& field : aFieldArray ) { LIB_FIELD* fld = sym->GetLibSymbolRef()->FindField( field, true ); diff --git a/eeschema/netlist_exporters/netlist_exporter_allegro.h b/eeschema/netlist_exporters/netlist_exporter_allegro.h index ef15635a9e..7d6e85761a 100644 --- a/eeschema/netlist_exporters/netlist_exporter_allegro.h +++ b/eeschema/netlist_exporters/netlist_exporter_allegro.h @@ -3,7 +3,7 @@ * * Copyright (C) 1992-2013 jp.charras at wanadoo.fr * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-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 @@ -35,7 +35,8 @@ class NETLIST_EXPORTER_ALLEGRO : public NETLIST_EXPORTER_BASE { public: NETLIST_EXPORTER_ALLEGRO( SCHEMATIC* aSchematic ) : - NETLIST_EXPORTER_BASE( aSchematic ) + NETLIST_EXPORTER_BASE( aSchematic ), + m_f( nullptr ) { } @@ -212,4 +213,4 @@ private: std::multimap m_netNameNodes; ///< Store the NET_NODE with the net name }; -#endif \ No newline at end of file +#endif diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp index 356fd1d367..da92efd213 100644 --- a/kicad/project_tree_pane.cpp +++ b/kicad/project_tree_pane.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-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 @@ -242,7 +242,9 @@ void PROJECT_TREE_PANE::onCreateNewDirectory( wxCommandEvent& event ) wxString full_dirname = curr_dir + wxFileName::GetPathSeparator() + new_dir; - wxMkdir( full_dirname ); + if( !wxMkdir( full_dirname ) ) + return; + addItemToProjectTree( full_dirname, item_data->GetId(), nullptr, false ); } }