Skip to content

Commit

Permalink
Fix coverity unreachable code error
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 28, 2015
1 parent 808a432 commit 7c03619
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/core/auth/qgsauthmanager.cpp
Expand Up @@ -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 "
Expand All @@ -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 )
Expand Down Expand Up @@ -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 "
Expand All @@ -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
Expand Down

2 comments on commit 7c03619

@nyalldawson
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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

@dakcarto
Copy link
Member

Choose a reason for hiding this comment

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

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.