From d4e04dcc9702a4eaf764af98cb2b56887c000be6 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 19 Jan 2015 20:03:50 +0100 Subject: [PATCH] Fix bugs detected by Cppcheck. --- common/gal/opengl/opengl_gal.cpp | 3 ++- cvpcb/autosel.cpp | 2 +- pcbnew/class_pcb_text.cpp | 2 +- pcbnew/cross-probing.cpp | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 569cacf23d..404e3a0728 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -812,10 +812,11 @@ void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd VECTOR2D startEndVector = aEndPoint - aStartPoint; double lineLength = startEndVector.EuclideanNorm(); - double scale = 0.5 * lineWidth / lineLength; if( lineLength <= 0.0 ) return; + + double scale = 0.5 * lineWidth / lineLength; // The perpendicular vector also needs transformations glm::vec4 vector = currentManager->GetTransformation() * diff --git a/cvpcb/autosel.cpp b/cvpcb/autosel.cpp index a6419aa745..8f4095f001 100644 --- a/cvpcb/autosel.cpp +++ b/cvpcb/autosel.cpp @@ -218,7 +218,7 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event ) bool equ_is_unique = true; unsigned next = idx+1; - unsigned previous = idx-1; + int previous = idx-1; if( next < equiv_List.size() && equivItem.m_ComponentValue == equiv_List[next].m_ComponentValue ) diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index f9bdee7f7d..bedc597e55 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -74,7 +74,7 @@ void TEXTE_PCB::Copy( TEXTE_PCB* source ) m_Bold = source->m_Bold; m_HJustify = source->m_HJustify; m_VJustify = source->m_VJustify; - m_MultilineAllowed = m_MultilineAllowed; + m_MultilineAllowed = source->m_MultilineAllowed; m_Text = source->m_Text; } diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index e09da9d899..d2ba0bef97 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -45,6 +45,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) wxPoint pos; strncpy( line, cmdline, sizeof(line) - 1 ); + line[sizeof(line) - 1] = 0; idcmd = strtok( line, " \n\r" ); text = strtok( NULL, " \n\r" );