From 2ec10bf62ddc54d8ebdf9828e6188eb715998d12 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 13 Apr 2023 15:33:06 +1000 Subject: [PATCH] Fix more cppcheck uninitialized member warnings --- .../processing/qgsalgorithmfuzzifyraster.h | 36 +++++++++---------- .../qgsalgorithmrandompointsinpolygons.h | 2 +- .../qgsalgorithmrandompointsonlines.h | 2 +- .../processing/qgsalgorithmrandomraster.h | 8 ++--- ...rithmrasterfrequencybycomparisonoperator.h | 12 +++---- .../qgsalgorithmrasterlayeruniquevalues.h | 8 ++--- .../processing/qgsalgorithmrasterlogicalop.h | 8 ++--- .../qgsalgorithmrasterstackposition.h | 10 +++--- .../qgsalgorithmrastersurfacevolume.h | 10 +++--- .../processing/qgsalgorithmrasterzonalstats.h | 8 ++--- .../processing/qgsalgorithmrescaleraster.h | 6 ++-- .../qgsalgorithmroundrastervalues.h | 18 +++++----- .../processing/qgsalgorithmzonalhistogram.h | 10 +++--- .../processing/qgsalgorithmzonalstatistics.h | 6 ++-- .../qgsalgorithmzonalstatisticsfeaturebased.h | 6 ++-- .../geometry_checker/qgsgeometrycheck.h | 4 +-- .../expression/qgspointcloudexpressionnode.h | 2 +- src/core/pointcloud/qgspointcloudattribute.h | 2 +- src/core/pointcloud/qgspointcloudindex.h | 9 +++-- src/core/providers/ogr/qgsogrproviderutils.h | 2 +- src/core/qgsbookmarkmanager.h | 2 +- 21 files changed, 88 insertions(+), 83 deletions(-) diff --git a/src/analysis/processing/qgsalgorithmfuzzifyraster.h b/src/analysis/processing/qgsalgorithmfuzzifyraster.h index c1056a594a6..32bc497fc2d 100644 --- a/src/analysis/processing/qgsalgorithmfuzzifyraster.h +++ b/src/analysis/processing/qgsalgorithmfuzzifyraster.h @@ -61,19 +61,19 @@ class QgsFuzzifyRasterAlgorithmBase : public QgsProcessingAlgorithm */ virtual void fuzzify( QgsProcessingFeedback *feedback ) = 0; - QgsRasterLayer *mInputRaster; - int mBand; + QgsRasterLayer *mInputRaster = nullptr; + int mBand = 1; std::unique_ptr< QgsRasterInterface > mInterface; QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; - int mLayerWidth; - int mLayerHeight; + int mLayerWidth = 0; + int mLayerHeight = 0; int mNbCellsXProvider = 0; int mNbCellsYProvider = 0; Qgis::DataType mDataType = Qgis::DataType::Float32; const double mNoDataValue = -9999; - QgsRasterDataProvider *mDestinationRasterProvider; + QgsRasterDataProvider *mDestinationRasterProvider = nullptr; }; @@ -98,8 +98,8 @@ class QgsFuzzifyRasterLinearMembershipAlgorithm : public QgsFuzzifyRasterAlgorit void fuzzify( QgsProcessingFeedback *feedback ) override; private: - double mFuzzifyLowBound; - double mFuzzifyHighBound; + double mFuzzifyLowBound = 0; + double mFuzzifyHighBound = 0; }; @@ -123,9 +123,9 @@ class QgsFuzzifyRasterPowerMembershipAlgorithm : public QgsFuzzifyRasterAlgorith void fuzzify( QgsProcessingFeedback *feedback ) override; private: - double mFuzzifyLowBound; - double mFuzzifyHighBound; - double mFuzzifyExponent; + double mFuzzifyLowBound = 0; + double mFuzzifyHighBound = 0; + double mFuzzifyExponent = 0; }; @@ -149,8 +149,8 @@ class QgsFuzzifyRasterLargeMembershipAlgorithm : public QgsFuzzifyRasterAlgorith void fuzzify( QgsProcessingFeedback *feedback ) override; private: - double mFuzzifyMidpoint; - double mFuzzifySpread; + double mFuzzifyMidpoint = 0; + double mFuzzifySpread = 0; }; @@ -174,8 +174,8 @@ class QgsFuzzifyRasterSmallMembershipAlgorithm : public QgsFuzzifyRasterAlgorith void fuzzify( QgsProcessingFeedback *feedback ) override; private: - double mFuzzifyMidpoint; - double mFuzzifySpread; + double mFuzzifyMidpoint = 0; + double mFuzzifySpread = 0; }; @@ -199,8 +199,8 @@ class QgsFuzzifyRasterGaussianMembershipAlgorithm : public QgsFuzzifyRasterAlgor void fuzzify( QgsProcessingFeedback *feedback ) override; private: - double mFuzzifyMidpoint; - double mFuzzifySpread; + double mFuzzifyMidpoint = 0; + double mFuzzifySpread = 0; }; @@ -224,8 +224,8 @@ class QgsFuzzifyRasterNearMembershipAlgorithm : public QgsFuzzifyRasterAlgorithm void fuzzify( QgsProcessingFeedback *feedback ) override; private: - double mFuzzifyMidpoint; - double mFuzzifySpread; + double mFuzzifyMidpoint = 0; + double mFuzzifySpread = 0; }; diff --git a/src/analysis/processing/qgsalgorithmrandompointsinpolygons.h b/src/analysis/processing/qgsalgorithmrandompointsinpolygons.h index 2f8532249ca..1d6f5e4b2d4 100644 --- a/src/analysis/processing/qgsalgorithmrandompointsinpolygons.h +++ b/src/analysis/processing/qgsalgorithmrandompointsinpolygons.h @@ -52,7 +52,7 @@ class QgsRandomPointsInPolygonsAlgorithm : public QgsProcessingAlgorithm QgsProcessingFeedback *feedback ) override; private: - int mNumPoints; + int mNumPoints = 0; bool mDynamicNumPoints = false; QgsProperty mNumPointsProperty; diff --git a/src/analysis/processing/qgsalgorithmrandompointsonlines.h b/src/analysis/processing/qgsalgorithmrandompointsonlines.h index 5978cb1be58..36d6d63b93a 100644 --- a/src/analysis/processing/qgsalgorithmrandompointsonlines.h +++ b/src/analysis/processing/qgsalgorithmrandompointsonlines.h @@ -54,7 +54,7 @@ class QgsRandomPointsOnLinesAlgorithm : public QgsProcessingAlgorithm private: - int mNumPoints; + int mNumPoints = 0; bool mDynamicNumPoints = false; QgsProperty mNumPointsProperty; diff --git a/src/analysis/processing/qgsalgorithmrandomraster.h b/src/analysis/processing/qgsalgorithmrandomraster.h index b9598f2fe78..c750d193bd8 100644 --- a/src/analysis/processing/qgsalgorithmrandomraster.h +++ b/src/analysis/processing/qgsalgorithmrandomraster.h @@ -64,8 +64,8 @@ class QgsRandomRasterAlgorithmBase : public QgsProcessingAlgorithm private: QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; - double mPixelSize; - Qgis::DataType mRasterDataType; + double mPixelSize = 0; + Qgis::DataType mRasterDataType = Qgis::DataType::UnknownDataType; }; @@ -89,8 +89,8 @@ class QgsRandomUniformRasterAlgorithm : public QgsRandomRasterAlgorithmBase double generateRandomDoubleValue( std::mt19937 &mersenneTwister ) final; private: - double mRandomUpperBound; - double mRandomLowerBound; + double mRandomUpperBound = 0; + double mRandomLowerBound = 0; std::uniform_int_distribution mRandomUniformIntDistribution; std::uniform_real_distribution mRandomUniformDoubleDistribution; }; diff --git a/src/analysis/processing/qgsalgorithmrasterfrequencybycomparisonoperator.h b/src/analysis/processing/qgsalgorithmrasterfrequencybycomparisonoperator.h index 01a6aa44276..baa86491cde 100644 --- a/src/analysis/processing/qgsalgorithmrasterfrequencybycomparisonoperator.h +++ b/src/analysis/processing/qgsalgorithmrasterfrequencybycomparisonoperator.h @@ -43,16 +43,16 @@ class QgsRasterFrequencyByComparisonOperatorBase : public QgsProcessingAlgorithm private: std::unique_ptr< QgsRasterInterface > mInputValueRasterInterface; - int mInputValueRasterBand; + int mInputValueRasterBand = 1; std::vector< QgsRasterAnalysisUtils::RasterLogicInput > mInputs; - bool mIgnoreNoData; + bool mIgnoreNoData = false; double mNoDataValue = -9999; - int mLayerWidth; - int mLayerHeight; + int mLayerWidth = 0; + int mLayerHeight = 0; QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; - double mRasterUnitsPerPixelX; - double mRasterUnitsPerPixelY; + double mRasterUnitsPerPixelX = 0; + double mRasterUnitsPerPixelY = 0; }; class QgsRasterFrequencyByEqualOperatorAlgorithm : public QgsRasterFrequencyByComparisonOperatorBase diff --git a/src/analysis/processing/qgsalgorithmrasterlayeruniquevalues.h b/src/analysis/processing/qgsalgorithmrasterlayeruniquevalues.h index aa779e9f3ec..8030c019c06 100644 --- a/src/analysis/processing/qgsalgorithmrasterlayeruniquevalues.h +++ b/src/analysis/processing/qgsalgorithmrasterlayeruniquevalues.h @@ -54,12 +54,12 @@ class QgsRasterLayerUniqueValuesReportAlgorithm : public QgsProcessingAlgorithm std::unique_ptr< QgsRasterInterface > mInterface; bool mHasNoDataValue = false; int mBand = 1; - int mLayerWidth; - int mLayerHeight; + int mLayerWidth = 0; + int mLayerHeight = 0; QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; - double mRasterUnitsPerPixelX; - double mRasterUnitsPerPixelY; + double mRasterUnitsPerPixelX = 0; + double mRasterUnitsPerPixelY = 0; QString mSource; }; diff --git a/src/analysis/processing/qgsalgorithmrasterlogicalop.h b/src/analysis/processing/qgsalgorithmrasterlogicalop.h index a4a317ce652..fe74eb0df7e 100644 --- a/src/analysis/processing/qgsalgorithmrasterlogicalop.h +++ b/src/analysis/processing/qgsalgorithmrasterlogicalop.h @@ -55,12 +55,12 @@ class ANALYSIS_EXPORT QgsRasterBooleanLogicAlgorithmBase : public QgsProcessingA std::vector< QgsRasterAnalysisUtils::RasterLogicInput > mInputs; Qgis::DataType mDataType = Qgis::DataType::Float32; double mNoDataValue = -9999; - int mLayerWidth; - int mLayerHeight; + int mLayerWidth = 0; + int mLayerHeight = 0; QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; - double mRasterUnitsPerPixelX; - double mRasterUnitsPerPixelY; + double mRasterUnitsPerPixelX = 0; + double mRasterUnitsPerPixelY = 0; bool mTreatNodataAsFalse = false; friend class TestQgsProcessingAlgsPt1; }; diff --git a/src/analysis/processing/qgsalgorithmrasterstackposition.h b/src/analysis/processing/qgsalgorithmrasterstackposition.h index 8a44faf0209..1df58afd3c7 100644 --- a/src/analysis/processing/qgsalgorithmrasterstackposition.h +++ b/src/analysis/processing/qgsalgorithmrasterstackposition.h @@ -44,13 +44,13 @@ class QgsRasterStackPositionAlgorithmBase : public QgsProcessingAlgorithm private: std::vector< QgsRasterAnalysisUtils::RasterLogicInput > mInputs; - bool mIgnoreNoData; - int mLayerWidth; - int mLayerHeight; + bool mIgnoreNoData = false; + int mLayerWidth = 0; + int mLayerHeight = 0; QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; - double mRasterUnitsPerPixelX; - double mRasterUnitsPerPixelY; + double mRasterUnitsPerPixelX = 0; + double mRasterUnitsPerPixelY = 0; }; class QgsRasterStackLowestPositionAlgorithm : public QgsRasterStackPositionAlgorithmBase diff --git a/src/analysis/processing/qgsalgorithmrastersurfacevolume.h b/src/analysis/processing/qgsalgorithmrastersurfacevolume.h index 43366a07bb5..c34618662ed 100644 --- a/src/analysis/processing/qgsalgorithmrastersurfacevolume.h +++ b/src/analysis/processing/qgsalgorithmrastersurfacevolume.h @@ -63,15 +63,15 @@ class QgsRasterSurfaceVolumeAlgorithm : public QgsProcessingAlgorithm std::unique_ptr< QgsRasterInterface > mInterface; bool mHasNoDataValue = false; int mBand = 1; - int mLayerWidth; - int mLayerHeight; + int mLayerWidth = 0; + int mLayerHeight = 0; QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; - double mRasterUnitsPerPixelX; - double mRasterUnitsPerPixelY; + double mRasterUnitsPerPixelX = 0; + double mRasterUnitsPerPixelY = 0; double mLevel = 0; QString mSource; - Method mMethod; + Method mMethod = Method::CountOnlyAboveBaseLevel; }; diff --git a/src/analysis/processing/qgsalgorithmrasterzonalstats.h b/src/analysis/processing/qgsalgorithmrasterzonalstats.h index 094d841b029..2e6e1c46ad4 100644 --- a/src/analysis/processing/qgsalgorithmrasterzonalstats.h +++ b/src/analysis/processing/qgsalgorithmrasterzonalstats.h @@ -69,12 +69,12 @@ class QgsRasterLayerZonalStatsAlgorithm : public QgsProcessingAlgorithm bool mZonesHasNoDataValue = false; int mBand = 1; int mZonesBand = 1; - int mLayerWidth; - int mLayerHeight; + int mLayerWidth = 0; + int mLayerHeight = 0; QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; - double mRasterUnitsPerPixelX; - double mRasterUnitsPerPixelY; + double mRasterUnitsPerPixelX = 0; + double mRasterUnitsPerPixelY = 0; RefLayer mRefLayer = Source; }; diff --git a/src/analysis/processing/qgsalgorithmrescaleraster.h b/src/analysis/processing/qgsalgorithmrescaleraster.h index a82ef37ad2b..3fd4ae0a78f 100644 --- a/src/analysis/processing/qgsalgorithmrescaleraster.h +++ b/src/analysis/processing/qgsalgorithmrescaleraster.h @@ -57,9 +57,9 @@ class QgsRescaleRasterAlgorithm : public QgsProcessingAlgorithm int mLayerHeight = 0; int mXSize = 0; int mYSize = 0; - double mNoData; - double mMinimum; - double mMaximum; + double mNoData = 0; + double mMinimum = 0; + double mMaximum = 0; QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; diff --git a/src/analysis/processing/qgsalgorithmroundrastervalues.h b/src/analysis/processing/qgsalgorithmroundrastervalues.h index 8511628eb57..3feae92004c 100644 --- a/src/analysis/processing/qgsalgorithmroundrastervalues.h +++ b/src/analysis/processing/qgsalgorithmroundrastervalues.h @@ -64,20 +64,20 @@ class QgsRoundRasterValuesAlgorithm : public QgsProcessingAlgorithm int mDecimalPrecision = 2; int mBaseN = 10; - double mScaleFactor; - int mMultipleOfBaseN; - int mBand; - int mRoundingDirection; + double mScaleFactor = 0; + int mMultipleOfBaseN = 0; + int mBand = 1; + int mRoundingDirection = 0; std::unique_ptr< QgsRasterInterface > mInterface; - Qgis::DataType mDataType; - bool mIsInteger; + Qgis::DataType mDataType = Qgis::DataType::UnknownDataType; + bool mIsInteger = false; QgsRectangle mExtent; QgsCoordinateReferenceSystem mCrs; - int mLayerWidth; - int mLayerHeight; + int mLayerWidth = 0; + int mLayerHeight = 0; int mNbCellsXProvider = 0; int mNbCellsYProvider = 0; - double mInputNoDataValue; + double mInputNoDataValue = 0; }; ///@endcond PRIVATE diff --git a/src/analysis/processing/qgsalgorithmzonalhistogram.h b/src/analysis/processing/qgsalgorithmzonalhistogram.h index 20f0a7d5963..0aa4b15e02d 100644 --- a/src/analysis/processing/qgsalgorithmzonalhistogram.h +++ b/src/analysis/processing/qgsalgorithmzonalhistogram.h @@ -52,15 +52,15 @@ class QgsZonalHistogramAlgorithm : public QgsProcessingAlgorithm private: std::unique_ptr< QgsRasterInterface > mRasterInterface; - int mRasterBand; + int mRasterBand = 1; bool mHasNoDataValue = false; float mNodataValue = -1; QgsRectangle mRasterExtent; QgsCoordinateReferenceSystem mCrs; - double mCellSizeX; - double mCellSizeY; - double mNbCellsXProvider; - double mNbCellsYProvider; + double mCellSizeX = 0; + double mCellSizeY = 0; + double mNbCellsXProvider = 0; + double mNbCellsYProvider = 0; }; diff --git a/src/analysis/processing/qgsalgorithmzonalstatistics.h b/src/analysis/processing/qgsalgorithmzonalstatistics.h index 610a11ed8fe..a5d1ce8be16 100644 --- a/src/analysis/processing/qgsalgorithmzonalstatistics.h +++ b/src/analysis/processing/qgsalgorithmzonalstatistics.h @@ -54,12 +54,12 @@ class QgsZonalStatisticsAlgorithm : public QgsProcessingAlgorithm private: std::unique_ptr< QgsRasterInterface > mInterface; - int mBand; + int mBand = 1; QString mPrefix; QgsZonalStatistics::Statistics mStats = QgsZonalStatistics::All; QgsCoordinateReferenceSystem mCrs; - double mPixelSizeX; - double mPixelSizeY; + double mPixelSizeX = 0; + double mPixelSizeY = 0; }; ///@endcond PRIVATE diff --git a/src/analysis/processing/qgsalgorithmzonalstatisticsfeaturebased.h b/src/analysis/processing/qgsalgorithmzonalstatisticsfeaturebased.h index 7338b5bc520..8b37a1d38f9 100644 --- a/src/analysis/processing/qgsalgorithmzonalstatisticsfeaturebased.h +++ b/src/analysis/processing/qgsalgorithmzonalstatisticsfeaturebased.h @@ -58,14 +58,14 @@ class QgsZonalStatisticsFeatureBasedAlgorithm : public QgsProcessingFeatureBased private: std::unique_ptr< QgsRasterInterface > mRaster; - int mBand; + int mBand = 1; QString mPrefix; QgsZonalStatistics::Statistics mStats = QgsZonalStatistics::All; QgsCoordinateReferenceSystem mCrs; bool mCreatedTransform = false; QgsCoordinateTransform mFeatureToRasterTransform; - double mPixelSizeX; - double mPixelSizeY; + double mPixelSizeX = 0; + double mPixelSizeY = 0; QgsFields mOutputFields; QMap mStatFieldsMapping; }; diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheck.h b/src/analysis/vector/geometry_checker/qgsgeometrycheck.h index ae28ce4844e..8c9e975825d 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrycheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrycheck.h @@ -189,12 +189,12 @@ class ANALYSIS_EXPORT QgsGeometryCheck /** * What level this change affects. */ - QgsGeometryCheck::ChangeWhat what; + QgsGeometryCheck::ChangeWhat what = QgsGeometryCheck::ChangeWhat::ChangeFeature; /** * What action this change performs. */ - QgsGeometryCheck::ChangeType type; + QgsGeometryCheck::ChangeType type = QgsGeometryCheck::ChangeType::ChangeAdded; /** * The index of the part / ring / vertex, depending on \see what. diff --git a/src/core/pointcloud/expression/qgspointcloudexpressionnode.h b/src/core/pointcloud/expression/qgspointcloudexpressionnode.h index d1fddcd9c59..0b2df3753ba 100644 --- a/src/core/pointcloud/expression/qgspointcloudexpressionnode.h +++ b/src/core/pointcloud/expression/qgspointcloudexpressionnode.h @@ -235,7 +235,7 @@ class CORE_EXPORT QgsPointCloudExpressionNode /** * Contains the static, precalculated value for the node if mHasCachedValue is TRUE. */ - mutable double mCachedStaticValue; + mutable double mCachedStaticValue = 0; private: diff --git a/src/core/pointcloud/qgspointcloudattribute.h b/src/core/pointcloud/qgspointcloudattribute.h index 0b11ee89663..bd38152052d 100644 --- a/src/core/pointcloud/qgspointcloudattribute.h +++ b/src/core/pointcloud/qgspointcloudattribute.h @@ -128,7 +128,7 @@ class CORE_EXPORT QgsPointCloudAttribute QString mName; int mSize = 0; - DataType mType; + DataType mType = DataType::Char; }; /** diff --git a/src/core/pointcloud/qgspointcloudindex.h b/src/core/pointcloud/qgspointcloudindex.h index 3f560ff5c17..c217033f4bb 100644 --- a/src/core/pointcloud/qgspointcloudindex.h +++ b/src/core/pointcloud/qgspointcloudindex.h @@ -148,7 +148,12 @@ class CORE_EXPORT QgsPointCloudDataBounds QgsDoubleRange zRange( const QgsVector3D &offset, const QgsVector3D &scale ) const; private: - qint32 mXMin, mYMin, mZMin, mXMax, mYMax, mZMax; + qint32 mXMin = 0; + qint32 mYMin = 0; + qint32 mZMin = 0; + qint32 mXMax = 0; + qint32 mYMax = 0; + qint32 mZMax = 0; }; /** @@ -341,7 +346,7 @@ class CORE_EXPORT QgsPointCloudIndex: public QObject QgsVector3D mOffset; //!< Offset of our int32 coordinates compared to CRS coords QgsPointCloudDataBounds mRootBounds; //!< Bounds of the root node's cube (in int32 coordinates) QgsPointCloudAttributeCollection mAttributes; //! All native attributes stored in the file - int mSpan; //!< Number of points in one direction in a single node + int mSpan = 0; //!< Number of points in one direction in a single node QgsPointCloudExpression mFilterExpression; //!< The filter expression to be evaluated when fetching node data QString mError; diff --git a/src/core/providers/ogr/qgsogrproviderutils.h b/src/core/providers/ogr/qgsogrproviderutils.h index bd603886198..fa71b5fa2a1 100644 --- a/src/core/providers/ogr/qgsogrproviderutils.h +++ b/src/core/providers/ogr/qgsogrproviderutils.h @@ -285,7 +285,7 @@ class QgsOgrDataset friend class QgsOgrProviderUtils; friend class QgsOgrTransaction; QgsOgrProviderUtils::DatasetIdentification mIdent; - QgsOgrProviderUtils::DatasetWithLayers *mDs; + QgsOgrProviderUtils::DatasetWithLayers *mDs = nullptr; QgsOgrDataset() = default; ~QgsOgrDataset() = default; diff --git a/src/core/qgsbookmarkmanager.h b/src/core/qgsbookmarkmanager.h index 5b547645d8b..8d711a80edc 100644 --- a/src/core/qgsbookmarkmanager.h +++ b/src/core/qgsbookmarkmanager.h @@ -143,7 +143,7 @@ class CORE_EXPORT QgsBookmark QString mName; QString mGroup; QgsReferencedRectangle mExtent; - double mRotation; + double mRotation = 0; };