Refactored all the sprintf to use snprintf instead. (#628)
This commit is contained in:
+3
-3
@@ -106,14 +106,14 @@ unsigned Analog_Input_Count(void)
|
||||
bool Analog_Input_Object_Name(
|
||||
uint32_t object_instance, BACNET_CHARACTER_STRING *object_name)
|
||||
{
|
||||
static char text_string[32]; /* okay for single thread */
|
||||
static char text[32]; /* okay for single thread */
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
|
||||
index = Analog_Input_Instance_To_Index(object_instance);
|
||||
if (index < MAX_ANALOG_INPUTS) {
|
||||
sprintf(text_string, "AI-%lu", object_instance);
|
||||
status = characterstring_init_ansi(object_name, text_string);
|
||||
snprintf(text, sizeof(text), "AI-%lu", (unsigned long)object_instance);
|
||||
status = characterstring_init_ansi(object_name, text);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -241,11 +241,12 @@ uint32_t Device_Index_To_Instance(unsigned index)
|
||||
|
||||
static char *Device_Name_Default(void)
|
||||
{
|
||||
static char text_string[32]; /* okay for single thread */
|
||||
static char text[32]; /* okay for single thread */
|
||||
|
||||
sprintf(text_string, "DEVICE-%lu", Object_Instance_Number);
|
||||
snprintf(text, sizeof(text), "DEVICE-%lu",
|
||||
(unsigned long)Object_Instance_Number);
|
||||
|
||||
return text_string;
|
||||
return text;
|
||||
}
|
||||
|
||||
bool Device_Object_Name(
|
||||
|
||||
Reference in New Issue
Block a user