From e297d72fa6722173abf6f1c3096440fb0bffe2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Thu, 25 Sep 2014 20:49:43 +0100 Subject: [PATCH] Fix build when using -Werror "accessible/qaccessible.cpp:2154:43: error: 'type' may be used uninitialized in this function [-Werror=maybe-uninitialized]" Compiler doesn't seem very smart, all enumerators are handled in the switch already. Observed on android's gcc and gcc-4.7 on GNU/Linux Change-Id: I30b4660c18992158457cada01b5916aa4feae4ff Reviewed-by: BogDan Vatra --- src/gui/accessible/qaccessible.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 524fc3a511..d3afed604f 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -1972,7 +1972,8 @@ QString QAccessibleTextInterface::textBeforeOffset(int offset, QAccessible::Text if (txt.isEmpty() || offset <= 0 || offset > txt.length()) return QString(); - QTextBoundaryFinder::BoundaryType type; + // type initialized just to silence a compiler warning [-Werror=maybe-uninitialized] + QTextBoundaryFinder::BoundaryType type = QTextBoundaryFinder::Grapheme; switch (boundaryType) { case QAccessible::CharBoundary: type = QTextBoundaryFinder::Grapheme; @@ -2043,7 +2044,8 @@ QString QAccessibleTextInterface::textAfterOffset(int offset, QAccessible::TextB if (txt.isEmpty() || offset < 0 || offset >= txt.length()) return QString(); - QTextBoundaryFinder::BoundaryType type; + // type initialized just to silence a compiler warning [-Werror=maybe-uninitialized] + QTextBoundaryFinder::BoundaryType type = QTextBoundaryFinder::Grapheme; switch (boundaryType) { case QAccessible::CharBoundary: type = QTextBoundaryFinder::Grapheme; @@ -2128,7 +2130,8 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun if (offset == txt.length() && boundaryType == QAccessible::CharBoundary) return QString(); - QTextBoundaryFinder::BoundaryType type; + // type initialized just to silence a compiler warning [-Werror=maybe-uninitialized] + QTextBoundaryFinder::BoundaryType type = QTextBoundaryFinder::Grapheme; switch (boundaryType) { case QAccessible::CharBoundary: type = QTextBoundaryFinder::Grapheme;