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 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. Increased the size of the name string to handle larger possible integers.

* Fixed copied code that no longer needs static function scope variables for text names.
This commit is contained in:
Steve Karg
2025-09-12 15:08:47 -05:00
committed by GitHub
parent 0da61e52bb
commit 9b6173995c
28 changed files with 82 additions and 64 deletions
+2 -2
View File
@@ -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);
}
}
+3 -3
View File
@@ -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);
}
}
+2 -1
View File
@@ -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);
}
}
+1 -1
View File
@@ -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);
+4 -2
View File
@@ -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);
}
}
+3 -3
View File
@@ -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);
}
}
+2 -2
View File
@@ -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);
}
}
+3 -3
View File
@@ -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);
}
}
+2 -2
View File
@@ -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);
}
}
+2 -2
View File
@@ -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);
}
}
+3 -3
View File
@@ -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);
}
}
+1 -1
View File
@@ -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(": ");