Cleanup: use correct loop bounds

I'm a bit confused why this enum has two extra values, NUM_DIVEMODE and
UNDEF_COMP_TYPE. I can see how this could create confusion. This may
benefit from addition review.

Found by Coverity. Fixes CID 350092.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-10-26 07:54:57 -04:00
parent 56e8ac0bd7
commit 70737b9eec

View file

@ -1652,7 +1652,7 @@ void ProfileWidget2::addDivemodeSwitch()
int i; int i;
QAction *action = qobject_cast<QAction *>(sender()); QAction *action = qobject_cast<QAction *>(sender());
QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint())); QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint()));
for (i = 0; i < UNDEF_COMP_TYPE; i++) for (i = 0; i < NUM_DIVEMODE; i++)
if (gettextFromC::tr(divemode_text_ui[i]) == action->text()) if (gettextFromC::tr(divemode_text_ui[i]) == action->text())
add_event(current_dc, lrint(timeAxis->valueAt(scenePos)), 8, 0, i, add_event(current_dc, lrint(timeAxis->valueAt(scenePos)), 8, 0, i,
QT_TRANSLATE_NOOP("gettextFromC", "modechange")); QT_TRANSLATE_NOOP("gettextFromC", "modechange"));