Skip to content

Commit

Permalink
Fix more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 21, 2015
1 parent 483ef3c commit 013d6d3
Show file tree
Hide file tree
Showing 68 changed files with 377 additions and 386 deletions.
10 changes: 2 additions & 8 deletions src/analysis/CMakeLists.txt
Expand Up @@ -62,16 +62,10 @@ ADD_FLEX_FILES_PREFIX(QGIS_ANALYSIS_SRCS raster raster/qgsrastercalclexer.ll)

ADD_BISON_FILES_PREFIX(QGIS_ANALYSIS_SRCS raster raster/qgsrastercalcparser.yy)

IF (PEDANTIC AND MSVC)
# disable warnings
# 4065 switch with default and no case
# 4127 conditional expression is constant
# 4702 unreachable code
SET_SOURCE_FILES_PROPERTIES(
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_BINARY_DIR}/src/analysis/qgsrastercalcparser.cpp
PROPERTIES COMPILE_FLAGS "-wd4065 -wd4127 -wd4702"
PROPERTIES COMPILE_FLAGS "-w"
)
ENDIF (PEDANTIC AND MSVC)

IF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET_SOURCE_FILES_PROPERTIES(
Expand Down
4 changes: 2 additions & 2 deletions src/app/CMakeLists.txt
Expand Up @@ -529,11 +529,11 @@ IF(ENABLE_MODELTEST)
ENDIF(ENABLE_MODELTEST)

IF (ANDROID)
INCLUDE_DIRECTORIES(${ANDROID_NDK_TOOLCHAIN_ROOT}/sysroot/usr/include)
INCLUDE_DIRECTORIES(SYSTEM ${ANDROID_NDK_TOOLCHAIN_ROOT}/sysroot/usr/include)
ENDIF (ANDROID)

IF (POSTGRES_FOUND)
INCLUDE_DIRECTORIES(${POSTGRES_INCLUDE_DIR})
INCLUDE_DIRECTORIES(SYSTEM ${POSTGRES_INCLUDE_DIR})
ENDIF (POSTGRES_FOUND)

#############
Expand Down
2 changes: 0 additions & 2 deletions src/app/pluginmanager/qgspluginsortfilterproxymodel.cpp
Expand Up @@ -88,14 +88,12 @@ bool QgsPluginSortFilterProxyModel::filterByPhrase( QModelIndex &index ) const
case PLUGIN_TAGS_ROLE:
// search in tags only
return sourceModel()->data( index, PLUGIN_TAGS_ROLE ).toString().contains( filterRegExp() );
break;
case 0:
// full search: name + description + tags + author
return sourceModel()->data( index, PLUGIN_DESCRIPTION_ROLE ).toString().contains( filterRegExp() )
|| sourceModel()->data( index, PLUGIN_AUTHOR_ROLE ).toString().contains( filterRegExp() )
|| sourceModel()->data( index, Qt::DisplayRole ).toString().contains( filterRegExp() )
|| sourceModel()->data( index, PLUGIN_TAGS_ROLE ).toString().contains( filterRegExp() );
break;
default:
// unknown filter mode, return nothing
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsfieldcalculator.h
Expand Up @@ -62,7 +62,7 @@ class APP_EXPORT QgsFieldCalculator: public QDialog, private Ui::QgsFieldCalcula
inline QgsField fieldDefinition()
{
return QgsField( mOutputFieldNameLineEdit->text(),
( QVariant::Type ) mOutputFieldTypeComboBox->itemData( mOutputFieldTypeComboBox->currentIndex(), Qt::UserRole ).toInt(),
static_cast< QVariant::Type >( mOutputFieldTypeComboBox->itemData( mOutputFieldTypeComboBox->currentIndex(), Qt::UserRole ).toInt() ),
mOutputFieldTypeComboBox->itemData( mOutputFieldTypeComboBox->currentIndex(), Qt::UserRole + 1 ).toString(),
mOutputFieldWidthSpinBox->value(),
mOutputFieldPrecisionSpinBox->value() );
Expand Down
3 changes: 0 additions & 3 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -732,7 +732,6 @@ void QgsVectorLayerProperties::loadDefaultStyle_clicked()
{
case 0:
return;
break;
case 2:
msg = layer->loadNamedStyle( layer->styleURI(), defaultLoadedFlag );
if ( !defaultLoadedFlag )
Expand All @@ -751,7 +750,6 @@ void QgsVectorLayerProperties::loadDefaultStyle_clicked()
}

return;
break;
default:
break;
}
Expand Down Expand Up @@ -789,7 +787,6 @@ void QgsVectorLayerProperties::saveDefaultStyle_clicked()
{
case 0:
return;
break;
case 2:
layer->saveStyleToDatabase( "", "", true, "", errorMsg );
if ( errorMsg.isNull() )
Expand Down
2 changes: 2 additions & 0 deletions src/astyle/CMakeLists.txt
@@ -1,3 +1,5 @@
SET(ASTYLE_SRCS astyle_main.cpp ASBeautifier.cpp ASFormatter.cpp ASEnhancer.cpp ASResource.cpp)
# No warnings for astyle build
SET_SOURCE_FILES_PROPERTIES( ${ASTYLE_SRCS} PROPERTIES COMPILE_FLAGS -w )
ADD_EXECUTABLE(qgisstyle ${ASTYLE_SRCS})
SET_TARGET_PROPERTIES(qgisstyle PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/scripts)
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -406,6 +406,8 @@ ADD_FLEX_FILES(QGIS_CORE_SRCS qgsexpressionlexer.ll)

ADD_BISON_FILES(QGIS_CORE_SRCS qgsexpressionparser.yy)

SET_SOURCE_FILES_PROPERTIES( qgsexpressionparser.cpp PROPERTIES COMPILE_FLAGS -w )

SET(QGIS_CORE_MOC_HDRS
qgsapplication.h
qgsbrowsermodel.h
Expand Down
12 changes: 6 additions & 6 deletions src/core/auth/qgsauthconfig.cpp
Expand Up @@ -405,16 +405,16 @@ const QString QgsAuthConfigSslServer::configString() const
QStringList configlist;
configlist << QString::number( mVersion ) << QString::number( mQtVersion );

configlist << QString::number(( int )mSslProtocol );
configlist << QString::number( static_cast< int >( mSslProtocol ) );

QStringList errs;
Q_FOREACH ( const QSslError::SslError& err, mSslIgnoredErrors )
{
errs << QString::number(( int )err );
errs << QString::number( static_cast< int >( err ) );
}
configlist << errs.join( "~~" );

configlist << QString( "%1~~%2" ).arg(( int )mSslPeerVerifyMode ).arg( mSslPeerVerifyDepth );
configlist << QString( "%1~~%2" ).arg( static_cast< int >( mSslPeerVerifyMode ) ).arg( mSslPeerVerifyDepth );

return configlist.join( mConfSep );
}
Expand All @@ -432,17 +432,17 @@ void QgsAuthConfigSslServer::loadConfigString( const QString &config )

// TODO: Conversion between 4.7 -> 4.8 protocol enum differences (and reverse?).
// This is necessary for users upgrading from 4.7 to 4.8
mSslProtocol = ( QSsl::SslProtocol )configlist.at( 2 ).toInt();
mSslProtocol = static_cast< QSsl::SslProtocol >( configlist.at( 2 ).toInt() );

mSslIgnoredErrors.clear();
QStringList errs( configlist.at( 3 ).split( "~~" ) );
Q_FOREACH ( const QString& err, errs )
{
mSslIgnoredErrors.append(( QSslError::SslError )err.toInt() );
mSslIgnoredErrors.append( static_cast< QSslError::SslError >( err.toInt() ) );
}

QStringList peerverify( configlist.at( 4 ).split( "~~" ) );
mSslPeerVerifyMode = ( QSslSocket::PeerVerifyMode )peerverify.at( 0 ).toInt();
mSslPeerVerifyMode = static_cast< QSslSocket::PeerVerifyMode >( peerverify.at( 0 ).toInt() );
mSslPeerVerifyDepth = peerverify.at( 1 ).toInt();
}

Expand Down
1 change: 0 additions & 1 deletion src/core/auth/qgsauthcrypto.cpp
Expand Up @@ -28,7 +28,6 @@
#define CIPHER_IV_LENGTH 32
#define CIPHER_PROVIDER "qca-ossl"
#define PASSWORD_HASH_ALGORITHM "sha256"
#define RANDOM_KEY_LENGTH 16
#define KEY_GEN_ITERATIONS 10000
#define KEY_GEN_LENGTH 16
#define KEY_GEN_IV_LENGTH 16
Expand Down
12 changes: 6 additions & 6 deletions src/core/auth/qgsauthmanager.cpp
Expand Up @@ -774,7 +774,7 @@ const QString QgsAuthManager::uniqueConfigId() const
QTimer::singleShot( 3, &loop, SLOT( quit() ) );
loop.exec();

uint seed = ( uint ) QTime::currentTime().msec();
uint seed = static_cast< uint >( QTime::currentTime().msec() );
qsrand( seed );

while ( true )
Expand Down Expand Up @@ -2463,7 +2463,7 @@ bool QgsAuthManager::storeCertTrustPolicy( const QSslCertificate &cert, QgsAuthC
"VALUES (:id, :policy)" ).arg( authDbTrustTable() ) );

