diff options
author | Zou Ya <zouya@uniontech.com> | 2020-11-24 19:54:09 +0800 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-26 14:43:20 +0100 |
commit | 5b93f6cae692363ab03b0c9b0ae8efd0bb4ef499 (patch) | |
tree | c3f85874099bc91c0b411ef08f54abcd1a7dc1c4 /src/plugins/sqldrivers/mysql/qsql_mysql.cpp | |
parent | 6cb36d825d365988ea7a601218bdd3a329290469 (diff) | |
download | qtbase-5b93f6cae692363ab03b0c9b0ae8efd0bb4ef499.tar.gz |
Reduce the scope of variables in exec() and fetchNext()
The scope of the variable 'currBind' can be reduced if the variable 'r'
is not 0. So declare the variable when the variable 'r' is 0. The local
variable 'i' shadows outer variable in fetchNext(), so move it to the
front of switch.
Don't declare 'res' until we need and initialize it.
Change-Id: Idfb220b96cfbcd4088fd7858ed9392d0a3e10aea
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers/mysql/qsql_mysql.cpp')
-rw-r--r-- | src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 7d945f23fc..3092a7f772 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -872,7 +872,6 @@ bool QMYSQLResult::exec() return false; int r = 0; - MYSQL_BIND* currBind; QList<MYSQL_TIME *> timeVector; QList<QByteArray> stringVector; QList<my_bool> nullVector; @@ -894,7 +893,7 @@ bool QMYSQLResult::exec() const QVariant &val = boundValues().at(i); void *data = const_cast<void *>(val.constData()); - currBind = &d->outBinds[i]; + MYSQL_BIND* currBind = &d->outBinds[i]; nullVector[i] = static_cast<my_bool>(val.isNull()); currBind->is_null = &nullVector[i]; |