Added scanf bit-width modifiers due to ccpcheck warnings.
This commit is contained in:
@@ -206,10 +206,10 @@ static void address_file_init(
|
|||||||
long device_id = 0;
|
long device_id = 0;
|
||||||
int snet = 0;
|
int snet = 0;
|
||||||
unsigned max_apdu = 0;
|
unsigned max_apdu = 0;
|
||||||
unsigned mac[6];
|
unsigned mac[6] = {0};
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char mac_string[80], sadr_string[80];
|
char mac_string[80] = {""}, sadr_string[80] = {""};
|
||||||
BACNET_ADDRESS src;
|
BACNET_ADDRESS src = {0};
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
pFile = fopen(pFilename, "r");
|
pFile = fopen(pFilename, "r");
|
||||||
@@ -217,10 +217,11 @@ static void address_file_init(
|
|||||||
while (fgets(line, (int) sizeof(line), pFile) != NULL) {
|
while (fgets(line, (int) sizeof(line), pFile) != NULL) {
|
||||||
/* ignore comments */
|
/* ignore comments */
|
||||||
if (line[0] != ';') {
|
if (line[0] != ';') {
|
||||||
if (sscanf(line, "%ld %s %d %s %u", &device_id, &mac_string[0],
|
if (sscanf(line, "%7ld %79s %5d %79s %4u", &device_id,
|
||||||
&snet, &sadr_string[0], &max_apdu) == 5) {
|
&mac_string[0], &snet, &sadr_string[0],
|
||||||
|
&max_apdu) == 5) {
|
||||||
count =
|
count =
|
||||||
sscanf(mac_string, "%x:%x:%x:%x:%x:%x", &mac[0],
|
sscanf(mac_string, "%2x:%2x:%2x:%2x:%2x:%2x", &mac[0],
|
||||||
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
|
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
|
||||||
src.mac_len = (uint8_t) count;
|
src.mac_len = (uint8_t) count;
|
||||||
for (index = 0; index < MAX_MAC_LEN; index++) {
|
for (index = 0; index < MAX_MAC_LEN; index++) {
|
||||||
@@ -229,7 +230,7 @@ static void address_file_init(
|
|||||||
src.net = (uint16_t) snet;
|
src.net = (uint16_t) snet;
|
||||||
if (snet) {
|
if (snet) {
|
||||||
count =
|
count =
|
||||||
sscanf(sadr_string, "%x:%x:%x:%x:%x:%x", &mac[0],
|
sscanf(sadr_string, "%2x:%2x:%2x:%2x:%2x:%2x", &mac[0],
|
||||||
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
|
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
|
||||||
src.len = (uint8_t) count;
|
src.len = (uint8_t) count;
|
||||||
for (index = 0; index < MAX_MAC_LEN; index++) {
|
for (index = 0; index < MAX_MAC_LEN; index++) {
|
||||||
|
|||||||
@@ -1407,7 +1407,7 @@ bool bacapp_parse_application_data(
|
|||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_DATE:
|
case BACNET_APPLICATION_TAG_DATE:
|
||||||
count =
|
count =
|
||||||
sscanf(argv, "%d/%d/%d:%d", &year, &month, &day, &wday);
|
sscanf(argv, "%4d/%2d/%2d:%2d", &year, &month, &day, &wday);
|
||||||
if (count == 3) {
|
if (count == 3) {
|
||||||
datetime_set_date(&value->type.Date, (uint16_t) year,
|
datetime_set_date(&value->type.Date, (uint16_t) year,
|
||||||
(uint8_t) month, (uint8_t) day);
|
(uint8_t) month, (uint8_t) day);
|
||||||
@@ -1422,7 +1422,7 @@ bool bacapp_parse_application_data(
|
|||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_TIME:
|
case BACNET_APPLICATION_TAG_TIME:
|
||||||
count =
|
count =
|
||||||
sscanf(argv, "%d:%d:%d.%d", &hour, &min, &sec,
|
sscanf(argv, "%2d:%2d:%2d.%2d", &hour, &min, &sec,
|
||||||
&hundredths);
|
&hundredths);
|
||||||
if (count == 4) {
|
if (count == 4) {
|
||||||
value->type.Time.hour = (uint8_t) hour;
|
value->type.Time.hour = (uint8_t) hour;
|
||||||
@@ -1444,7 +1444,7 @@ bool bacapp_parse_application_data(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||||
count = sscanf(argv, "%d:%d", &object_type, &instance);
|
count = sscanf(argv, "%4d:%7d", &object_type, &instance);
|
||||||
if (count == 2) {
|
if (count == 2) {
|
||||||
value->type.Object_Id.type = (uint16_t) object_type;
|
value->type.Object_Id.type = (uint16_t) object_type;
|
||||||
value->type.Object_Id.instance = instance;
|
value->type.Object_Id.instance = instance;
|
||||||
|
|||||||
Reference in New Issue
Block a user