Skip to content

Wrong return-value from basic/object /calendar.c #1015

@skarg

Description

@skarg

Discussed in #1014

Originally posted by maimomohali June 9, 2025
Here is part of bacnet-stack/bacnet-stack/tree/master/src/bacnet/basic/object/calendar.c

Calendar_Date_List_Add`s return type is boolean

bool Calendar_Date_List_Add(uint32_t object_instance, const BACNET_CALENDAR_ENTRY *value)
{
bool st = false;
~~
st = Keylist_Data_Add(pObject->Date_List, Keylist_Count(pObject->Date_List), entry);
return st;
}

From /src/bacnet/basic/sys/keylist.c, Keylist_Data_Add`s return type is int
int Keylist_Data_Add(OS_Keylist list, KEY key, void *data) => return index..

Problem is this,
When "First" Data is added, [Keylist_Data_Add Return] has value , [0] (this mean first index is 0 ,also, mean successful adding)
But, 0 return (successful add) --> st --> Calendar_Date_List_Add` return 0 mean Fail add.

So,
I think [Below explanation & Calendar_Date_List_Add`s return judge ] need some fix.
/**

  • For a given object instance-number, adds a Calendar entity to entities list.
  • @param object_instance - object-instance number of the object
  • @param entity - Calendar entity
  • @return true if the entity is add successfully. --> False can also mean successfull add.
    */

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions