Fixed two SQLiteC++ Coverity Issues in Database::execAndGet() and Database::tableExists()

- adding a (void) cast in front of query.executeStep()
- adding comments explaining how errors are handled in this thow methods

Thank you to Donald Jones and Mark Pashley of Ubiquisys for reporting this to me.
This commit is contained in:
Sébastien Rombauts 2013-04-27 13:14:51 +02:00
parent 3442a9a002
commit 4d828fe6b1

View File

@ -59,7 +59,7 @@ int Database::exec(const char* apQueries) // throw(SQLite::Exception);
Column Database::execAndGet(const char* apQuery) // throw(SQLite::Exception)
{
Statement query(*this, apQuery);
query.executeStep();
(void)query.executeStep(); // Can return false if no result, which will throw next line in getColumn()
return query.getColumn(0);
}
@ -68,7 +68,7 @@ bool Database::tableExists(const char* apTableName) // throw(SQLite::Exception)
{
Statement query(*this, "SELECT count(*) FROM sqlite_master WHERE type='table' AND name=?");
query.bind(1, apTableName);
query.executeStep();
(void)query.executeStep(); // Cannot return false, as the above query always return a result
int Nb = query.getColumn(0);
return (1 == Nb);
}