util: Fix Clang warnings in SQLiteDatabase

This commit is contained in:
Oleg Shparber 2017-02-17 20:18:23 -05:00
parent a5ef8e88c5
commit 01ffac5d34

View File

@ -81,8 +81,8 @@ bool SQLiteDatabase::execute(const QString &queryStr)
sqlite3_mutex_enter(sqlite3_db_mutex(m_db));
const void *pzTail = nullptr;
const int res = sqlite3_prepare16_v2(m_db, queryStr.constData(),
(queryStr.size() + 1) * sizeof(QChar), &m_stmt, &pzTail);
const int res = sqlite3_prepare16_v2(m_db, queryStr.constData(), (queryStr.size() + 1) * 2,
&m_stmt, &pzTail); // 2 = sizeof(QChar)
sqlite3_mutex_leave(sqlite3_db_mutex(m_db));
if (res != SQLITE_OK) {
@ -140,12 +140,16 @@ QVariant SQLiteDatabase::value(int index) const
switch (type) {
case SQLITE_INTEGER:
ret = sqlite3_column_int64(m_stmt, index);
break;
case SQLITE_NULL:
ret = QVariant(QVariant::String);
break;
default:
ret = QString(reinterpret_cast<const QChar *>(sqlite3_column_text16(m_stmt, index)),
sqlite3_column_bytes16(m_stmt, index) / sizeof(QChar));
sqlite3_column_bytes16(m_stmt, index) / 2); // 2 = sizeof(QChar)
break;
}
sqlite3_mutex_leave(sqlite3_db_mutex(m_db));
return ret;
}