From 6e8a8a6b2578c0dfe6d162ba7527d79289c03aee Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 21 Mar 2015 10:06:04 +0100 Subject: [PATCH] Fix some coverity warnings (mainly not initialized members) --- common/gal/cairo/cairo_compositor.cpp | 4 ++++ common/gal/graphics_abstraction_layer.cpp | 2 ++ common/gal/opengl/cached_container.cpp | 5 +++++ common/gal/opengl/shader.cpp | 3 +++ eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp | 1 + eeschema/dialogs/dialog_edit_one_field.h | 8 ++++++++ lib_dxf/libdxfrw.cpp | 2 +- pcbnew/exporters/export_gencad.cpp | 5 ++--- pcbnew/gpcb_plugin.cpp | 2 ++ 9 files changed, 28 insertions(+), 4 deletions(-) diff --git a/common/gal/cairo/cairo_compositor.cpp b/common/gal/cairo/cairo_compositor.cpp index d94b19b3c0..f81cb5a0bd 100644 --- a/common/gal/cairo/cairo_compositor.cpp +++ b/common/gal/cairo/cairo_compositor.cpp @@ -36,6 +36,10 @@ using namespace KIGFX; CAIRO_COMPOSITOR::CAIRO_COMPOSITOR( cairo_t** aMainContext ) : m_current( 0 ), m_currentContext( aMainContext ), m_mainContext( *aMainContext ) { + // Do not have uninitialized members: + cairo_matrix_init_identity( &m_matrix ); + m_stride = 0; + m_bufferSize = 0; } diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 0142a36bab..eea095e48b 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -48,8 +48,10 @@ GAL::GAL() : SetWorldUnitLength( 1.0 / METRIC_UNIT_LENGTH * 2.54 ); // 1 inch in nanometers SetScreenDPI( 106 ); // Display resolution setting SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) ); + SetLayerDepth( 0.0 ); SetFlip( false, false ); SetLineWidth( 1.0 ); + ComputeWorldScale(); // Set grid defaults SetGridVisibility( true ); diff --git a/common/gal/opengl/cached_container.cpp b/common/gal/opengl/cached_container.cpp index 34bd24df50..4caf93663a 100644 --- a/common/gal/opengl/cached_container.cpp +++ b/common/gal/opengl/cached_container.cpp @@ -47,6 +47,11 @@ CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) : { // In the beginning there is only free space m_freeChunks.insert( CHUNK( aSize, 0 ) ); + + // Do not have uninitialized members: + m_chunkSize = 0; + m_chunkOffset = 0; + m_itemSize = 0; } diff --git a/common/gal/opengl/shader.cpp b/common/gal/opengl/shader.cpp index 04157ae0c4..228d53de21 100644 --- a/common/gal/opengl/shader.cpp +++ b/common/gal/opengl/shader.cpp @@ -45,7 +45,10 @@ SHADER::SHADER() : maximumVertices( 4 ), geomInputType( GL_LINES ), geomOutputType( GL_LINES ) + { + // Do not have uninitialized members: + programNumber = 0; } diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index 6195982a49..1de0d495b9 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -164,6 +164,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( { m_parent = aParent; m_libEntry = aLibEntry; + m_skipCopyFromPanel = false; GetSizer()->SetSizeHints( this ); Centre(); diff --git a/eeschema/dialogs/dialog_edit_one_field.h b/eeschema/dialogs/dialog_edit_one_field.h index 9ea079ab02..7edd99b1bf 100644 --- a/eeschema/dialogs/dialog_edit_one_field.h +++ b/eeschema/dialogs/dialog_edit_one_field.h @@ -59,6 +59,14 @@ public: { m_parent = aParent; SetTitle( aTitle ); + + // Avoid not initialized members: + m_textshape = 0; + m_textsize = 0; + m_textorient = 0; + m_textHjustify = GR_TEXT_HJUSTIFY_CENTER; + m_textVjustify = GR_TEXT_VJUSTIFY_CENTER; + m_text_invisible = false; } // ~DIALOG_EDIT_ONE_FIELD() {}; diff --git a/lib_dxf/libdxfrw.cpp b/lib_dxf/libdxfrw.cpp index 729977b410..fedda4f841 100644 --- a/lib_dxf/libdxfrw.cpp +++ b/lib_dxf/libdxfrw.cpp @@ -1403,7 +1403,7 @@ bool dxfRW::writeDimension( DRW_Dimension* ent ) writer->writeUtf8String( 3, ent->getStyle() ); - if( ent->getTextLineFactor() != 0 ) + if( ent->getDir() != 0 ) writer->writeDouble( 53, ent->getDir() ); writer->writeDouble( 210, ent->getExtrusion().x ); diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index 2831d87338..8c65fa25ad 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -1030,13 +1030,12 @@ static void CreateBoardSection( FILE* aFile, BOARD* aPcb ) fputs( "$BOARD\n", aFile ); // Extract the board edges - for( EDA_ITEM* drawing = aPcb->m_Drawings; - drawing != 0; + for( EDA_ITEM* drawing = aPcb->m_Drawings; drawing != 0; drawing = drawing->Next() ) { if( drawing->Type() == PCB_LINE_T ) { - DRAWSEGMENT* drawseg = dynamic_cast( drawing ); + DRAWSEGMENT* drawseg = static_cast( drawing ); if( drawseg->GetLayer() == Edge_Cuts ) { // XXX GenCAD supports arc boundaries but I've seen nothing that reads them diff --git a/pcbnew/gpcb_plugin.cpp b/pcbnew/gpcb_plugin.cpp index 97c6804ebe..e138efb12e 100644 --- a/pcbnew/gpcb_plugin.cpp +++ b/pcbnew/gpcb_plugin.cpp @@ -855,6 +855,7 @@ GPCB_PLUGIN::GPCB_PLUGIN() : m_cache( 0 ), m_ctl( 0 ) { + m_reader = NULL; init( 0 ); } @@ -863,6 +864,7 @@ GPCB_PLUGIN::GPCB_PLUGIN( int aControlFlags ) : m_cache( 0 ), m_ctl( aControlFlags ) { + m_reader = NULL; init( 0 ); }