query.bindValue( ":id", id );
query.bindValue( ":policy", ( int )policy );
query.bindValue( ":policy", static_cast< int >( policy ) );

if ( !authDbStartTransaction() )
return false;
Expand Down Expand Up @@ -2502,7 +2502,7 @@ QgsAuthCertUtils::CertTrustPolicy QgsAuthManager::getCertTrustPolicy( const QSsl
{
if ( query.first() )
{
policy = ( QgsAuthCertUtils::CertTrustPolicy )query.value( 0 ).toInt();
policy = static_cast< QgsAuthCertUtils::CertTrustPolicy >( query.value( 0 ).toInt() );
QgsDebugMsg( QString( "Authentication cert trust policy retrieved for id: %1" ).arg( id ) );
}
if ( query.next() )
Expand Down Expand Up @@ -2591,7 +2591,7 @@ bool QgsAuthManager::setDefaultCertTrustPolicy( QgsAuthCertUtils::CertTrustPolic
// set default trust policy to Trusted by removing setting
return removeAuthSetting( "certdefaulttrust" );
}
return storeAuthSetting( "certdefaulttrust", ( int )policy );
return storeAuthSetting( "certdefaulttrust", static_cast< int >( policy ) );
}

QgsAuthCertUtils::CertTrustPolicy QgsAuthManager::defaultCertTrustPolicy()
Expand All @@ -2601,7 +2601,7 @@ QgsAuthCertUtils::CertTrustPolicy QgsAuthManager::defaultCertTrustPolicy()
{
return QgsAuthCertUtils::Trusted;
}
return ( QgsAuthCertUtils::CertTrustPolicy )policy.toInt();
return static_cast< QgsAuthCertUtils::CertTrustPolicy >( policy.toInt() );
}

