Skip to content
Permalink
Browse files

Fix coverity unreachable code error

  • Loading branch information
nyalldawson committed Sep 28, 2015
1 parent 808a432 commit 7c036194faddb5bbe6be26b2bd5709b2f715ab0d
Showing with 14 additions and 17 deletions.
  1. +14 −17 src/core/auth/qgsauthmanager.cpp
@@ -3006,6 +3006,13 @@ bool QgsAuthManager::reencryptAuthenticationConfig( const QString &authcfg, cons
{
QString configstring( QgsAuthCrypto::decrypt( prevpass, prevciv, query.value( 0 ).toString() ) );

if ( query.next() )
{
QgsDebugMsg( QString( "Select contains more than one for authcfg: %1" ).arg( authcfg ) );
emit messageOut( tr( "Authentication database contains duplicate configuration IDs" ), authManTag(), WARNING );
return false;
}

query.clear();

query.prepare( QString( "UPDATE %1 "
@@ -3032,14 +3039,6 @@ bool QgsAuthManager::reencryptAuthenticationConfig( const QString &authcfg, cons
QgsDebugMsg( QString( "Reencrypt FAILED, could not find in db authcfg: %2" ).arg( authcfg ) );
return false;
}

if ( query.next() )
{
QgsDebugMsg( QString( "Select contains more than one for authcfg: %1" ).arg( authcfg ) );
emit messageOut( tr( "Authentication database contains duplicate configuration IDs" ), authManTag(), WARNING );
}

return false;
}

bool QgsAuthManager::reencryptAllAuthenticationSettings( const QString &prevpass, const QString &prevciv )
@@ -3169,6 +3168,13 @@ bool QgsAuthManager::reencryptAuthenticationIdentity(
{
QString keystring( QgsAuthCrypto::decrypt( prevpass, prevciv, query.value( 0 ).toString() ) );

if ( query.next() )
{
QgsDebugMsg( QString( "Select contains more than one for identity id: %1" ).arg( identid ) );
emit messageOut( tr( "Authentication database contains duplicate identity IDs" ), authManTag(), WARNING );
return false;
}

query.clear();

query.prepare( QString( "UPDATE %1 "
@@ -3195,15 +3201,6 @@ bool QgsAuthManager::reencryptAuthenticationIdentity(
QgsDebugMsg( QString( "Reencrypt FAILED, could not find in db identity id: %2" ).arg( identid ) );
return false;
}

if ( query.next() )
{
QgsDebugMsg( QString( "Select contains more than one for identity id: %1" ).arg( identid ) );
emit messageOut( tr( "Authentication database contains duplicate identity IDs" ), authManTag(), WARNING );
}

return false;

}

bool QgsAuthManager::authDbOpen() const

2 comments on commit 7c03619

@nyalldawson

This comment has been minimized.

Copy link
Collaborator Author

@nyalldawson nyalldawson replied Sep 28, 2015

@dakcarto Coverity flagged this unreachable code - can you check if this solution is OK?

@dakcarto

This comment has been minimized.

Copy link
Member

@dakcarto dakcarto replied Sep 28, 2015

It looks ok, though I think the removed return false; probably still needs to be there (will double-check). Seems it was an error that was reiterated via copy/paste. Also, seems like Coverity missed some other functions with that flawed logic flow as well.

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