diff --git a/CHANGELOG.md b/CHANGELOG.md index 43edbac4..7a8adf58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The git repositories are hosted at the following sites: ### Added +* Added MS/TP statistics counters for BadCRC and Poll-For-Master. (#1081) * Added Lighting Output API to implement override for HOA control. Integrated lighting command overridden behavior into the lighting output object and added Overridden status flags API. @@ -99,6 +100,9 @@ The git repositories are hosted at the following sites: ### Changed +* Changed Who-Am-I and You-Are JSON handlers to eliminate dynamic + memory allocation for model and serial number strings, + improving memory management and simplifying code. (#1089) * Change stm32f4xx example to use static RAM file system. (#1058) * Changed the bacnet file object to be storage agnostic by refactoring and using callbacks. (#1056) @@ -110,6 +114,12 @@ The git repositories are hosted at the following sites: ### Fixed +* Fixed copied code that no longer needs static function scope variables + for text names. (#1092) +* Fixed compiler warning format '%u' expects argument of type 'unsigned int', + but argument 4 has type 'uint32_t' {aka 'long unsigned int'} + [-Werror=format=] by casting or increasing format specifier size + and casting. (#1092) * Fixed Lighting_Command to ignore write priority and use its own. (#1086) * Fixed BACnetLightingOperation reserved range. (#1086) * Fixed missing prototype warning in lighting.c module. diff --git a/apps/epics/main.c b/apps/epics/main.c index c28fd00d..67372741 100644 --- a/apps/epics/main.c +++ b/apps/epics/main.c @@ -683,7 +683,8 @@ static void PrintReadPropertyData( static void Print_Property_Identifier(unsigned propertyIdentifier) { if (bactext_property_name_proprietary(propertyIdentifier)) { - fprintf(stdout, "-- proprietary %u", propertyIdentifier); + fprintf( + stdout, "-- proprietary %lu", (unsigned long)propertyIdentifier); } else { fprintf(stdout, "%s", bactext_property_name(propertyIdentifier)); } diff --git a/apps/gtk-discover/main.c b/apps/gtk-discover/main.c index c4bda8d2..bf39c841 100644 --- a/apps/gtk-discover/main.c +++ b/apps/gtk-discover/main.c @@ -274,7 +274,9 @@ static void add_discovered_properties_to_gui( bacnet_discover_object_property_identifier( device_id, object_type, object_instance, index, &property_id); if (bactext_property_name_proprietary(property_id)) { - asprintfa(&property_string, "proprietary-%u", property_id); + asprintfa( + &property_string, "proprietary-%lu", + (unsigned long)property_id); } else { asprintfa( &property_string, "%s", bactext_property_name(property_id)); diff --git a/ports/at91sam7s/ai.c b/ports/at91sam7s/ai.c index 9c706b55..1fdc3bb9 100644 --- a/ports/at91sam7s/ai.c +++ b/ports/at91sam7s/ai.c @@ -75,7 +75,7 @@ uint32_t Analog_Input_Index_To_Instance(unsigned index) bool Analog_Input_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text_string[16] = "AI-0"; /* okay for single thread */ + char text_string[16] = "AI-0"; bool status = false; if (object_instance < MAX_ANALOG_INPUTS) { diff --git a/ports/at91sam7s/av.c b/ports/at91sam7s/av.c index b708f173..dff660af 100644 --- a/ports/at91sam7s/av.c +++ b/ports/at91sam7s/av.c @@ -131,7 +131,7 @@ float Analog_Value_Present_Value(uint32_t object_instance) bool Analog_Value_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text_string[16] = "AV-0"; /* okay for single thread */ + char text_string[16] = "AV-0"; bool status = false; if (object_instance < MAX_ANALOG_VALUES) { diff --git a/ports/at91sam7s/bi.c b/ports/at91sam7s/bi.c index d0a9e7f2..9d46338c 100644 --- a/ports/at91sam7s/bi.c +++ b/ports/at91sam7s/bi.c @@ -110,7 +110,7 @@ BACNET_BINARY_PV Binary_Input_Present_Value(uint32_t object_instance) bool Binary_Input_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text_string[16] = "BI-0"; /* okay for single thread */ + char text_string[16] = "BI-0"; bool status = false; if (object_instance < MAX_BINARY_INPUTS) { diff --git a/ports/at91sam7s/bv.c b/ports/at91sam7s/bv.c index e11cedcd..b73c979d 100644 --- a/ports/at91sam7s/bv.c +++ b/ports/at91sam7s/bv.c @@ -105,7 +105,7 @@ BACNET_BINARY_PV Binary_Value_Present_Value(uint32_t object_instance) bool Binary_Value_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text_string[16] = "BV-0"; /* okay for single thread */ + char text_string[16] = "BV-0"; bool status = false; if (object_instance < MAX_BINARY_VALUES) { diff --git a/ports/bdk-atxx4-mstp/ai.c b/ports/bdk-atxx4-mstp/ai.c index ff4778a3..65d2c819 100644 --- a/ports/bdk-atxx4-mstp/ai.c +++ b/ports/bdk-atxx4-mstp/ai.c @@ -77,7 +77,7 @@ uint32_t Analog_Input_Index_To_Instance(unsigned index) bool Analog_Input_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text[32]; /* okay for single thread */ + char text[32]; bool status = false; if (object_instance < MAX_ANALOG_INPUTS) { diff --git a/ports/bdk-atxx4-mstp/av.c b/ports/bdk-atxx4-mstp/av.c index bc7a7c29..712463c7 100644 --- a/ports/bdk-atxx4-mstp/av.c +++ b/ports/bdk-atxx4-mstp/av.c @@ -141,7 +141,7 @@ bool Analog_Value_Present_Value_Set( bool Analog_Value_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text[32] = ""; /* okay for single thread */ + char text[32] = ""; unsigned index = 0; bool status = false; diff --git a/ports/bdk-atxx4-mstp/bi.c b/ports/bdk-atxx4-mstp/bi.c index d98bbca4..ae679131 100644 --- a/ports/bdk-atxx4-mstp/bi.c +++ b/ports/bdk-atxx4-mstp/bi.c @@ -122,7 +122,7 @@ bool Binary_Input_Present_Value_Set( bool Binary_Input_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text[32]; /* okay for single thread */ + char text[32]; bool status = false; if (object_instance < MAX_BINARY_INPUTS) { diff --git a/ports/bdk-atxx4-mstp/bo.c b/ports/bdk-atxx4-mstp/bo.c index d64afb8e..57692d44 100644 --- a/ports/bdk-atxx4-mstp/bo.c +++ b/ports/bdk-atxx4-mstp/bo.c @@ -192,7 +192,7 @@ bool Binary_Output_Out_Of_Service(uint32_t instance) bool Binary_Output_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text[32]; /* okay for single thread */ + char text[32]; bool status = false; if (object_instance < MAX_BINARY_OUTPUTS) { diff --git a/ports/stm32f10x/bo.c b/ports/stm32f10x/bo.c index 4385ce65..f60bd90f 100644 --- a/ports/stm32f10x/bo.c +++ b/ports/stm32f10x/bo.c @@ -181,7 +181,7 @@ bool Binary_Output_Out_Of_Service(uint32_t instance) bool Binary_Output_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text_string[16] = "BO-0"; /* okay for single thread */ + char text_string[16] = "BO-0"; bool status = false; if (object_instance < MAX_BINARY_OUTPUTS) { diff --git a/ports/win32/bip6.c b/ports/win32/bip6.c index d171aa15..34096a0a 100644 --- a/ports/win32/bip6.c +++ b/ports/win32/bip6.c @@ -93,7 +93,7 @@ void bip6_set_interface(char *ifname) Hints.ai_socktype = SOCK_DGRAM; Hints.ai_protocol = IPPROTO_UDP; Hints.ai_flags = AI_NUMERICHOST | AI_PASSIVE; - snprintf(port, sizeof(port), "%u", BIP6_Addr.port); + snprintf(port, sizeof(port), "%u", (unsigned)BIP6_Addr.port); if (BIP6_Debug) { debug_fprintf( stderr, "BIP6: seeking IPv6 address %s port %s...\n", ifname, port); diff --git a/ports/xplained/ai.c b/ports/xplained/ai.c index c5eddf59..48ed7c34 100644 --- a/ports/xplained/ai.c +++ b/ports/xplained/ai.c @@ -86,7 +86,7 @@ unsigned Analog_Input_Count(void) bool Analog_Input_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { - static char text[32]; /* okay for single thread */ + char text[32]; bool status = false; unsigned index = 0; diff --git a/src/bacnet/basic/object/bitstring_value.c b/src/bacnet/basic/object/bitstring_value.c index 94e13347..dca2e336 100644 --- a/src/bacnet/basic/object/bitstring_value.c +++ b/src/bacnet/basic/object/bitstring_value.c @@ -495,8 +495,8 @@ bool BitString_Value_Object_Name( characterstring_init_ansi(object_name, pObject->Object_Name); } else { snprintf( - name_text, sizeof(name_text), "BITSTRING_VALUE-%u", - object_instance); + name_text, sizeof(name_text), "BITSTRING_VALUE-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/object/blo.c b/src/bacnet/basic/object/blo.c index d3775546..70d2fb74 100644 --- a/src/bacnet/basic/object/blo.c +++ b/src/bacnet/basic/object/blo.c @@ -773,7 +773,7 @@ bool Binary_Lighting_Output_Object_Name( { bool status = false; struct object_data *pObject; - char name_text[32] = "BINARY-LIGHTING-OUTPUT-4194303"; + char name_text[48] = "BINARY-LIGHTING-OUTPUT-4194303"; pObject = Keylist_Data(Object_List, object_instance); if (pObject) { @@ -782,8 +782,8 @@ bool Binary_Lighting_Output_Object_Name( characterstring_init_ansi(object_name, pObject->Object_Name); } else { snprintf( - name_text, sizeof(name_text), "BINARY-LIGHTING-OUTPUT-%u", - object_instance); + name_text, sizeof(name_text), "BINARY-LIGHTING-OUTPUT-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/object/calendar.c b/src/bacnet/basic/object/calendar.c index 9e750dd2..4b872417 100644 --- a/src/bacnet/basic/object/calendar.c +++ b/src/bacnet/basic/object/calendar.c @@ -384,7 +384,8 @@ bool Calendar_Object_Name( characterstring_init_ansi(object_name, pObject->Object_Name); } else { snprintf( - name_text, sizeof(name_text), "CALENDAR-%u", object_instance); + name_text, sizeof(name_text), "CALENDAR-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/object/channel.c b/src/bacnet/basic/object/channel.c index 0449412b..0516ef1a 100644 --- a/src/bacnet/basic/object/channel.c +++ b/src/bacnet/basic/object/channel.c @@ -847,7 +847,7 @@ bool Channel_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING *object_name) { bool status = false; - char name_text[24] = "CHANNEL-4194303"; + char name_text[32] = "CHANNEL-4194303"; struct object_data *pObject; pObject = Object_Data(object_instance); diff --git a/src/bacnet/basic/object/color_object.c b/src/bacnet/basic/object/color_object.c index e7c2d5d6..c510df80 100644 --- a/src/bacnet/basic/object/color_object.c +++ b/src/bacnet/basic/object/color_object.c @@ -696,7 +696,7 @@ bool Color_Object_Name( { bool status = false; struct object_data *pObject; - char name_text[24] = "COLOR-4194303"; + char name_text[32] = "COLOR-4194303"; pObject = Keylist_Data(Object_List, object_instance); if (pObject) { @@ -704,7 +704,9 @@ bool Color_Object_Name( status = characterstring_init_ansi(object_name, pObject->Object_Name); } else { - snprintf(name_text, sizeof(name_text), "COLOR-%u", object_instance); + snprintf( + name_text, sizeof(name_text), "COLOR-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/object/color_temperature.c b/src/bacnet/basic/object/color_temperature.c index a1b357b9..d8179d96 100644 --- a/src/bacnet/basic/object/color_temperature.c +++ b/src/bacnet/basic/object/color_temperature.c @@ -935,7 +935,7 @@ bool Color_Temperature_Object_Name( { bool status = false; struct object_data *pObject; - char name_text[26] = "COLOR-TEMPERATURE-4194303"; + char name_text[48] = "COLOR-TEMPERATURE-4194303"; pObject = Keylist_Data(Object_List, object_instance); if (pObject) { @@ -944,8 +944,8 @@ bool Color_Temperature_Object_Name( characterstring_init_ansi(object_name, pObject->Object_Name); } else { snprintf( - name_text, sizeof(name_text), "COLOR-TEMPERATURE-%u", - object_instance); + name_text, sizeof(name_text), "COLOR-TEMPERATURE-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/object/lc.c b/src/bacnet/basic/object/lc.c index 35bbc106..deac1fb0 100644 --- a/src/bacnet/basic/object/lc.c +++ b/src/bacnet/basic/object/lc.c @@ -244,8 +244,8 @@ bool Load_Control_Object_Name( characterstring_init_ansi(object_name, pObject->Object_Name); } else { snprintf( - name_text, sizeof(name_text), "LOAD_CONTROL-%u", - object_instance); + name_text, sizeof(name_text), "LOAD_CONTROL-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/object/lo.c b/src/bacnet/basic/object/lo.c index 1a1008e4..f4daa8a2 100644 --- a/src/bacnet/basic/object/lo.c +++ b/src/bacnet/basic/object/lo.c @@ -974,7 +974,7 @@ bool Lighting_Output_Object_Name( { bool status = false; struct object_data *pObject; - char name_text[24] = "LIGHTING-OUTPUT-4194303"; + char name_text[48] = "LIGHTING-OUTPUT-4194303"; pObject = Keylist_Data(Object_List, object_instance); if (pObject) { @@ -983,8 +983,8 @@ bool Lighting_Output_Object_Name( characterstring_init_ansi(object_name, pObject->Object_Name); } else { snprintf( - name_text, sizeof(name_text), "LIGHTING-OUTPUT-%u", - object_instance); + name_text, sizeof(name_text), "LIGHTING-OUTPUT-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/object/lsp.c b/src/bacnet/basic/object/lsp.c index 19f669e2..b0757989 100644 --- a/src/bacnet/basic/object/lsp.c +++ b/src/bacnet/basic/object/lsp.c @@ -198,8 +198,8 @@ bool Life_Safety_Point_Object_Name( characterstring_init_ansi(object_name, pObject->Object_Name); } else { snprintf( - name_text, sizeof(name_text), "LIFE-SAFETY-POINT-%u", - object_instance); + name_text, sizeof(name_text), "LIFE-SAFETY-POINT-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/object/lsz.c b/src/bacnet/basic/object/lsz.c index 7b092a05..b8953e53 100644 --- a/src/bacnet/basic/object/lsz.c +++ b/src/bacnet/basic/object/lsz.c @@ -209,8 +209,8 @@ bool Life_Safety_Zone_Object_Name( characterstring_init_ansi(object_name, pObject->Object_Name); } else { snprintf( - name_text, sizeof(name_text), "LIFE-SAFETY-ZONE-%u", - object_instance); + name_text, sizeof(name_text), "LIFE-SAFETY-ZONE-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/object/structured_view.c b/src/bacnet/basic/object/structured_view.c index b2d229e1..5c3fd78e 100644 --- a/src/bacnet/basic/object/structured_view.c +++ b/src/bacnet/basic/object/structured_view.c @@ -168,7 +168,7 @@ bool Structured_View_Object_Name( { bool status = false; struct object_data *pObject; - char name_text[24] = "Structured-View-4194303"; + char name_text[48] = "Structured-View-4194303"; pObject = Keylist_Data(Object_List, object_instance); if (pObject) { @@ -177,8 +177,8 @@ bool Structured_View_Object_Name( characterstring_init_ansi(object_name, pObject->Object_Name); } else { snprintf( - name_text, sizeof(name_text), "Structured-View-%u", - object_instance); + name_text, sizeof(name_text), "Structured-View-%lu", + (unsigned long)object_instance); status = characterstring_init_ansi(object_name, name_text); } } diff --git a/src/bacnet/basic/service/h_rr_a.c b/src/bacnet/basic/service/h_rr_a.c index e729829d..72c2b12c 100644 --- a/src/bacnet/basic/service/h_rr_a.c +++ b/src/bacnet/basic/service/h_rr_a.c @@ -51,7 +51,7 @@ static void PrintReadRangeData(BACNET_READ_RANGE_DATA *data) by others subject to the procedures and constraints described in Clause 23. */ debug_printf_stdout( - " proprietary %u", (unsigned)data->object_property); + " proprietary %lu", (unsigned long)data->object_property); } if (data->array_index == BACNET_ARRAY_ALL) { debug_printf_stdout(": "); diff --git a/src/bacnet/hostnport.c b/src/bacnet/hostnport.c index 75d4423b..5f2f5f2b 100644 --- a/src/bacnet/hostnport.c +++ b/src/bacnet/hostnport.c @@ -949,42 +949,44 @@ int bacnet_bdt_entry_to_ascii( if (ip_len == 4) { len = snprintf( str, str_size, "%u.%u.%u.%u:%u,%u.%u.%u.%u", - value->bbmd_address.host.ip_address.value[0], - value->bbmd_address.host.ip_address.value[1], - value->bbmd_address.host.ip_address.value[2], - value->bbmd_address.host.ip_address.value[3], - value->bbmd_address.port, value->broadcast_mask.value[0], - value->broadcast_mask.value[1], value->broadcast_mask.value[2], - value->broadcast_mask.value[3]); + (unsigned)value->bbmd_address.host.ip_address.value[0], + (unsigned)value->bbmd_address.host.ip_address.value[1], + (unsigned)value->bbmd_address.host.ip_address.value[2], + (unsigned)value->bbmd_address.host.ip_address.value[3], + (unsigned)value->bbmd_address.port, + (unsigned)value->broadcast_mask.value[0], + (unsigned)value->broadcast_mask.value[1], + (unsigned)value->broadcast_mask.value[2], + (unsigned)value->broadcast_mask.value[3]); } else if (ip_len == 16) { len = snprintf( str, str_size, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:" "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%u", - value->bbmd_address.host.ip_address.value[0], - value->bbmd_address.host.ip_address.value[1], - value->bbmd_address.host.ip_address.value[2], - value->bbmd_address.host.ip_address.value[3], - value->bbmd_address.host.ip_address.value[4], - value->bbmd_address.host.ip_address.value[5], - value->bbmd_address.host.ip_address.value[6], - value->bbmd_address.host.ip_address.value[7], - value->bbmd_address.host.ip_address.value[8], - value->bbmd_address.host.ip_address.value[9], - value->bbmd_address.host.ip_address.value[10], - value->bbmd_address.host.ip_address.value[11], - value->bbmd_address.host.ip_address.value[12], - value->bbmd_address.host.ip_address.value[13], - value->bbmd_address.host.ip_address.value[14], - value->bbmd_address.host.ip_address.value[15], - value->bbmd_address.port); + (unsigned)value->bbmd_address.host.ip_address.value[0], + (unsigned)value->bbmd_address.host.ip_address.value[1], + (unsigned)value->bbmd_address.host.ip_address.value[2], + (unsigned)value->bbmd_address.host.ip_address.value[3], + (unsigned)value->bbmd_address.host.ip_address.value[4], + (unsigned)value->bbmd_address.host.ip_address.value[5], + (unsigned)value->bbmd_address.host.ip_address.value[6], + (unsigned)value->bbmd_address.host.ip_address.value[7], + (unsigned)value->bbmd_address.host.ip_address.value[8], + (unsigned)value->bbmd_address.host.ip_address.value[9], + (unsigned)value->bbmd_address.host.ip_address.value[10], + (unsigned)value->bbmd_address.host.ip_address.value[11], + (unsigned)value->bbmd_address.host.ip_address.value[12], + (unsigned)value->bbmd_address.host.ip_address.value[13], + (unsigned)value->bbmd_address.host.ip_address.value[14], + (unsigned)value->bbmd_address.host.ip_address.value[15], + (unsigned)value->bbmd_address.port); } } else if (value->bbmd_address.host_name) { len = snprintf( str, str_size, "%*s:%u", (int)characterstring_length(&value->bbmd_address.host.name), characterstring_value(&value->bbmd_address.host.name), - value->bbmd_address.port); + (unsigned)value->bbmd_address.port); } return len; diff --git a/src/bacnet/lighting.c b/src/bacnet/lighting.c index 09fb1642..382730f8 100644 --- a/src/bacnet/lighting.c +++ b/src/bacnet/lighting.c @@ -440,7 +440,7 @@ int lighting_command_to_ascii( priority = value->priority; } len = snprintf( - buf, buf_size, "%u,%f,%lu,%u", value->operation, + buf, buf_size, "%u,%f,%lu,%u", (unsigned)value->operation, (double)target_level, (unsigned long)fade_time, (unsigned)priority); break;