bool QgsAuthManager::rebuildCertTrustCache()
Expand All @@ -2622,7 +2622,7 @@ bool QgsAuthManager::rebuildCertTrustCache()
while ( query.next() )
{
QString id = query.value( 0 ).toString();
QgsAuthCertUtils::CertTrustPolicy policy = ( QgsAuthCertUtils::CertTrustPolicy )query.value( 1 ).toInt();
QgsAuthCertUtils::CertTrustPolicy policy = static_cast< QgsAuthCertUtils::CertTrustPolicy >( query.value( 1 ).toInt() );

QStringList ids;
if ( mCertTrustCache.contains( policy ) )
Expand Down
12 changes: 6 additions & 6 deletions src/core/auth/qgsauthmethodregistry.cpp
Expand Up @@ -107,7 +107,7 @@ QgsAuthMethodRegistry::QgsAuthMethodRegistry( const QString& pluginPath )
}

// get the description and the key for the auth method plugin
isauthmethod_t *isAuthMethod = ( isauthmethod_t * ) cast_to_fptr( myLib.resolve( "isAuthMethod" ) );
isauthmethod_t *isAuthMethod = reinterpret_cast< isauthmethod_t * >( cast_to_fptr( myLib.resolve( "isAuthMethod" ) ) );
if ( !isAuthMethod )
{
QgsDebugMsg( QString( "Checking %1: ...invalid (no isAuthMethod method)" ).arg( myLib.fileName() ) );
Expand All @@ -122,14 +122,14 @@ QgsAuthMethodRegistry::QgsAuthMethodRegistry( const QString& pluginPath )
}

