From 9d5a2e981504c76b175b3074d7e104085d134038 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 5 Sep 2015 22:03:42 +0200 Subject: [PATCH] Launch detection: Fix hard typing in array size calculation, fix use of index variable --- src/lib/launchdetection/LaunchDetector.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/launchdetection/LaunchDetector.cpp b/src/lib/launchdetection/LaunchDetector.cpp index 24f2953426..6bcae85344 100644 --- a/src/lib/launchdetection/LaunchDetector.cpp +++ b/src/lib/launchdetection/LaunchDetector.cpp @@ -66,7 +66,7 @@ LaunchDetector::~LaunchDetector() void LaunchDetector::reset() { /* Reset all detectors */ - for (uint8_t i = 0; i < sizeof(launchMethods)/sizeof(LaunchMethod *); i++) { + for (unsigned i = 0; i < (sizeof(launchMethods) / sizeof(launchMethods[0])); i++) { launchMethods[i]->reset(); } @@ -79,7 +79,7 @@ void LaunchDetector::reset() void LaunchDetector::update(float accel_x) { if (launchdetection_on.get() == 1) { - for (uint8_t i = 0; i < sizeof(launchMethods)/sizeof(LaunchMethod *); i++) { + for (unsigned i = 0; i < (sizeof(launchMethods) / sizeof(launchMethods[0])); i++) { launchMethods[i]->update(accel_x); } } @@ -90,7 +90,7 @@ LaunchDetectionResult LaunchDetector::getLaunchDetected() if (launchdetection_on.get() == 1) { if (activeLaunchDetectionMethodIndex < 0) { /* None of the active launchmethods has detected a launch, check all launchmethods */ - for (uint8_t i = 0; i < sizeof(launchMethods)/sizeof(LaunchMethod *); i++) { + for (unsigned i = 0; i < (sizeof(launchMethods) / sizeof(launchMethods[0])); i++) { if(launchMethods[i]->getLaunchDetected() != LAUNCHDETECTION_RES_NONE) { warnx("selecting launchmethod %d", i); activeLaunchDetectionMethodIndex = i; // from now on only check this method