From 4ab9808180b8a4cc59294b2f52687e5311f50635 Mon Sep 17 00:00:00 2001 From: Ben Franksen Date: Mon, 30 Mar 2020 21:46:46 +0200 Subject: [PATCH] make it clearer what the result of wrapArrayIndices will be --- modules/database/src/std/filters/arr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/database/src/std/filters/arr.c b/modules/database/src/std/filters/arr.c index 813848076..cfa7118bf 100644 --- a/modules/database/src/std/filters/arr.c +++ b/modules/database/src/std/filters/arr.c @@ -77,8 +77,6 @@ static void freeArray(db_field_log *pfl) static long wrapArrayIndices(long *start, const long increment, long *end, const long no_elements) { - long len = 0; - if (*start < 0) *start = no_elements + *start; if (*start < 0) *start = 0; if (*start > no_elements) *start = no_elements; @@ -87,8 +85,10 @@ static long wrapArrayIndices(long *start, const long increment, long *end, if (*end < 0) *end = 0; if (*end >= no_elements) *end = no_elements - 1; - if (*end - *start >= 0) len = 1 + (*end - *start) / increment; - return len; + if (*end - *start >= 0) + return 1 + (*end - *start) / increment; + else + return 0; } static db_field_log* filter(void* pvt, dbChannel *chan, db_field_log *pfl)