Fix warning about unused variable in QtPlatformSupport

GCC was complaining:
qevdevtouch.cpp:475:13: error: 'maxId' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Which got me scratching my head: maxId was unconditionally initialised. How
could GCC be complaining about it being uninitialised? Well, turns out that
bestId could be uninitialised and the code does:

            if (bestId > maxId)
                maxId = bestId;

Of course, if bestId was uninitialised, the warning should have been in the
"if" line first.

Change-Id: I5e174ab2957d76ad040c14fa6ef8535129b6dce3
Reviewed-by: Laszlo Agocs <lagocs83@gmail.com>
This commit is contained in:
Thiago Macieira 2012-12-21 19:36:12 -08:00 committed by The Qt Project
parent 7426102c73
commit 2ebb714686

View File

@ -457,7 +457,7 @@ void QEvdevTouchScreenData::assignIds()
int maxId = -1;
QHash<int, Contact>::iterator it, ite, bestMatch;
while (!pending.isEmpty() && !candidates.isEmpty()) {
int bestDist = -1, bestId;
int bestDist = -1, bestId = 0;
for (it = pending.begin(), ite = pending.end(); it != ite; ++it) {
int dist;
int id = findClosestContact(candidates, it->x, it->y, &dist);