// looks like an auth method plugin. get the key and description
description_t *pDesc = ( description_t * ) cast_to_fptr( myLib.resolve( "description" ) );
description_t *pDesc = reinterpret_cast< description_t * >( cast_to_fptr( myLib.resolve( "description" ) ) );
if ( !pDesc )
{
QgsDebugMsg( QString( "Checking %1: ...invalid (no description method)" ).arg( myLib.fileName() ) );
continue;
}

methodkey_t *pKey = ( methodkey_t * ) cast_to_fptr( myLib.resolve( "authMethodKey" ) );
methodkey_t *pKey = reinterpret_cast< methodkey_t * >( cast_to_fptr( myLib.resolve( "authMethodKey" ) ) );
if ( !pKey )
{
QgsDebugMsg( QString( "Checking %1: ...invalid (no authMethodKey method)" ).arg( myLib.fileName() ) );
Expand All @@ -156,7 +156,7 @@ QgsAuthMethodRegistry::~QgsAuthMethodRegistry()
QLibrary myLib( lib );
if ( myLib.isLoaded() )
{
cleanupAuthMethod_t* cleanupFunc = ( cleanupAuthMethod_t* ) cast_to_fptr( myLib.resolve( "cleanupAuthMethod" ) );
cleanupAuthMethod_t* cleanupFunc = reinterpret_cast< cleanupAuthMethod_t* >( cast_to_fptr( myLib.resolve( "cleanupAuthMethod" ) ) );
if ( cleanupFunc )
cleanupFunc();
}
Expand Down Expand Up @@ -292,7 +292,7 @@ QgsAuthMethod *QgsAuthMethodRegistry::authMethod( const QString &authMethodKey )
return nullptr;
}

