Skip to content

Commit

Permalink
Fix some warnings when building with clang and -Weverything
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 20, 2015
1 parent 80de178 commit ec35dbe
Show file tree
Hide file tree
Showing 60 changed files with 214 additions and 282 deletions.
2 changes: 1 addition & 1 deletion src/analysis/interpolation/DualEdgeTriangulation.h
Expand Up @@ -220,7 +220,7 @@ inline DualEdgeTriangulation::DualEdgeTriangulation( int nop, Triangulation* dec

inline int DualEdgeTriangulation::getNumberOfPoints() const
{
return (( int )( mPointVector.count() ) );
return mPointVector.count();
}

inline Point3D* DualEdgeTriangulation::getPoint( unsigned int i ) const
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposeritemcommand.h
Expand Up @@ -137,7 +137,7 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
~QgsComposerMergeCommand();

bool mergeWith( const QUndoCommand * command ) override;
int id() const override { return ( int )mContext; }
int id() const override { return static_cast< int >( mContext ); }

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Dec 20, 2015

Member

Wouldn't it be better to return the return type instead?

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Dec 20, 2015

Author Collaborator

@m-kuhn sorry, I don't understand. The return type here is int?

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Dec 20, 2015

Member

s/return/change/

Context id() const override;

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Dec 20, 2015

Author Collaborator

Ahh... It's overriding a qt method returning int though.

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Dec 20, 2015

Member

Ah, I see. Thanks for all the cleanup anyway, really like to see such commits.


private:
Context mContext;
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposermultiframecommand.h
Expand Up @@ -81,7 +81,7 @@ class CORE_EXPORT QgsComposerMultiFrameMergeCommand: public QgsComposerMultiFram
~QgsComposerMultiFrameMergeCommand();

bool mergeWith( const QUndoCommand * command ) override;
int id() const override { return ( int )mContext; }
int id() const override { return static_cast< int >( mContext ); }

private:
Context mContext;
Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfexport.h
Expand Up @@ -117,7 +117,7 @@ class CORE_EXPORT QgsDxfExport
* @param layerTitleAsName flag
* @see addLayers
*/
void setLayerTitleAsName( bool layerTitleAsName ) { mLayerTitleAsName = layerTitleAsName; };
void setLayerTitleAsName( bool layerTitleAsName ) { mLayerTitleAsName = layerTitleAsName; }

/**
* Retrieve wether layer title (where set) instead of name shall be use
Expand Down
6 changes: 3 additions & 3 deletions src/core/effects/qgsimageoperation.h
Expand Up @@ -219,7 +219,7 @@ class CORE_EXPORT QgsImageOperation
{
for ( unsigned int y = block.beginLine; y < block.endLine; ++y )
{
QRgb* ref = ( QRgb* )block.image->scanLine( y );
QRgb* ref = reinterpret_cast< QRgb* >( block.image->scanLine( y ) );
for ( unsigned int x = 0; x < block.lineLength; ++x )
{
mOperation( ref[x], x, y );
Expand Down Expand Up @@ -249,7 +249,7 @@ class CORE_EXPORT QgsImageOperation
{
for ( unsigned int y = block.beginLine; y < block.endLine; ++y )
{
QRgb* ref = ( QRgb* )block.image->scanLine( y );
QRgb* ref = reinterpret_cast< QRgb* >( block.image->scanLine( y ) );
mOperation( ref, block.lineLength, bpl );
}
}
Expand All @@ -259,7 +259,7 @@ class CORE_EXPORT QgsImageOperation
unsigned char* ref = block.image->scanLine( 0 ) + 4 * block.beginLine;
for ( unsigned int x = block.beginLine; x < block.endLine; ++x, ref += 4 )
{
mOperation(( QRgb* )ref, block.lineLength, bpl );
mOperation( reinterpret_cast< QRgb* >( ref ), block.lineLength, bpl );
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/core/geometry/qgsgeometry.cpp
Expand Up @@ -317,7 +317,7 @@ QGis::WkbType QgsGeometry::wkbType() const
}
else
{
return ( QGis::WkbType )d->geometry->wkbType();
return static_cast< QGis::WkbType >( d->geometry->wkbType() );
}
}

Expand All @@ -328,7 +328,7 @@ QGis::GeometryType QgsGeometry::type() const
{
return QGis::UnknownGeometry;
}
return ( QGis::GeometryType )( QgsWKBTypes::geometryType( d->geometry->wkbType() ) );
return static_cast< QGis::GeometryType >( QgsWKBTypes::geometryType( d->geometry->wkbType() ) );
}

bool QgsGeometry::isMultipart() const
Expand Down Expand Up @@ -1917,7 +1917,6 @@ QgsGeometry* QgsGeometry::smooth( const unsigned int iterations, const double of
}
return QgsGeometry::fromMultiPolygon( resultMultipoly );
}
break;

case QGis::WKBUnknown:
default:
Expand Down Expand Up @@ -2303,7 +2302,7 @@ QgsGeometryEngine* QgsGeometry::createGeometryEngine( const QgsAbstractGeometryV

QDataStream& operator<<( QDataStream& out, const QgsGeometry& geometry )
{
QByteArray byteArray = QByteArray::fromRawData(( char * )geometry.asWkb(), geometry.wkbSize() ); // does not copy data and does not take ownership
QByteArray byteArray = QByteArray::fromRawData( reinterpret_cast< const char * >( geometry.asWkb() ), geometry.wkbSize() ); // does not copy data and does not take ownership
out << byteArray;
return out;
}
Expand All @@ -2320,6 +2319,6 @@ QDataStream& operator>>( QDataStream& in, QgsGeometry& geometry )

char *data = new char[byteArray.size()];
memcpy( data, byteArray.data(), byteArray.size() );
geometry.fromWkb(( unsigned char* )data, byteArray.size() );
geometry.fromWkb( reinterpret_cast< unsigned char* >( data ), byteArray.size() );
return in;
}
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometryutils.cpp
Expand Up @@ -149,7 +149,7 @@ bool QgsGeometryUtils::lineIntersection( const QgsPointV2& p1, const QgsVector&
{
double d = v.y() * w.x() - v.x() * w.y();

if ( d == 0 )
if ( qgsDoubleNear( d, 0 ) )
return false;

double dx = q1.x() - p1.x();
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgswkbptr.cpp
Expand Up @@ -2,7 +2,7 @@

QgsConstWkbPtr::QgsConstWkbPtr( const unsigned char *p ): mEndianSwap( false )
{
mP = ( unsigned char * ) p;
mP = const_cast< unsigned char * >( p );
}

QgsWKBTypes::Type QgsConstWkbPtr::readHeader() const
Expand Down
10 changes: 5 additions & 5 deletions src/core/geometry/qgswkbtypes.cpp
Expand Up @@ -68,7 +68,7 @@ QgsWKBTypes::Type QgsWKBTypes::flatType( Type type )
QgsWKBTypes::Type QgsWKBTypes::parseType( const QString &wktStr )
{
QString typestr = wktStr.left( wktStr.indexOf( '(' ) ).simplified().remove( ' ' );
Q_FOREACH ( const Type& type, entries()->keys() )
Q_FOREACH ( Type type, entries()->keys() )
{
QMap< Type, wkbEntry >::const_iterator it = entries()->constFind( type );
if ( it != entries()->constEnd() && it.value().mName.compare( typestr, Qt::CaseInsensitive ) == 0 )
Expand Down Expand Up @@ -185,9 +185,9 @@ QgsWKBTypes::Type QgsWKBTypes::addZ( QgsWKBTypes::Type type )
//upgrade with z dimension
Type flat = flatType( type );
if ( hasM( type ) )
return ( QgsWKBTypes::Type )( flat + 3000 );
return static_cast< QgsWKBTypes::Type >( flat + 3000 );
else
return ( QgsWKBTypes::Type )( flat + 1000 );
return static_cast< QgsWKBTypes::Type >( flat + 1000 );
}

QgsWKBTypes::Type QgsWKBTypes::addM( QgsWKBTypes::Type type )
Expand All @@ -209,9 +209,9 @@ QgsWKBTypes::Type QgsWKBTypes::addM( QgsWKBTypes::Type type )
//upgrade with m dimension
Type flat = flatType( type );
if ( hasZ( type ) )
return ( QgsWKBTypes::Type )( flat + 3000 );
return static_cast< QgsWKBTypes::Type >( flat + 3000 );
else
return ( QgsWKBTypes::Type )( flat + 2000 );
return static_cast< QgsWKBTypes::Type >( flat + 2000 );
}

QgsWKBTypes::Type QgsWKBTypes::dropZ( QgsWKBTypes::Type type )
Expand Down
2 changes: 1 addition & 1 deletion src/core/gps/qgsgpsdconnection.cpp
Expand Up @@ -46,7 +46,7 @@ void QgsGpsdConnection::connected()

void QgsGpsdConnection::error( QAbstractSocket::SocketError socketError )
{
#if QGISDEBUG
#ifdef QGISDEBUG
QTcpSocket *socket = qobject_cast< QTcpSocket * >( mSource );
QgsDebugMsg( QString( "error: %1 %2" ).arg( socketError ).arg( socket->errorString() ) );
#else
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/feature.cpp
Expand Up @@ -30,7 +30,7 @@
#define _CRT_SECURE_NO_DEPRECATE


#if defined(_VERBOSE_) || (_DEBUG_)
#if defined(_VERBOSE_) || defined(_DEBUG_)
#include <iostream>
#endif

Expand Down
2 changes: 0 additions & 2 deletions src/core/pal/layer.cpp
Expand Up @@ -27,8 +27,6 @@
*
*/

#define _CRT_SECURE_NO_DEPRECATE

#include "pal.h"
#include "layer.h"
#include "palexception.h"
Expand Down
20 changes: 9 additions & 11 deletions src/core/pal/pal.cpp
Expand Up @@ -29,8 +29,6 @@

//#define _VERBOSE_

#define _CRT_SECURE_NO_DEPRECATE

#include "qgsgeometry.h"
#include "pal.h"
#include "layer.h"
Expand Down Expand Up @@ -151,7 +149,7 @@ namespace pal
bool extractFeatCallback( FeaturePart *ft_ptr, void *ctx )
{
double amin[2], amax[2];
FeatCallBackCtx *context = ( FeatCallBackCtx* ) ctx;
FeatCallBackCtx *context = reinterpret_cast< FeatCallBackCtx* >( ctx );

// Holes of the feature are obstacles
for ( int i = 0; i < ft_ptr->getNumSelfObstacles(); i++ )
Expand Down Expand Up @@ -200,7 +198,7 @@ namespace pal
bool extractObstaclesCallback( FeaturePart *ft_ptr, void *ctx )
{
double amin[2], amax[2];
ObstacleCallBackCtx *context = ( ObstacleCallBackCtx* ) ctx;
ObstacleCallBackCtx *context = reinterpret_cast< ObstacleCallBackCtx* >( ctx );

// insert into obstacles
ft_ptr->getBoundingBox( amin, amax );
Expand All @@ -218,8 +216,8 @@ namespace pal
bool filteringCallback( FeaturePart *featurePart, void *ctx )
{

RTree<LabelPosition*, double, 2, double> *cdtsIndex = (( FilterContext* ) ctx )->cdtsIndex;
Pal* pal = (( FilterContext* )ctx )->pal;
RTree<LabelPosition*, double, 2, double> *cdtsIndex = ( reinterpret_cast< FilterContext* >( ctx ) )->cdtsIndex;
Pal* pal = ( reinterpret_cast< FilterContext* >( ctx ) )->pal;

if ( pal->isCancelled() )
return false; // do not continue searching
Expand All @@ -230,7 +228,7 @@ namespace pal
LabelPosition::PruneCtx pruneContext;
pruneContext.obstacle = featurePart;
pruneContext.pal = pal;
cdtsIndex->Search( amin, amax, LabelPosition::pruneCallback, ( void* ) &pruneContext );
cdtsIndex->Search( amin, amax, LabelPosition::pruneCallback, static_cast< void* >( &pruneContext ) );

return true;
}
Expand Down Expand Up @@ -306,9 +304,9 @@ namespace pal

// find features within bounding box and generate candidates list
context.layer = layer;
layer->mFeatureIndex->Search( amin, amax, extractFeatCallback, ( void* ) &context );
layer->mFeatureIndex->Search( amin, amax, extractFeatCallback, static_cast< void* >( &context ) );
// find obstacles within bounding box
layer->mObstacleIndex->Search( amin, amax, extractObstaclesCallback, ( void* ) &obstacleContext );
layer->mObstacleIndex->Search( amin, amax, extractObstaclesCallback, static_cast< void* >( &obstacleContext ) );

layer->mMutex.unlock();

Expand Down Expand Up @@ -353,7 +351,7 @@ namespace pal
FilterContext filterCtx;
filterCtx.cdtsIndex = prob->candidates;
filterCtx.pal = this;
obstacles->Search( amin, amax, filteringCallback, ( void* ) &filterCtx );
obstacles->Search( amin, amax, filteringCallback, static_cast< void* >( &filterCtx ) );

if ( isCancelled() )
{
Expand Down Expand Up @@ -450,7 +448,7 @@ namespace pal
lp->getBoundingBox( amin, amax );

// lookup for overlapping candidate
prob->candidates->Search( amin, amax, LabelPosition::countOverlapCallback, ( void* ) lp );
prob->candidates->Search( amin, amax, LabelPosition::countOverlapCallback, static_cast< void* >( lp ) );

nbOverlaps += lp->getNumOverlaps();
}
Expand Down
7 changes: 1 addition & 6 deletions src/core/pal/pointset.cpp
Expand Up @@ -27,10 +27,7 @@
*
*/

#ifndef POINT_SET_H
#define POINT_SET_H

#if defined(_VERBOSE_) || (_DEBUG_) || (_DEBUG_FULL_)
#if defined(_VERBOSE_) || defined(_DEBUG_) || defined(_DEBUG_FULL_)
#include <iostream>
#endif

Expand Down Expand Up @@ -1054,5 +1051,3 @@ namespace pal


} // end namespace

#endif
6 changes: 2 additions & 4 deletions src/core/pal/problem.cpp
Expand Up @@ -27,8 +27,6 @@
*
*/

#define _CRT_SECURE_NO_DEPRECATE

#include "pal.h"
#include "palstat.h"
#include "layer.h"
Expand Down Expand Up @@ -453,7 +451,7 @@ namespace pal

SubPart *current = nullptr;

#if _VERBOSE_
#ifdef _VERBOSE_
int subPartTotalSize = 0;
#endif

Expand All @@ -472,7 +470,7 @@ namespace pal
for ( i = 0; i < nbft; i++ )
{
parts[i] = subPart( r, i, isIn );
#if _VERBOSE_
#ifdef _VERBOSE_
subPartTotalSize += parts[i]->subSize;
#endif
ok[i] = false;
Expand Down

1 comment on commit ec35dbe

@m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented on ec35dbe Dec 20, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Please sign in to comment.