diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index 1d54025f3c..cf81d8cc2b 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -177,7 +177,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL break; default: - wxFAIL_MSG( "PlotDrawingSheet(): Unknown drawing sheet item." ); + wxFAIL_MSG( wxT( "PlotDrawingSheet(): Unknown drawing sheet item." ) ); break; } } diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 8a11f71276..6bf91f5143 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -1177,10 +1177,10 @@ void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber ) { switch( aNumber ) { - case 0: m_statusLine1->SetLabel( aText ); break; - case 1: m_statusLine2->SetLabel( aText ); break; - case 2: m_statusLine3->SetLabel( aText ); break; - default: wxFAIL_MSG( "Invalid status row number" ); break; + case 0: m_statusLine1->SetLabel( aText ); break; + case 1: m_statusLine2->SetLabel( aText ); break; + case 2: m_statusLine3->SetLabel( aText ); break; + default: wxFAIL_MSG( wxT( "Invalid status row number" ) ); break; } } diff --git a/eeschema/dialogs/dialog_line_properties.cpp b/eeschema/dialogs/dialog_line_properties.cpp index 157600486e..aa645910d4 100644 --- a/eeschema/dialogs/dialog_line_properties.cpp +++ b/eeschema/dialogs/dialog_line_properties.cpp @@ -104,7 +104,7 @@ bool DIALOG_LINE_PROPERTIES::TransferDataToWindow() else if( style < (int) lineTypeNames.size() ) m_typeCombo->SetSelection( style ); else - wxFAIL_MSG( "Line type not found in the type lookup map" ); + wxFAIL_MSG( wxT( "Line type not found in the type lookup map" ) ); } else { diff --git a/eeschema/dialogs/dialog_shape_properties.cpp b/eeschema/dialogs/dialog_shape_properties.cpp index 0e5d419f1a..7e47b2fa36 100644 --- a/eeschema/dialogs/dialog_shape_properties.cpp +++ b/eeschema/dialogs/dialog_shape_properties.cpp @@ -143,7 +143,7 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataToWindow() else if( style < (int) lineTypeNames.size() ) m_borderStyleCombo->SetSelection( style ); else - wxFAIL_MSG( "Line type not found in the type lookup map" ); + wxFAIL_MSG( wxT( "Line type not found in the type lookup map" ) ); if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast( m_frame ) ) { diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 622ed5cc64..5bf2b729f5 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -827,7 +827,8 @@ bool SCH_EDIT_FRAME::saveSchematicFile( SCH_SHEET* aSheet, const wxString& aSave wxCHECK( screen, false ); // Cannot save to nowhere - wxCHECK( !aSavePath.IsEmpty(), false ); + if( aSavePath.IsEmpty() ) + return false; // Construct the name of the file to be saved schematicFileName = Prj().AbsolutePath( aSavePath ); diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 0c8311af6e..a82785c1bd 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -795,14 +795,15 @@ void LIB_SYMBOL::RemoveDrawItem( SCH_ITEM* aItem ) void LIB_SYMBOL::AddDrawItem( SCH_ITEM* aItem, bool aSort ) { - wxCHECK( aItem, /* void */ ); + if( aItem ) + { + aItem->SetParent( this ); - aItem->SetParent( this ); + m_drawings.push_back( aItem ); - m_drawings.push_back( aItem ); - - if( aSort ) - m_drawings.sort(); + if( aSort ) + m_drawings.sort(); + } } @@ -1791,8 +1792,6 @@ int LIB_SYMBOL::compare( const SCH_ITEM& aOther, int aCompareFlags ) const const LIB_SYMBOL* tmp = static_cast( &aOther ); - wxCHECK( tmp, -1 ); - return Compare( *tmp, aCompareFlags ); } diff --git a/eeschema/net_navigator.cpp b/eeschema/net_navigator.cpp index 02414a5f89..6802a14408 100644 --- a/eeschema/net_navigator.cpp +++ b/eeschema/net_navigator.cpp @@ -52,8 +52,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, { const SCH_LINE* line = static_cast( aItem ); - wxCHECK( line, retv ); - if( aItem->GetLayer() == LAYER_WIRE ) { retv.Printf( _( "Wire from %s, %s to %s, %s" ), @@ -80,33 +78,35 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, case SCH_PIN_T: { const SCH_PIN* pin = static_cast( aItem ); - wxCHECK( pin, retv ); - const SYMBOL* symbol = pin->GetParentSymbol(); - wxCHECK( symbol, retv ); + if( const SYMBOL* symbol = pin->GetParentSymbol() ) + { + retv.Printf( _( "Symbol '%s' pin '%s'" ), + symbol->GetRef( &aSheetPath, true ), + UnescapeString( pin->GetNumber() ) ); + } - retv.Printf( _( "Symbol '%s' pin '%s'" ), symbol->GetRef( &aSheetPath, true ), - UnescapeString( pin->GetNumber() ) ); break; } case SCH_SHEET_PIN_T: { const SCH_SHEET_PIN* pin = static_cast( aItem ); - wxCHECK( pin, retv ); - SCH_SHEET* sheet = pin->GetParent(); - wxCHECK( sheet, retv ); + if( SCH_SHEET* sheet = pin->GetParent() ) + { + retv.Printf( _( "Sheet '%s' pin '%s'" ), + sheet->GetName(), + UnescapeString( pin->GetText() ) ); + } - retv.Printf( _( "Sheet '%s' pin '%s'" ), sheet->GetName(), - UnescapeString( pin->GetText() ) ); break; } case SCH_LABEL_T: { const SCH_LABEL* label = static_cast( aItem ); - wxCHECK( label, retv ); - retv.Printf( _( "Label '%s' at %s, %s" ), UnescapeString( label->GetText() ), + retv.Printf( _( "Label '%s' at %s, %s" ), + UnescapeString( label->GetText() ), aUnitsProvider->MessageTextFromValue( label->GetPosition().x ), aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) ); break; @@ -114,7 +114,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, case SCH_GLOBAL_LABEL_T: { const SCH_GLOBALLABEL* label = static_cast( aItem ); - wxCHECK( label, retv ); retv.Printf( _( "Global label '%s' at %s, %s" ), UnescapeString( label->GetText() ), aUnitsProvider->MessageTextFromValue( label->GetPosition().x ), @@ -124,7 +123,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, case SCH_HIER_LABEL_T: { const SCH_HIERLABEL* label = static_cast( aItem ); - wxCHECK( label, retv ); retv.Printf( _( "Hierarchical label '%s' at %s, %s" ), UnescapeString( label->GetText() ), aUnitsProvider->MessageTextFromValue( label->GetPosition().x ), @@ -134,7 +132,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, case SCH_JUNCTION_T: { const SCH_JUNCTION* junction = static_cast( aItem ); - wxCHECK( junction, retv ); retv.Printf( _( "Junction at %s, %s" ), aUnitsProvider->MessageTextFromValue( junction->GetPosition().x ), @@ -144,7 +141,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, case SCH_NO_CONNECT_T: { const SCH_NO_CONNECT* nc = static_cast( aItem ); - wxCHECK( nc, retv ); retv.Printf( _( "No-Connect at %s, %s" ), aUnitsProvider->MessageTextFromValue( nc->GetPosition().x ), @@ -154,7 +150,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, case SCH_BUS_WIRE_ENTRY_T: { const SCH_BUS_WIRE_ENTRY* entry = static_cast( aItem ); - wxCHECK( entry, retv ); retv.Printf( _( "Bus to wire entry from %s, %s to %s, %s" ), aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ), @@ -166,7 +161,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, case SCH_BUS_BUS_ENTRY_T: { const SCH_BUS_BUS_ENTRY* entry = static_cast( aItem ); - wxCHECK( entry, retv ); retv.Printf( _( "Bus to bus entry from %s, %s to %s, %s" ), aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ), @@ -178,7 +172,6 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, case SCH_DIRECTIVE_LABEL_T: { const SCH_DIRECTIVE_LABEL* entry = static_cast( aItem ); - wxCHECK( entry, retv ); retv.Printf( _( "Netclass label '%s' at %s, %s" ), UnescapeString( entry->GetText() ), aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ), diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 67aceaddd7..4481411f15 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -444,9 +444,9 @@ void SCH_BASE_FRAME::AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen ) // Null pointers will cause boost::ptr_vector to raise a boost::bad_pointer exception which // will be unhandled. There is no valid reason to pass an invalid EDA_ITEM pointer to the // screen append function. - wxCHECK( aItem != nullptr, /* void */ ); + wxCHECK( aItem, /* void */ ); - auto screen = aScreen; + SCH_SCREEN* screen = aScreen; if( aScreen == nullptr ) screen = GetScreen(); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index c857a2a3a6..17cf5f7993 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1121,12 +1121,13 @@ void SCH_EDIT_FRAME::OnModify() { EDA_BASE_FRAME::OnModify(); - wxCHECK( GetScreen(), /* void */ ); + if( GetScreen() ) + GetScreen()->SetContentModified(); - GetScreen()->SetContentModified(); m_autoSaveRequired = true; - GetCanvas()->Refresh(); + if( GetCanvas() ) + GetCanvas()->Refresh(); if( !GetTitle().StartsWith( wxS( "*" ) ) ) updateTitle(); diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index f0d1c82a17..e9520fde43 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -540,12 +540,13 @@ void SYMBOL_EDIT_FRAME::Save() void SYMBOL_EDIT_FRAME::SaveLibraryAs() { - wxCHECK( !GetTargetLibId().GetLibNickname().empty(), /* void */ ); - const wxString& libName = GetTargetLibId().GetLibNickname(); - saveLibrary( libName, true ); - m_treePane->GetLibTree()->RefreshLibTree(); + if( !libName.IsEmpty() ) + { + saveLibrary( libName, true ); + m_treePane->GetLibTree()->RefreshLibTree(); + } } @@ -895,22 +896,15 @@ void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard ) wxLogMessage( wxS( "Can not paste: %s" ), e.Problem() ); } } - else + else if( LIB_SYMBOL* srcSymbol = m_libMgr->GetBufferedSymbol( libId.GetLibItemName(), lib ) ) { - LIB_SYMBOL* srcSymbol = m_libMgr->GetBufferedSymbol( libId.GetLibItemName(), lib ); - - wxCHECK( srcSymbol, /* void */ ); - newSymbols.emplace_back( new LIB_SYMBOL( *srcSymbol ) ); // Derive from same parent. if( srcSymbol->IsAlias() ) { - std::shared_ptr< LIB_SYMBOL > srcParent = srcSymbol->GetParent().lock(); - - wxCHECK( srcParent, /* void */ ); - - newSymbols.back()->SetParent( srcParent.get() ); + if( std::shared_ptr srcParent = srcSymbol->GetParent().lock() ) + newSymbols.back()->SetParent( srcParent.get() ); } } @@ -935,16 +929,17 @@ void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard ) void SYMBOL_EDIT_FRAME::ensureUniqueName( LIB_SYMBOL* aSymbol, const wxString& aLibrary ) { - wxCHECK( aSymbol, /* void */ ); + if( aSymbol ) + { + int i = 1; + wxString newName = aSymbol->GetName(); - int i = 1; - wxString newName = aSymbol->GetName(); + // Append a number to the name until the name is unique in the library. + while( m_libMgr->SymbolExists( newName, aLibrary ) ) + newName.Printf( "%s_%d", aSymbol->GetName(), i++ ); - // Append a number to the name until the name is unique in the library. - while( m_libMgr->SymbolExists( newName, aLibrary ) ) - newName.Printf( "%s_%d", aSymbol->GetName(), i++ ); - - aSymbol->SetName( newName ); + aSymbol->SetName( newName ); + } } diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 584c64428a..dc3bb46f52 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -1056,12 +1056,10 @@ OPT_TOOL_EVENT EE_SELECTION_TOOL::autostartEvent( TOOL_EVENT* aEvent, EE_GRID_HE else if( aItem->Type() == SCH_SYMBOL_T ) { const SCH_SYMBOL* symbol = static_cast( aItem ); + const SCH_PIN* pin = symbol->GetPin( pos ); - wxCHECK( symbol, OPT_TOOL_EVENT() ); - - const SCH_PIN* pin = symbol->GetPin( pos ); - - wxCHECK( pin, OPT_TOOL_EVENT() ); + if( !pin ) + return OPT_TOOL_EVENT(); if( !pin->IsVisible() && !( m_frame->eeconfig()->m_Appearance.show_hidden_pins diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 9b08b1330f..dfce43ba7d 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -590,17 +590,18 @@ const wxString BOARD::GetLayerName( PCB_LAYER_ID aLayer ) const bool BOARD::SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName ) { - wxCHECK( !aLayerName.IsEmpty(), false ); - - // no quote chars in the name allowed - if( aLayerName.Find( wxChar( '"' ) ) != wxNOT_FOUND ) - return false; - - if( IsLayerEnabled( aLayer ) ) + if( !aLayerName.IsEmpty() ) { - m_layers[aLayer].m_userName = aLayerName; - recalcOpposites(); - return true; + // no quote chars in the name allowed + if( aLayerName.Find( wxChar( '"' ) ) != wxNOT_FOUND ) + return false; + + if( IsLayerEnabled( aLayer ) ) + { + m_layers[aLayer].m_userName = aLayerName; + recalcOpposites(); + return true; + } } return false; diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index cc0a6bcfa0..882df71c32 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -86,8 +86,6 @@ BOARD* BOARD_COMMIT::GetBoard() const COMMIT& BOARD_COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType, BASE_SCREEN* aScreen ) { - wxCHECK( aItem, *this ); - // Many operations (move, rotate, etc.) are applied directly to a group's children, so they // must be staged as well. if( aChangeType == CHT_MODIFY ) diff --git a/pcbnew/board_item.cpp b/pcbnew/board_item.cpp index dddaedd156..197fe57d0f 100644 --- a/pcbnew/board_item.cpp +++ b/pcbnew/board_item.cpp @@ -85,13 +85,15 @@ bool BOARD_ITEM::IsLocked() const STROKE_PARAMS BOARD_ITEM::GetStroke() const { - wxCHECK( false, STROKE_PARAMS( pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) ) ); + wxFAIL_MSG( wxString( "GetStroke() not defined by " ) + GetClass() ); + + return STROKE_PARAMS( pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) ); } void BOARD_ITEM::SetStroke( const STROKE_PARAMS& aStroke ) { - wxCHECK( false, /* void */ ); + wxFAIL_MSG( wxString( "SetStroke() not defined by " ) + GetClass() ); } diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 654c284409..1ab407d740 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -441,6 +441,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* aTestItem, void* aTestData } else if( aTestItem->Type() == PCB_FOOTPRINT_T ) { + // Already tested above, but Coverity can't figure that out wxCHECK( footprint, INSPECT_RESULT::CONTINUE ); if( footprint->HitTest( m_refPos, accuracy ) diff --git a/pcbnew/generators/pcb_tuning_pattern.cpp b/pcbnew/generators/pcb_tuning_pattern.cpp index 75dd775c05..97236f6cf9 100644 --- a/pcbnew/generators/pcb_tuning_pattern.cpp +++ b/pcbnew/generators/pcb_tuning_pattern.cpp @@ -931,8 +931,6 @@ static std::optional getPNSLine( const VECTOR2I& aStart, const VECTOR PNS::LINKED_ITEM* startItem = pickSegment( router, aStart, layer, aStartOut ); PNS::LINKED_ITEM* endItem = pickSegment( router, aEnd, layer, aEndOut ); - //wxCHECK( startItem && endItem, std::nullopt ); - for( PNS::LINKED_ITEM* testItem : { startItem, endItem } ) { if( !testItem ) diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 998fae389c..0c5e5ec438 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -57,7 +57,8 @@ static void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMa void PlotBoardLayers( BOARD* aBoard, PLOTTER* aPlotter, const LSEQ& aLayers, const PCB_PLOT_PARAMS& aPlotOptions ) { - wxCHECK( aBoard && aPlotter && aLayers.size(), /* void */ ); + if( !aBoard || !aPlotter || aLayers.empty() ) + return; // if a drill mark must be plotted, the copper layer needs to be plotted // after other layers because the drill mark must be plotted as a filled diff --git a/pcbnew/router/pns_joint.h b/pcbnew/router/pns_joint.h index a4afaa9e1a..0ba65f0fcc 100644 --- a/pcbnew/router/pns_joint.h +++ b/pcbnew/router/pns_joint.h @@ -139,9 +139,8 @@ public: } } - wxCHECK( seg1 && seg2, false ); - - return seg1->Width() == seg2->Width(); + if( seg1 && seg2 ) + return seg1->Width() == seg2->Width(); } return false; diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 34c9b212ab..76960ec282 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -197,7 +197,8 @@ bool PNS_PCBNEW_RULE_RESOLVER::IsNetTieExclusion( const PNS::ITEM* aItem, const VECTOR2I& aCollisionPos, const PNS::ITEM* aCollidingItem ) { - wxCHECK( aItem && aCollidingItem, false ); + if( !aItem || !aCollidingItem ) + return false; std::shared_ptr drcEngine = m_board->GetDesignSettings().m_DRCEngine; BOARD_ITEM* item = aItem->BoardItem(); diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index 6f971e2c56..f59d8ae6d5 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -975,7 +975,8 @@ void NODE::followLine( LINKED_ITEM* aCurrent, bool aScanDirection, int& aPos, in const VECTOR2I p = aCurrent->Anchor( aScanDirection ^ prevReversed ); const JOINT* jt = FindJoint( p, aCurrent ); - wxCHECK( jt, /* void */ ); + if( !jt ) + break; aCorners[aPos] = jt->Pos(); aSegments[aPos] = aCurrent; @@ -985,7 +986,9 @@ void NODE::followLine( LINKED_ITEM* aCurrent, bool aScanDirection, int& aPos, in { if( ( aScanDirection && jt->Pos() == aCurrent->Anchor( 0 ) ) || ( !aScanDirection && jt->Pos() == aCurrent->Anchor( 1 ) ) ) + { aArcReversed[aPos] = true; + } } aPos += ( aScanDirection ? 1 : -1 );