Help GCC understand that variable is never used unintialized

qformlayout.cpp:1982:14: error: ‘role’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

The variable role is never used uninitialized because the access is
protected by the check for row != -1. The only condition under which
QFormLayout::getItemPosition will leave role unset is if it sets row to
-1. Since row == -1 ←→ col == -1 ←→ storageIndex == -1, we can simply
change the variable that we check here and the warning goes away.

Change-Id: Ia3e896da908f42939148fffd14c4ace6e40a808e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Thiago Macieira 2017-06-03 10:31:23 -07:00
parent 0265a23bb0
commit bc93ee060a
1 changed files with 1 additions and 1 deletions

View File

@ -1907,7 +1907,7 @@ void QFormLayout::getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) con
if (rowPtr)
*rowPtr = row;
if (rolePtr && col != -1) {
if (rolePtr && row != -1) {
const bool spanning = col == 1 && d->m_matrix(row, col)->fullRow;
if (spanning) {
*rolePtr = SpanningRole;