Skip to content

Commit

Permalink
Coverity fixes: uninitialised members
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 16, 2015
1 parent f6d0e70 commit da092bf
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 30 deletions.
3 changes: 2 additions & 1 deletion src/core/pal/layer.cpp
Expand Up @@ -62,7 +62,8 @@ namespace pal
: pal( pal ), obstacle( obstacle ), active( active ),
toLabel( toLabel ), displayAll( displayAll ), centroidInside( false ), label_unit( label_unit ),
min_scale( min_scale ), max_scale( max_scale ),
arrangement( arrangement ), arrangementFlags( 0 ), mode( LabelPerFeature ), mergeLines( false )
arrangement( arrangement ), arrangementFlags( 0 ), mode( LabelPerFeature ), mergeLines( false ),
upsidedownLabels( Upright )
{

this->name = new char[strlen( lyrName ) +1];
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/problem.cpp
Expand Up @@ -2197,7 +2197,7 @@ namespace pal

maxit = probSize * pal->tabuMaxIt;

itwimp = probSize * pal->tabuMinIt;;
itwimp = probSize * pal->tabuMinIt;

stop_it = itwimp;

Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -70,7 +70,10 @@ QgsVectorFileWriter::QgsVectorFileWriter(
, mLayer( NULL )
, mGeom( NULL )
, mError( NoError )
, mCodec( 0 )
, mWkbType( geometryType )
, mSymbologyExport( symbologyExport )
, mSymbologyScaleDenominator( 1.0 )
{
QString vectorFileName = theVectorFileName;
QString fileEncoding = theFileEncoding;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayerimport.cpp
Expand Up @@ -51,7 +51,9 @@ QgsVectorLayerImport::QgsVectorLayerImport( const QString &uri,
const QMap<QString, QVariant> *options,
QProgressDialog *progress )
: mErrorCount( 0 )
, mAttributeCount( -1 )
, mProgress( progress )

{
mProvider = NULL;

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

delete myLib;

mAttributeCount = -1;

// create an empty layer
QString errMsg;
mError = pCreateEmpty( uri, fields, geometryType, crs, overwrite, &mOldToNewAttrIdx, &errMsg, options );
Expand Down
1 change: 1 addition & 0 deletions src/core/raster/qgscolorrampshader.cpp
Expand Up @@ -27,6 +27,7 @@ originally part of the larger QgsRasterLayer class

QgsColorRampShader::QgsColorRampShader( double theMinimumValue, double theMaximumValue )
: QgsRasterShaderFunction( theMinimumValue, theMaximumValue )
, mColorRampType( INTERPOLATED )
, mClip( false )
{
QgsDebugMsg( "called." );
Expand Down
1 change: 1 addition & 0 deletions src/core/raster/qgsrasterprojector.cpp
Expand Up @@ -93,6 +93,7 @@ QgsRasterProjector::QgsRasterProjector(
, mDestRowsPerMatrixRow( 0.0 )
, mDestColsPerMatrixCol( 0.0 )
, pHelperTop( 0 ), pHelperBottom( 0 )
, mHelperTopRow( 0 )
, mCPCols( 0 )
, mCPRows( 0 )
, mSqrTolerance( 0.0 )
Expand Down
12 changes: 8 additions & 4 deletions src/plugins/spit/qgsshapefile.cpp
Expand Up @@ -42,9 +42,14 @@
#endif

QgsShapeFile::QgsShapeFile( QString name, QString encoding )
: ogrLayer( 0 )
, import_canceled( false )
, valid( false )
, isMulti( false )
, hasMoreDimensions( false )
, features( 0 )
, fileName( name )
{
fileName = name;
features = 0;
QgsApplication::registerOgrDrivers();

QSettings settings;
Expand All @@ -57,8 +62,7 @@ QgsShapeFile::QgsShapeFile( QString name, QString encoding )
ogrLayer = OGR_DS_GetLayer( ogrDataSource, 0 );
features = OGR_L_GetFeatureCount( ogrLayer, true );
}
else
valid = false;

setDefaultTable();
// init the geometry types
geometries << "NULL" << "POINT" << "LINESTRING" << "POLYGON" << "MULTIPOINT"
Expand Down
6 changes: 3 additions & 3 deletions src/providers/gpx/qgsgpxprovider.cpp
Expand Up @@ -69,10 +69,10 @@ const QString GPX_DESCRIPTION = QObject::tr( "GPS eXchange format provider" );

QgsGPXProvider::QgsGPXProvider( QString uri )
: QgsVectorDataProvider( uri )
, data( 0 )
, mFeatureType( WaypointType )
, mValid( false ) // assume that it won't work
{
// assume that it won't work
mValid = false;

// we always use UTF-8
mEncoding = QTextCodec::codecForName( "utf8" );

Expand Down
10 changes: 0 additions & 10 deletions src/providers/gpx/qgsgpxprovider.h
Expand Up @@ -165,16 +165,6 @@ class QgsGPXProvider : public QgsVectorDataProvider
static const int attrCount;

bool mValid;
long mNumberFeatures;

struct wkbPoint
{
char byteOrder;
unsigned wkbType;
double x;
double y;
};
wkbPoint mWKBpt;

friend class QgsGPXFeatureSource;
};
Expand Down
18 changes: 9 additions & 9 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -411,11 +411,18 @@ QgsSpatiaLiteProvider::createEmptyLayer(

QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
: QgsVectorDataProvider( uri )
, valid( false )
, isQuery( false )
, mTableBased( false )
, mViewBased( false )
, mVShapeBased( false )
, mReadOnly( false )
, geomType( QGis::WKBUnknown )
, sqliteHandle( NULL )
, mSrid( -1 )
, spatialIndexRTree( false )
, spatialIndexMbrCache( false )
, enabledCapabilities( 0 )
, mGotSpatialiteVersion( false )
, mSpatialiteVersionMajor( 0 )
, mSpatialiteVersionMinor( 0 )
Expand All @@ -433,11 +440,9 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )

// trying to open the SQLite DB
spatialite_init( 0 );
valid = true;
handle = QgsSqliteHandle::openDb( mSqlitePath );
if ( handle == NULL )
{
valid = false;
return;
}
sqliteHandle = handle->handle();
Expand Down Expand Up @@ -486,7 +491,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
{
// invalid metadata
numberFeatures = 0;
valid = false;

QgsDebugMsg( "Invalid SpatiaLite layer" );
closeDb();
Expand Down Expand Up @@ -514,7 +518,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
{
// the table is not a geometry table
numberFeatures = 0;
valid = false;
QgsDebugMsg( "Invalid SpatiaLite layer" );
closeDb();
gaiaFreeVectorLayersList( list );
Expand All @@ -523,7 +526,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
if ( !getTableSummaryAbstractInterface( lyr ) ) // gets the extent and feature count
{
numberFeatures = 0;
valid = false;
QgsDebugMsg( "Invalid SpatiaLite layer" );
closeDb();
gaiaFreeVectorLayersList( list );
Expand All @@ -543,15 +545,13 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
{
// the table is not a geometry table
numberFeatures = 0;
valid = false;
QgsDebugMsg( "Invalid SpatiaLite layer" );
closeDb();
return;
}
if ( !getTableSummary() ) // gets the extent and feature count
{
numberFeatures = 0;
valid = false;
QgsDebugMsg( "Invalid SpatiaLite layer" );
closeDb();
return;
Expand All @@ -561,7 +561,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
}
if ( sqliteHandle == NULL )
{
valid = false;
QgsDebugMsg( "Invalid SpatiaLite layer" );
return;
}
Expand All @@ -576,6 +575,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "FLOAT", QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "INTEGER", QVariant::LongLong )
;
valid = true;
}

QgsSpatiaLiteProvider::~QgsSpatiaLiteProvider()
Expand Down Expand Up @@ -4145,7 +4145,7 @@ bool QgsSpatiaLiteProvider::checkLayerType()

QString sql;

if ( mGeometryColumn.isEmpty() && !(mQuery.startsWith( "(" ) && mQuery.endsWith( ")" )) )
if ( mGeometryColumn.isEmpty() && !( mQuery.startsWith( "(" ) && mQuery.endsWith( ")" ) ) )
{
// checking if is a non-spatial table
sql = QString( "SELECT type FROM sqlite_master "
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsrasterlayer.cpp
Expand Up @@ -420,6 +420,7 @@ void TestQgsRasterLayer::checkScaleOffset()
mReport += QString( " %1 = %2 <br>\n" ).arg( myProvider->generateBandName( bandNo ) ).arg( valueString );
delete myRasterLayer;
QVERIFY( false );
return;
}
else
{
Expand All @@ -436,6 +437,7 @@ void TestQgsRasterLayer::checkScaleOffset()
{
delete myRasterLayer;
QVERIFY( false );
return;
}

mReport += "<p>Passed</p>";
Expand Down

0 comments on commit da092bf

Please sign in to comment.