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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(": ");
|
||||
|
||||
+27
-25
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user