From bc93ee060abcd746cbed906a51f2379e3da6f379 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 3 Jun 2017 10:31:23 -0700 Subject: Help GCC understand that variable is never used unintialized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marc Mutz --- src/widgets/kernel/qformlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/kernel/qformlayout.cpp') diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index c66a6d5673..868ac17b6f 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -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; -- cgit v1.2.3