From 15592682ad7cc0dd4559f8544798075b2a1e7a1e Mon Sep 17 00:00:00 2001 From: SG Date: Wed, 4 Aug 2021 03:07:39 +1000 Subject: [PATCH] Notification settings: correctly count values with a zero index (#621) --- applications/notification/notification-app-settings.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/notification/notification-app-settings.c b/applications/notification/notification-app-settings.c index 21d1908c7..3bcf084b1 100644 --- a/applications/notification/notification-app-settings.c +++ b/applications/notification/notification-app-settings.c @@ -74,7 +74,7 @@ uint8_t float_value_index(const float value, const float values[], uint8_t value const float epsilon = 0.01f; float last_value = values[0]; uint8_t index = 0; - for(uint8_t i = 1; i < values_count; i++) { + for(uint8_t i = 0; i < values_count; i++) { if((value >= last_value - epsilon) && (value <= values[i] + epsilon)) { index = i; break; @@ -85,9 +85,9 @@ uint8_t float_value_index(const float value, const float values[], uint8_t value } uint8_t uint32_value_index(const uint32_t value, const uint32_t values[], uint8_t values_count) { - float last_value = values[0]; + int64_t last_value = INT64_MIN; uint8_t index = 0; - for(uint8_t i = 1; i < values_count; i++) { + for(uint8_t i = 0; i < values_count; i++) { if((value >= last_value) && (value <= values[i])) { index = i; break;