Skip to content
Permalink
Browse files

Ensure all pointer variables are initialized to nullptr

  • Loading branch information
nyalldawson committed Feb 18, 2017
1 parent 54339e3 commit d19e70700fa13ea60462e7fa06947bdf74709256
Showing 859 changed files with 2,756 additions and 2,752 deletions.
@@ -28,14 +28,18 @@
# Also fix doxygen comments
s#^(\s*)/\*[*!]\s*([^\s*].*)\s*$#$1/** \u$2\n#;

# Convert single line doxygent blocks:
# Convert single line doxygen blocks:
# /*!< comment */ to //!< comment
# /** comment */ to //! comment
s#\/\*[!\*](?!\*)(<*)\h*(.*?)\h*\*\/\h*$#//!$1 $2#;

# Uppercase initial character in //!< comment
s#\/\/!<\s*(.)(.*)#//!< \u$1$2#;

# Ensure that pointer members are always initialized to nullptr
# We don't run this check by default, there's a high likelihood of false positives...
# s#^(\s*(?!typedef|return|delete)(?:\s*(?:const)\s*)?[a-zA-Z0-9_:]+\s*\*+\s*[a-zA-Z0-9_]+)\s*;\s*$#$1 = nullptr;\n#;

if( /^\s*#include/ ) {
push @inc, $_ unless exists $inc{$_};
$inc{$_}=1;
@@ -29,7 +29,7 @@ class ANALYSIS_EXPORT CloughTocherInterpolator : public TriangleInterpolator
{
protected:
//! Association with a triangulation object
NormVecDecorator* mTIN;
NormVecDecorator* mTIN = nullptr;
//! Tolerance of the barycentric coordinates at the borders of the triangles (to prevent errors because of very small negativ baricentric coordinates)
double mEdgeTolerance;
//! First point of the triangle in x-,y-,z-coordinates
@@ -2968,9 +2968,9 @@ bool DualEdgeTriangulation::swapEdge( double x, double y )
if ( edge1 >= 0 )
{
int edge2, edge3;
Point3D* point1;
Point3D* point2;
Point3D* point3;
Point3D* point1 = nullptr;
Point3D* point2 = nullptr;
Point3D* point3 = nullptr;
edge2 = mHalfEdge[edge1]->getNext();
edge3 = mHalfEdge[edge2]->getNext();
point1 = getPoint( mHalfEdge[edge1]->getPoint() );
@@ -3030,9 +3030,9 @@ QList<int>* DualEdgeTriangulation::getPointsAroundEdge( double x, double y )
if ( edge1 >= 0 )
{
int edge2, edge3;
Point3D* point1;
Point3D* point2;
Point3D* point3;
Point3D* point1 = nullptr;
Point3D* point2 = nullptr;
Point3D* point3 = nullptr;
edge2 = mHalfEdge[edge1]->getNext();
edge3 = mHalfEdge[edge2]->getNext();
point1 = getPoint( mHalfEdge[edge1]->getPoint() );
@@ -122,7 +122,7 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
//! Stores pointers to the HalfEdges
QVector<HalfEdge*> mHalfEdge;
//! Association to an interpolator object
TriangleInterpolator* mTriangleInterpolator;
TriangleInterpolator* mTriangleInterpolator = nullptr;
//! Member to store the behavior in case of crossing forced segments
Triangulation::ForcedCrossBehavior mForcedCrossBehavior;
//! Color to paint the normal edges
@@ -132,7 +132,7 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
//! Color to paint the breaklines
QColor mBreakEdgeColor;
//! Pointer to the decorator using this triangulation. It it is used directly, mDecorator equals this
Triangulation* mDecorator;
Triangulation* mDecorator = nullptr;
//! Inserts an edge and makes sure, everything is ok with the storage of the edge. The number of the HalfEdge is returned
unsigned int insertEdge( int dual, int next, int point, bool mbreak, bool forced );
//! Inserts a forced segment between the points with the numbers p1 and p2 into the triangulation and returns the number of a HalfEdge belonging to this forced edge or -100 in case of failure
@@ -42,7 +42,7 @@ class ANALYSIS_EXPORT LinTriangleInterpolator : public TriangleInterpolator


protected:
DualEdgeTriangulation* mTIN;
DualEdgeTriangulation* mTIN = nullptr;
//! Calculates the first derivative with respect to x for a linear surface and assigns it to vec
virtual bool calcFirstDerX( double x, double y, Vector3D* result );
//! Calculates the first derivative with respect to y for a linear surface and assigns it to vec
@@ -30,9 +30,9 @@ class ANALYSIS_EXPORT Line3D
//! Assignment operator, declared private to not use it
Line3D& operator=( const Line3D& );
protected:
Node* head;
Node* z;
Node* currentNode;
Node* head = nullptr;
Node* z = nullptr;
Node* currentNode = nullptr;
unsigned int size;
unsigned int current;

@@ -26,9 +26,9 @@ class ANALYSIS_EXPORT Node
{
protected:
//! Pointer to the Point3D object associated with the node
Point3D* mPoint;
Point3D* mPoint = nullptr;
//! Pointer to the next Node in the linked list
Node* mNext;
Node* mNext = nullptr;
public:
Node();
Node( const Node& n );
@@ -74,7 +74,7 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
bool alreadyestimated;
static const unsigned int DEFAULT_STORAGE_FOR_NORMALS = 100000;
//! Association with an interpolator object
TriangleInterpolator* mInterpolator;
TriangleInterpolator* mInterpolator = nullptr;
//! Vector that stores the normals for the points. If 'estimateFirstDerivatives()' was called and there is a null pointer, this means, that the triangle point is on a breakline
QVector<Vector3D*>* mNormVec;
//! Vector who stores, it a point is not on a breakline, if it is a normal point of the breakline or if it is an endpoint of a breakline
@@ -32,7 +32,7 @@ class ANALYSIS_EXPORT ParametricLine
//! Degree of the parametric Line
int mDegree;
//! Pointer to the parent object. If there isn't one, mParent is 0
ParametricLine* mParent;
ParametricLine* mParent = nullptr;
//! MControlPoly stores the points of the control polygon
QVector<Point3D*>* mControlPoly;
public:
@@ -58,7 +58,7 @@ class ANALYSIS_EXPORT TriDecorator : public Triangulation
virtual QList<int>* getPointsAroundEdge( double x, double y ) override;
protected:
//! Association with a Triangulation object
Triangulation* mTIN;
Triangulation* mTIN = nullptr;
};

inline TriDecorator::TriDecorator(): mTIN( nullptr )
@@ -44,7 +44,7 @@ class ANALYSIS_EXPORT QgsGridFileWriter
QgsGridFileWriter(); //forbidden
int writeHeader( QTextStream& outStream );

QgsInterpolator* mInterpolator;
QgsInterpolator* mInterpolator = nullptr;
QString mOutputFilePath;
QgsRectangle mInterpolationExtent;
int mNumColumns;
@@ -49,7 +49,7 @@ class ANALYSIS_EXPORT QgsInterpolator
//! A layer together with the information about interpolation attribute / z-coordinate interpolation and the type (point, structure line, breakline)
struct LayerData
{
QgsVectorLayer* vectorLayer;
QgsVectorLayer* vectorLayer = nullptr;
bool zCoordInterpolation;
int interpolationAttribute;
InputType mInputType;
@@ -51,8 +51,8 @@ class ANALYSIS_EXPORT QgsTINInterpolator: public QgsInterpolator
void setTriangulationFilePath( const QString& filepath ) {mTriangulationFilePath = filepath;}

private:
Triangulation* mTriangulation;
TriangleInterpolator* mTriangleInterpolator;
Triangulation* mTriangulation = nullptr;
TriangleInterpolator* mTriangleInterpolator = nullptr;
bool mIsInitialized;
bool mShowProgressDialog;
//! If true: export triangulation to shapefile after initialization
@@ -56,7 +56,7 @@ class ANALYSIS_EXPORT QgsGraphBuilder : public QgsGraphBuilderInterface

private:

QgsGraph *mGraph;
QgsGraph *mGraph = nullptr;
};

#endif // QGSGRAPHBUILDER_H
@@ -77,7 +77,7 @@ class ANALYSIS_EXPORT QgsVectorLayerDirector : public QgsGraphDirector
QString name() const override;

private:
QgsVectorLayer *mVectorLayer;
QgsVectorLayer *mVectorLayer = nullptr;
int mDirectionFieldId;
QString mDirectDirectionValue;
QString mReverseDirectionValue;
@@ -98,7 +98,7 @@ bool QgsOSMDatabase::close()

int QgsOSMDatabase::runCountStatement( const char* sql ) const
{
sqlite3_stmt* stmt;
sqlite3_stmt* stmt = nullptr;
int res = sqlite3_prepare_v2( mDatabase, sql, -1, &stmt, nullptr );
if ( res != SQLITE_OK )
return -1;
@@ -182,7 +182,7 @@ QList<QgsOSMTagCountPair> QgsOSMDatabase::usedTags( bool ways ) const

QString sql = QStringLiteral( "SELECT k, count(k) FROM %1_tags GROUP BY k" ).arg( ways ? "ways" : "nodes" );

sqlite3_stmt* stmt;
sqlite3_stmt* stmt = nullptr;
if ( sqlite3_prepare_v2( mDatabase, sql.toUtf8().data(), -1, &stmt, nullptr ) != SQLITE_OK )
return pairs;

@@ -384,7 +384,7 @@ void QgsOSMDatabase::exportSpatiaLiteNodes( const QString& tableName, const QStr
for ( int i = 0; i < tagKeys.count(); ++i )
sqlInsertPoint += QStringLiteral( ",?" );
sqlInsertPoint += QLatin1String( ", GeomFromWKB(?, 4326))" );
sqlite3_stmt* stmtInsert;
sqlite3_stmt* stmtInsert = nullptr;
if ( sqlite3_prepare_v2( mDatabase, sqlInsertPoint.toUtf8().constData(), -1, &stmtInsert, nullptr ) != SQLITE_OK )
{
mError = QStringLiteral( "Prepare SELECT FROM nodes failed." );
@@ -451,7 +451,7 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
for ( int i = 0; i < tagKeys.count(); ++i )
sqlInsertLine += QStringLiteral( ",?" );
sqlInsertLine += QLatin1String( ", GeomFromWKB(?, 4326))" );
sqlite3_stmt* stmtInsert;
sqlite3_stmt* stmtInsert = nullptr;
if ( sqlite3_prepare_v2( mDatabase, sqlInsertLine.toUtf8().constData(), -1, &stmtInsert, nullptr ) != SQLITE_OK )
{
mError = QStringLiteral( "Prepare SELECT FROM ways failed." );
@@ -117,14 +117,14 @@ class ANALYSIS_EXPORT QgsOSMDatabase
QString mError;

//! pointer to sqlite3 database that keeps OSM data
sqlite3* mDatabase;
sqlite3* mDatabase = nullptr;

sqlite3_stmt* mStmtNode;
sqlite3_stmt* mStmtNodeTags;
sqlite3_stmt* mStmtWay;
sqlite3_stmt* mStmtWayNode;
sqlite3_stmt* mStmtWayNodePoints;
sqlite3_stmt* mStmtWayTags;
sqlite3_stmt* mStmtNode = nullptr;
sqlite3_stmt* mStmtNodeTags = nullptr;
sqlite3_stmt* mStmtWay = nullptr;
sqlite3_stmt* mStmtWayNode = nullptr;
sqlite3_stmt* mStmtWayNodePoints = nullptr;
sqlite3_stmt* mStmtWayTags = nullptr;

};

@@ -147,7 +147,7 @@ class ANALYSIS_EXPORT QgsOSMNodeIterator // clazy:exclude=rule-of-three
*/
QgsOSMNodeIterator( sqlite3* handle );

sqlite3_stmt* mStmt;
sqlite3_stmt* mStmt = nullptr;

friend class QgsOSMDatabase;

@@ -173,7 +173,7 @@ class ANALYSIS_EXPORT QgsOSMWayIterator // clazy:exclude=rule-of-three
*/
QgsOSMWayIterator( sqlite3* handle );

sqlite3_stmt* mStmt;
sqlite3_stmt* mStmt = nullptr;

friend class QgsOSMDatabase;

@@ -96,7 +96,7 @@ class ANALYSIS_EXPORT QgsOSMDownload : public QObject
QString mQuery;
QString mError;

QNetworkReply* mReply;
QNetworkReply* mReply = nullptr;
QFile mFile;
};

@@ -131,7 +131,7 @@ bool QgsOSMXmlImport::createIndexes()

bool QgsOSMXmlImport::createDatabase()
{
char **results;
char **results = nullptr;
int rows, columns;
if ( QgsSLConnect::sqlite3_open_v2( mDbFileName.toUtf8().data(), &mDatabase, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr ) != SQLITE_OK )
return false;
@@ -165,7 +165,7 @@ bool QgsOSMXmlImport::createDatabase()
int initCount = sizeof( sqlInitStatements ) / sizeof( const char* );
for ( int i = 0; i < initCount; ++i )
{
char* errMsg;
char* errMsg = nullptr;
if ( sqlite3_exec( mDatabase, sqlInitStatements[i], nullptr, nullptr, &errMsg ) != SQLITE_OK )
{
mError = QStringLiteral( "Error executing SQL command:\n%1\nSQL:\n%2" )
@@ -89,12 +89,12 @@ class ANALYSIS_EXPORT QgsOSMXmlImport : public QObject

QFile mInputFile;

sqlite3* mDatabase;
sqlite3_stmt* mStmtInsertNode;
sqlite3_stmt* mStmtInsertNodeTag;
sqlite3_stmt* mStmtInsertWay;
sqlite3_stmt* mStmtInsertWayNode;
sqlite3_stmt* mStmtInsertWayTag;
sqlite3* mDatabase = nullptr;
sqlite3_stmt* mStmtInsertNode = nullptr;
sqlite3_stmt* mStmtInsertNodeTag = nullptr;
sqlite3_stmt* mStmtInsertWay = nullptr;
sqlite3_stmt* mStmtInsertWayNode = nullptr;
sqlite3_stmt* mStmtInsertWayTag = nullptr;
};


@@ -238,7 +238,7 @@ class ANALYSIS_EXPORT QgsAlignRaster
// set by the client

//! Object that facilitates reporting of progress / cancelation
ProgressHandler* mProgressHandler;
ProgressHandler* mProgressHandler = nullptr;

//! Last error message from run()
QString mErrorMessage;
@@ -71,7 +71,7 @@ class ANALYSIS_EXPORT QgsKernelDensityEstimation
struct Parameters
{
//! Vector point layer
QgsVectorLayer* vectorLayer;
QgsVectorLayer* vectorLayer = nullptr;

//! Fixed radius, in map units
double radius;
@@ -146,7 +146,7 @@ class ANALYSIS_EXPORT QgsKernelDensityEstimation

QgsRectangle calculateBounds() const;

QgsVectorLayer* mInputLayer;
QgsVectorLayer* mInputLayer = nullptr;

QString mOutputFile;
QString mOutputFormat;
@@ -230,7 +230,7 @@ GDALDatasetH QgsNineCellFilter::openInputFile( int& nCellsX, int& nCellsY )

GDALDriverH QgsNineCellFilter::openOutputDriver()
{
char **driverMetadata;
char **driverMetadata = nullptr;

//open driver
GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() );
@@ -102,11 +102,11 @@ class ANALYSIS_EXPORT QgsRasterCalcNode

private:
Type mType;
QgsRasterCalcNode* mLeft;
QgsRasterCalcNode* mRight;
QgsRasterCalcNode* mLeft = nullptr;
QgsRasterCalcNode* mRight = nullptr;
double mNumber;
QString mRasterName;
QgsRasterMatrix* mMatrix;
QgsRasterMatrix* mMatrix = nullptr;
Operator mOperator;

};
@@ -188,7 +188,7 @@ QgsRasterCalculator::QgsRasterCalculator()

GDALDriverH QgsRasterCalculator::openOutputDriver()
{
char **driverMetadata;
char **driverMetadata = nullptr;

//open driver
GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() );
@@ -115,7 +115,7 @@ class ANALYSIS_EXPORT QgsRasterMatrix
private:
int mColumns;
int mRows;
double* mData;
double* mData = nullptr;
double mNodataValue;

//! +,-,*,/,^,<,>,<=,>=,=,!=, and, or
@@ -427,7 +427,7 @@ GDALDatasetH QgsRelief::openInputFile( int& nCellsX, int& nCellsY )

GDALDriverH QgsRelief::openOutputDriver()
{
char **driverMetadata;
char **driverMetadata = nullptr;

//open driver
GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() );
@@ -86,11 +86,11 @@ class ANALYSIS_EXPORT QgsRelief

double mZFactor;

QgsSlopeFilter* mSlopeFilter;
QgsAspectFilter* mAspectFilter;
QgsHillshadeFilter* mHillshadeFilter285;
QgsHillshadeFilter* mHillshadeFilter300;
QgsHillshadeFilter* mHillshadeFilter315;
QgsSlopeFilter* mSlopeFilter = nullptr;
QgsAspectFilter* mAspectFilter = nullptr;
QgsHillshadeFilter* mHillshadeFilter285 = nullptr;
QgsHillshadeFilter* mHillshadeFilter300 = nullptr;
QgsHillshadeFilter* mHillshadeFilter315 = nullptr;

//relief colors and corresponding elevations
QList< ReliefColor > mReliefColors;

0 comments on commit d19e707

Please sign in to comment.
You can’t perform that action at this time.