Skip to content

Commit da092bf

Browse files
committed
Coverity fixes: uninitialised members
1 parent f6d0e70 commit da092bf

11 files changed

+32
-30
lines changed

src/core/pal/layer.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ namespace pal
6262
: pal( pal ), obstacle( obstacle ), active( active ),
6363
toLabel( toLabel ), displayAll( displayAll ), centroidInside( false ), label_unit( label_unit ),
6464
min_scale( min_scale ), max_scale( max_scale ),
65-
arrangement( arrangement ), arrangementFlags( 0 ), mode( LabelPerFeature ), mergeLines( false )
65+
arrangement( arrangement ), arrangementFlags( 0 ), mode( LabelPerFeature ), mergeLines( false ),
66+
upsidedownLabels( Upright )
6667
{
6768

6869
this->name = new char[strlen( lyrName ) +1];

src/core/pal/problem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,7 @@ namespace pal
21972197

21982198
maxit = probSize * pal->tabuMaxIt;
21992199

2200-
itwimp = probSize * pal->tabuMinIt;;
2200+
itwimp = probSize * pal->tabuMinIt;
22012201

22022202
stop_it = itwimp;
22032203

src/core/qgsvectorfilewriter.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ QgsVectorFileWriter::QgsVectorFileWriter(
7070
, mLayer( NULL )
7171
, mGeom( NULL )
7272
, mError( NoError )
73+
, mCodec( 0 )
74+
, mWkbType( geometryType )
7375
, mSymbologyExport( symbologyExport )
76+
, mSymbologyScaleDenominator( 1.0 )
7477
{
7578
QString vectorFileName = theVectorFileName;
7679
QString fileEncoding = theFileEncoding;

src/core/qgsvectorlayerimport.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ QgsVectorLayerImport::QgsVectorLayerImport( const QString &uri,
5151
const QMap<QString, QVariant> *options,
5252
QProgressDialog *progress )
5353
: mErrorCount( 0 )
54+
, mAttributeCount( -1 )
5455
, mProgress( progress )
56+
5557
{
5658
mProvider = NULL;
5759

@@ -76,8 +78,6 @@ QgsVectorLayerImport::QgsVectorLayerImport( const QString &uri,
7678

7779
delete myLib;
7880

79-
mAttributeCount = -1;
80-
8181
// create an empty layer
8282
QString errMsg;
8383
mError = pCreateEmpty( uri, fields, geometryType, crs, overwrite, &mOldToNewAttrIdx, &errMsg, options );

src/core/raster/qgscolorrampshader.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ originally part of the larger QgsRasterLayer class
2727

2828
QgsColorRampShader::QgsColorRampShader( double theMinimumValue, double theMaximumValue )
2929
: QgsRasterShaderFunction( theMinimumValue, theMaximumValue )
30+
, mColorRampType( INTERPOLATED )
3031
, mClip( false )
3132
{
3233
QgsDebugMsg( "called." );

src/core/raster/qgsrasterprojector.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ QgsRasterProjector::QgsRasterProjector(
9393
, mDestRowsPerMatrixRow( 0.0 )
9494
, mDestColsPerMatrixCol( 0.0 )
9595
, pHelperTop( 0 ), pHelperBottom( 0 )
96+
, mHelperTopRow( 0 )
9697
, mCPCols( 0 )
9798
, mCPRows( 0 )
9899
, mSqrTolerance( 0.0 )

src/plugins/spit/qgsshapefile.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@
4242
#endif
4343

4444
QgsShapeFile::QgsShapeFile( QString name, QString encoding )
45+
: ogrLayer( 0 )
46+
, import_canceled( false )
47+
, valid( false )
48+
, isMulti( false )
49+
, hasMoreDimensions( false )
50+
, features( 0 )
51+
, fileName( name )
4552
{
46-
fileName = name;
47-
features = 0;
4853
QgsApplication::registerOgrDrivers();
4954

5055
QSettings settings;
@@ -57,8 +62,7 @@ QgsShapeFile::QgsShapeFile( QString name, QString encoding )
5762
ogrLayer = OGR_DS_GetLayer( ogrDataSource, 0 );
5863
features = OGR_L_GetFeatureCount( ogrLayer, true );
5964
}
60-
else
61-
valid = false;
65+
6266
setDefaultTable();
6367
// init the geometry types
6468
geometries << "NULL" << "POINT" << "LINESTRING" << "POLYGON" << "MULTIPOINT"

src/providers/gpx/qgsgpxprovider.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ const QString GPX_DESCRIPTION = QObject::tr( "GPS eXchange format provider" );
6969

7070
QgsGPXProvider::QgsGPXProvider( QString uri )
7171
: QgsVectorDataProvider( uri )
72+
, data( 0 )
73+
, mFeatureType( WaypointType )
74+
, mValid( false ) // assume that it won't work
7275
{
73-
// assume that it won't work
74-
mValid = false;
75-
7676
// we always use UTF-8
7777
mEncoding = QTextCodec::codecForName( "utf8" );
7878

src/providers/gpx/qgsgpxprovider.h

-10
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,6 @@ class QgsGPXProvider : public QgsVectorDataProvider
165165
static const int attrCount;
166166

167167
bool mValid;
168-
long mNumberFeatures;
169-
170-
struct wkbPoint
171-
{
172-
char byteOrder;
173-
unsigned wkbType;
174-
double x;
175-
double y;
176-
};
177-
wkbPoint mWKBpt;
178168

179169
friend class QgsGPXFeatureSource;
180170
};

src/providers/spatialite/qgsspatialiteprovider.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,18 @@ QgsSpatiaLiteProvider::createEmptyLayer(
411411

412412
QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
413413
: QgsVectorDataProvider( uri )
414+
, valid( false )
415+
, isQuery( false )
416+
, mTableBased( false )
417+
, mViewBased( false )
418+
, mVShapeBased( false )
419+
, mReadOnly( false )
414420
, geomType( QGis::WKBUnknown )
415421
, sqliteHandle( NULL )
416422
, mSrid( -1 )
417423
, spatialIndexRTree( false )
418424
, spatialIndexMbrCache( false )
425+
, enabledCapabilities( 0 )
419426
, mGotSpatialiteVersion( false )
420427
, mSpatialiteVersionMajor( 0 )
421428
, mSpatialiteVersionMinor( 0 )
@@ -433,11 +440,9 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
433440

434441
// trying to open the SQLite DB
435442
spatialite_init( 0 );
436-
valid = true;
437443
handle = QgsSqliteHandle::openDb( mSqlitePath );
438444
if ( handle == NULL )
439445
{
440-
valid = false;
441446
return;
442447
}
443448
sqliteHandle = handle->handle();
@@ -486,7 +491,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
486491
{
487492
// invalid metadata
488493
numberFeatures = 0;
489-
valid = false;
490494

491495
QgsDebugMsg( "Invalid SpatiaLite layer" );
492496
closeDb();
@@ -514,7 +518,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
514518
{
515519
// the table is not a geometry table
516520
numberFeatures = 0;
517-
valid = false;
518521
QgsDebugMsg( "Invalid SpatiaLite layer" );
519522
closeDb();
520523
gaiaFreeVectorLayersList( list );
@@ -523,7 +526,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
523526
if ( !getTableSummaryAbstractInterface( lyr ) ) // gets the extent and feature count
524527
{
525528
numberFeatures = 0;
526-
valid = false;
527529
QgsDebugMsg( "Invalid SpatiaLite layer" );
528530
closeDb();
529531
gaiaFreeVectorLayersList( list );
@@ -543,15 +545,13 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
543545
{
544546
// the table is not a geometry table
545547
numberFeatures = 0;
546-
valid = false;
547548
QgsDebugMsg( "Invalid SpatiaLite layer" );
548549
closeDb();
549550
return;
550551
}
551552
if ( !getTableSummary() ) // gets the extent and feature count
552553
{
553554
numberFeatures = 0;
554-
valid = false;
555555
QgsDebugMsg( "Invalid SpatiaLite layer" );
556556
closeDb();
557557
return;
@@ -561,7 +561,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
561561
}
562562
if ( sqliteHandle == NULL )
563563
{
564-
valid = false;
565564
QgsDebugMsg( "Invalid SpatiaLite layer" );
566565
return;
567566
}
@@ -576,6 +575,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
576575
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "FLOAT", QVariant::Double )
577576
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "INTEGER", QVariant::LongLong )
578577
;
578+
valid = true;
579579
}
580580

581581
QgsSpatiaLiteProvider::~QgsSpatiaLiteProvider()
@@ -4145,7 +4145,7 @@ bool QgsSpatiaLiteProvider::checkLayerType()
41454145

41464146
QString sql;
41474147

4148-
if ( mGeometryColumn.isEmpty() && !(mQuery.startsWith( "(" ) && mQuery.endsWith( ")" )) )
4148+
if ( mGeometryColumn.isEmpty() && !( mQuery.startsWith( "(" ) && mQuery.endsWith( ")" ) ) )
41494149
{
41504150
// checking if is a non-spatial table
41514151
sql = QString( "SELECT type FROM sqlite_master "

tests/src/core/testqgsrasterlayer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ void TestQgsRasterLayer::checkScaleOffset()
420420
mReport += QString( " %1 = %2 <br>\n" ).arg( myProvider->generateBandName( bandNo ) ).arg( valueString );
421421
delete myRasterLayer;
422422
QVERIFY( false );
423+
return;
423424
}
424425
else
425426
{
@@ -436,6 +437,7 @@ void TestQgsRasterLayer::checkScaleOffset()
436437
{
437438
delete myRasterLayer;
438439
QVERIFY( false );
440+
return;
439441
}
440442

441443
mReport += "<p>Passed</p>";

0 commit comments

Comments
 (0)