From 600508c357396725c72c5f268ef087f1062682bf Mon Sep 17 00:00:00 2001 From: antocout <149781661+antocout@users.noreply.github.com> Date: Wed, 17 Apr 2024 15:53:12 +0200 Subject: [PATCH] Change first instance of an integer value from 1 to 0 (#619) Integer_Values instances start at 1 while other object instances start at 0. Change this to have the same start for all objects. Signed-off-by: Antoine Coutant --- src/bacnet/basic/object/iv.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/bacnet/basic/object/iv.c b/src/bacnet/basic/object/iv.c index bba3d89c..8cee5eaf 100644 --- a/src/bacnet/basic/object/iv.c +++ b/src/bacnet/basic/object/iv.c @@ -134,11 +134,7 @@ unsigned Integer_Value_Count(void) */ uint32_t Integer_Value_Index_To_Instance(unsigned index) { - uint32_t instance = 1; - - instance += index; - - return instance; + return index; } /** @@ -154,11 +150,8 @@ unsigned Integer_Value_Instance_To_Index(uint32_t object_instance) { unsigned index = MAX_INTEGER_VALUES; - if (object_instance) { - index = object_instance - 1; - if (index > MAX_INTEGER_VALUES) { - index = MAX_INTEGER_VALUES; - } + if (object_instance < MAX_INTEGER_VALUES) { + index = object_instance; } return index;