classFactoryFunction_t *classFactory = ( classFactoryFunction_t * ) cast_to_fptr( myLib.resolve( "classFactory" ) );
classFactoryFunction_t *classFactory = reinterpret_cast< classFactoryFunction_t * >( cast_to_fptr( myLib.resolve( "classFactory" ) ) );
if ( !classFactory )
{
QgsDebugMsg( QString( "Failed to load %1: no classFactory method" ).arg( lib ) );
Expand All @@ -316,7 +316,7 @@ typedef QWidget * editFactoryFunction_t( QWidget * parent );
QWidget *QgsAuthMethodRegistry::editWidget( const QString &authMethodKey, QWidget *parent )
{
editFactoryFunction_t * editFactory =
( editFactoryFunction_t * ) cast_to_fptr( function( authMethodKey, "editWidget" ) );
reinterpret_cast< editFactoryFunction_t * >( cast_to_fptr( function( authMethodKey, "editWidget" ) ) );

if ( !editFactory )
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/core/diagram/qgshistogramdiagram.cpp
Expand Up @@ -43,7 +43,7 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsFeature& feature, const QgsRen
return size; //zero size if no attributes
}

if ( is.upperValue - is.lowerValue == 0 )
if ( qgsDoubleNear( is.upperValue, is.lowerValue ) )
return size; // invalid value range => zero size

double maxValue = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/core/diagram/qgspiediagram.cpp
Expand Up @@ -90,7 +90,7 @@ QSizeF QgsPieDiagram::diagramSize( const QgsFeature& feature, const QgsRenderCon
if ( size.width() <= s.minimumSize && size.height() <= s.minimumSize )
{
bool p = false; // preserve height == width
if ( size.width() == size.height() )
if ( qgsDoubleNear( size.width(), size.height() ) )
p = true;

size.scale( s.minimumSize, s.minimumSize, Qt::KeepAspectRatio );
Expand Down
12 changes: 6 additions & 6 deletions src/core/effects/qgsblureffect.cpp
Expand Up @@ -86,18 +86,18 @@ QgsStringMap QgsBlurEffect::properties() const
{
QgsStringMap props;
props.insert( "enabled", mEnabled ? "1" : "0" );
props.insert( "draw_mode", QString::number( int( mDrawMode ) ) );
props.insert( "blend_mode", QString::number( int( mBlendMode ) ) );
props.insert( "draw_mode", QString::number( static_cast< int >( mDrawMode ) ) );
props.insert( "blend_mode", QString::number( static_cast< int >( mBlendMode ) ) );
props.insert( "transparency", QString::number( mTransparency ) );
props.insert( "blur_level", QString::number( mBlurLevel ) );
props.insert( "blur_method", QString::number(( int )mBlurMethod ) );
props.insert( "blur_method", QString::number( static_cast< int >( mBlurMethod ) ) );
return props;
}

void QgsBlurEffect::readProperties( const QgsStringMap &props )
{
bool ok;
QPainter::CompositionMode mode = ( QPainter::CompositionMode )props.value( "blend_mode" ).toInt( &ok );
QPainter::CompositionMode mode = static_cast< QPainter::CompositionMode >( props.value( "blend_mode" ).toInt( &ok ) );
if ( ok )
{
mBlendMode = mode;
Expand All @@ -108,13 +108,13 @@ void QgsBlurEffect::readProperties( const QgsStringMap &props )
mTransparency = transparency;
}
mEnabled = props.value( "enabled", "1" ).toInt();
mDrawMode = ( QgsPaintEffect::DrawMode )props.value( "draw_mode", "2" ).toInt();
mDrawMode = static_cast< QgsPaintEffect::DrawMode >( props.value( "draw_mode", "2" ).toInt() );
int level = props.value( "blur_level" ).toInt( &ok );
if ( ok )
{
mBlurLevel = level;
}
QgsBlurEffect::BlurMethod method = ( QgsBlurEffect::BlurMethod )props.value( "blur_method" ).toInt( &ok );
QgsBlurEffect::BlurMethod method = static_cast< QgsBlurEffect::BlurMethod >( props.value( "blur_method" ).toInt( &ok ) );
if ( ok )
{
mBlurMethod = method;
Expand Down
8 changes: 4 additions & 4 deletions src/core/effects/qgscoloreffect.cpp
Expand Up @@ -59,7 +59,7 @@ void QgsColorEffect::draw( QgsRenderContext &context )
QgsImageOperation::adjustBrightnessContrast( image, mBrightness, mContrast / 100.0 + 1 );
if ( mGrayscaleMode != QgsImageOperation::GrayscaleOff )
{
QgsImageOperation::convertToGrayscale( image, ( QgsImageOperation::GrayscaleMode ) mGrayscaleMode );
QgsImageOperation::convertToGrayscale( image, static_cast< QgsImageOperation::GrayscaleMode >( mGrayscaleMode ) );
}
QgsImageOperation::adjustHueSaturation( image, mSaturation, mColorizeOn ? mColorizeColor : QColor(), mColorizeStrength / 100.0 );

Expand Down Expand Up @@ -92,7 +92,7 @@ QgsStringMap QgsColorEffect::properties() const
void QgsColorEffect::readProperties( const QgsStringMap &props )
{
bool ok;
QPainter::CompositionMode mode = ( QPainter::CompositionMode )props.value( "blend_mode" ).toInt( &ok );
QPainter::CompositionMode mode = static_cast< QPainter::CompositionMode >( props.value( "blend_mode" ).toInt( &ok ) );
if ( ok )
{
mBlendMode = mode;
Expand All @@ -103,12 +103,12 @@ void QgsColorEffect::readProperties( const QgsStringMap &props )
mTransparency = transparency;
}
mEnabled = props.value( "enabled", "1" ).toInt();
mDrawMode = ( QgsPaintEffect::DrawMode )props.value( "draw_mode", "2" ).toInt();
mDrawMode = static_cast< QgsPaintEffect::DrawMode >( props.value( "draw_mode", "2" ).toInt() );

mBrightness = props.value( "brightness", "0" ).toInt();
mContrast = props.value( "contrast", "0" ).toInt();
mSaturation = props.value( "saturation", "1.0" ).toDouble();
mGrayscaleMode = ( QgsImageOperation::GrayscaleMode )props.value( "grayscale_mode", "0" ).toInt();
mGrayscaleMode = static_cast< QgsImageOperation::GrayscaleMode >( props.value( "grayscale_mode", "0" ).toInt() );
mColorizeOn = props.value( "colorize", "0" ).toInt();
if ( props.contains( "colorize_color" ) )
{
Expand Down
8 changes: 4 additions & 4 deletions src/core/effects/qgsgloweffect.cpp
Expand Up @@ -125,7 +125,7 @@ QgsStringMap QgsGlowEffect::properties() const
props.insert( "spread", QString::number( mSpread ) );
props.insert( "spread_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mSpreadUnit ) );
props.insert( "spread_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mSpreadMapUnitScale ) );
props.insert( "color_type", QString::number(( int )mColorType ) );
props.insert( "color_type", QString::number( static_cast< int >( mColorType ) ) );
props.insert( "single_color", QgsSymbolLayerV2Utils::encodeColor( mColor ) );

if ( mRamp )
Expand All @@ -139,7 +139,7 @@ QgsStringMap QgsGlowEffect::properties() const
void QgsGlowEffect::readProperties( const QgsStringMap &props )
{
bool ok;
QPainter::CompositionMode mode = ( QPainter::CompositionMode )props.value( "blend_mode" ).toInt( &ok );
QPainter::CompositionMode mode = static_cast< QPainter::CompositionMode >( props.value( "blend_mode" ).toInt( &ok ) );
if ( ok )
{
mBlendMode = mode;
Expand All @@ -150,7 +150,7 @@ void QgsGlowEffect::readProperties( const QgsStringMap &props )
mTransparency = transparency;
}
mEnabled = props.value( "enabled", "1" ).toInt();
mDrawMode = ( QgsPaintEffect::DrawMode )props.value( "draw_mode", "2" ).toInt();
mDrawMode = static_cast< QgsPaintEffect::DrawMode >( props.value( "draw_mode", "2" ).toInt() );
int level = props.value( "blur_level" ).toInt( &ok );
if ( ok )
{
Expand All @@ -163,7 +163,7 @@ void QgsGlowEffect::readProperties( const QgsStringMap &props )
}
mSpreadUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( props.value( "spread_unit" ) );
mSpreadMapUnitScale = QgsSymbolLayerV2Utils::decodeMapUnitScale( props.value( "spread_unit_scale" ) );
QgsGlowEffect::GlowColorType type = ( QgsGlowEffect::GlowColorType )props.value( "color_type" ).toInt( &ok );
QgsGlowEffect::GlowColorType type = static_cast< QgsGlowEffect::GlowColorType >( props.value( "color_type" ).toInt( &ok ) );
if ( ok )
{
mColorType = type;
Expand Down

0 comments on commit 013d6d3

Please sign in to comment.