From 5b93f6cae692363ab03b0c9b0ae8efd0bb4ef499 Mon Sep 17 00:00:00 2001 From: Zou Ya Date: Tue, 24 Nov 2020 19:54:09 +0800 Subject: 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 --- src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/plugins/sqldrivers/mysql') 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 timeVector; QList stringVector; QList nullVector; @@ -894,7 +893,7 @@ bool QMYSQLResult::exec() const QVariant &val = boundValues().at(i); void *data = const_cast(val.constData()); - currBind = &d->outBinds[i]; + MYSQL_BIND* currBind = &d->outBinds[i]; nullVector[i] = static_cast(val.isNull()); currBind->is_null = &nullVector[i]; -- cgit v1.2.3