Refactored all the sprintf to use snprintf instead. (#628)
This commit is contained in:
@@ -66,11 +66,11 @@ uint32_t Analog_Input_Index_To_Instance(unsigned index)
|
||||
|
||||
char *Analog_Input_Name(uint32_t object_instance)
|
||||
{
|
||||
static char text_string[16] = ""; /* okay for single thread */
|
||||
static char text[16] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_ANALOG_INPUTS) {
|
||||
sprintf(text_string, "AI-%lu", (unsigned long)object_instance);
|
||||
return text_string;
|
||||
snprintf(text, sizeof(text), "AI-%lu", (unsigned long)object_instance);
|
||||
return text;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -131,11 +131,11 @@ float Analog_Value_Present_Value(uint32_t object_instance)
|
||||
/* note: the object name must be unique within this device */
|
||||
char *Analog_Value_Name(uint32_t object_instance)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
static char text[32] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_ANALOG_VALUES) {
|
||||
sprintf(text_string, "AV-%lu", object_instance);
|
||||
return text_string;
|
||||
snprintf(text, sizeof(text), "AV-%lu", (unsigned long)object_instance);
|
||||
return text;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -103,11 +103,11 @@ BACNET_BINARY_PV Binary_Input_Present_Value(uint32_t object_instance)
|
||||
|
||||
char *Binary_Input_Name(uint32_t object_instance)
|
||||
{
|
||||
static char text_string[16] = ""; /* okay for single thread */
|
||||
static char text[16] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_BINARY_INPUTS) {
|
||||
sprintf(text_string, "BI-%lu", object_instance);
|
||||
return text_string;
|
||||
snprintf(text, sizeof(text), "BI-%lu", (unsigned long)object_instance);
|
||||
return text;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -100,11 +100,11 @@ BACNET_BINARY_PV Binary_Value_Present_Value(uint32_t object_instance)
|
||||
/* note: the object name must be unique within this device */
|
||||
char *Binary_Value_Name(uint32_t object_instance)
|
||||
{
|
||||
static char text_string[16] = ""; /* okay for single thread */
|
||||
static char text[16] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_BINARY_VALUES) {
|
||||
sprintf(text_string, "BV-%lu", object_instance);
|
||||
return text_string;
|
||||
snprintf(text, sizeof(text), "BV-%lu", (unsigned long)object_instance);
|
||||
return text;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user