Fixed some warnings flagged by IAR C-STAT static analysis tool.
This commit is contained in:
@@ -193,13 +193,13 @@ void handler_device_communication_control(
|
||||
len =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (len <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"DeviceCommunicationControl: " "Failed to send PDU (%s)!\n",
|
||||
strerror(errno));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,12 +162,12 @@ void handler_reinitialize_device(
|
||||
len =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (len <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "ReinitializeDevice: Failed to send PDU (%s)!\n",
|
||||
strerror(errno));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -193,13 +193,11 @@ void handler_read_property(
|
||||
bytes_sent =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
|
||||
}
|
||||
#else
|
||||
bytes_sent = bytes_sent;
|
||||
#endif
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -453,11 +453,9 @@ void handler_read_property_multiple(
|
||||
bytes_sent =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Failed to send PDU (%s)!\n", strerror(errno));
|
||||
}
|
||||
#else
|
||||
bytes_sent = bytes_sent;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,13 +136,11 @@ void handler_write_property(
|
||||
bytes_sent =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "WP: Failed to send PDU (%s)!\n", strerror(errno));
|
||||
}
|
||||
#else
|
||||
bytes_sent = bytes_sent;
|
||||
#endif
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -79,13 +79,13 @@ void handler_unrecognized_service(
|
||||
bytes_sent =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent > 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Sent Reject!\n");
|
||||
} else {
|
||||
fprintf(stderr, "Failed to Send Reject (%s)!\n", strerror(errno));
|
||||
}
|
||||
#else
|
||||
bytes_sent = bytes_sent;
|
||||
#endif
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Failed to Send Reject (%s)!\n", strerror(errno));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,13 +103,11 @@ void Send_I_Am(
|
||||
/* send data */
|
||||
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &buffer[0], pdu_len);
|
||||
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n", strerror(errno));
|
||||
}
|
||||
#else
|
||||
bytes_sent = bytes_sent;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/** Encode an I Am message to be unicast directly back to the src.
|
||||
@@ -189,6 +187,6 @@ void Send_I_Am_Unicast(
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n", strerror(errno));
|
||||
#else
|
||||
bytes_sent = bytes_sent;
|
||||
(void)bytes_sent;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -91,12 +91,10 @@ void Send_I_Have(
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Failed to Send I-Have Reply (%s)!\n",
|
||||
strerror(errno));
|
||||
}
|
||||
#else
|
||||
bytes_sent = bytes_sent;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ uint8_t automac_free_address_random(
|
||||
|
||||
count = automac_free_address_count();
|
||||
if (count) {
|
||||
random_count = rand() % count;
|
||||
random_count =(uint8_t)(rand() % count);
|
||||
mac = automac_free_address_mac(random_count);
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ unsigned Device_Count(
|
||||
uint32_t Device_Index_To_Instance(
|
||||
unsigned index)
|
||||
{
|
||||
index = index;
|
||||
(void)index;
|
||||
return Object_Instance_Number;
|
||||
}
|
||||
|
||||
@@ -957,7 +957,7 @@ bool Device_Write_Property_Local(
|
||||
break;
|
||||
}
|
||||
/* not using len at this time */
|
||||
len = len;
|
||||
(void)len;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ void dlmstp_automac_hander(
|
||||
bool dlmstp_init(
|
||||
char *ifname)
|
||||
{
|
||||
ifname = ifname;
|
||||
(void)ifname;
|
||||
Ringbuf_Init(&Transmit_Queue, (uint8_t *) & Transmit_Buffer,
|
||||
sizeof(struct mstp_tx_packet), MSTP_TRANSMIT_PACKET_COUNT);
|
||||
Ringbuf_Init(&PDU_Queue, (uint8_t *) & PDU_Buffer,
|
||||
@@ -466,7 +466,7 @@ static void MSTP_Send_Frame(
|
||||
crc8 = CRC_Calc_Header(pkt->buffer[5], crc8);
|
||||
pkt->buffer[6] = data_len % 256;
|
||||
crc8 = CRC_Calc_Header(pkt->buffer[6], crc8);
|
||||
pkt->buffer[7] = ~crc8;
|
||||
pkt->buffer[7] = (uint8_t)(~crc8);
|
||||
pkt->length = 8;
|
||||
if (data_len) {
|
||||
/* calculate CRC for any data */
|
||||
@@ -1214,7 +1214,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* a proprietary frame that expects a reply is received. */
|
||||
case MSTP_MASTER_STATE_ANSWER_DATA_REQUEST:
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Peek(&PDU_Queue);
|
||||
if (pkt != NULL) {
|
||||
if (pkt) {
|
||||
matched =
|
||||
dlmstp_compare_data_expecting_reply(&InputBuffer[0],
|
||||
DataLength, SourceAddress, &pkt->buffer[0], pkt->length,
|
||||
@@ -1243,7 +1243,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
MSTP_Flag.ReceivedValidFrame = false;
|
||||
/* clear the queue */
|
||||
(void) Ringbuf_Pop(&PDU_Queue, NULL);
|
||||
} else if (rs485_silence_elapsed(Treply_delay) || (pkt != NULL)) {
|
||||
} else if (rs485_silence_elapsed(Treply_delay) || pkt) {
|
||||
/* DeferredReply */
|
||||
/* If no reply will be available from the higher layers */
|
||||
/* within Treply_delay after the reception of the */
|
||||
|
||||
@@ -86,7 +86,11 @@ static uint16_t rs485_turnaround_time(
|
||||
/* delay after reception before transmitting - per MS/TP spec */
|
||||
/* wait a minimum 40 bit times since reception */
|
||||
/* at least 2 ms for errors: rounding, clock tick */
|
||||
return (2 + ((Tturnaround * 1000UL) / Baud_Rate));
|
||||
if (Baud_Rate) {
|
||||
return (2 + ((Tturnaround * 1000UL) / Baud_Rate));
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
@@ -378,8 +378,8 @@ void apdu_retries_set(
|
||||
/* When network communications are completely disabled,
|
||||
only DeviceCommunicationControl and ReinitializeDevice APDUs
|
||||
shall be processed and no messages shall be initiated.
|
||||
When the initiation of communications is disabled,
|
||||
all APDUs shall be processed and responses returned as
|
||||
When the initiation of communications is disabled,
|
||||
all APDUs shall be processed and responses returned as
|
||||
required... */
|
||||
static bool apdu_confirmed_dcc_disabled(
|
||||
uint8_t service_choice)
|
||||
@@ -413,7 +413,7 @@ static bool apdu_unconfirmed_dcc_disabled(
|
||||
bool status = false;
|
||||
|
||||
if (dcc_communication_disabled()) {
|
||||
/* there are no Unconfirmed messages that
|
||||
/* there are no Unconfirmed messages that
|
||||
can be processed in this state */
|
||||
status = true;
|
||||
} else if (dcc_communication_initiation_disabled()) {
|
||||
@@ -462,8 +462,7 @@ void apdu_handler(
|
||||
/* PDU Type */
|
||||
switch (apdu[0] & 0xF0) {
|
||||
case PDU_TYPE_CONFIRMED_SERVICE_REQUEST:
|
||||
len =
|
||||
(int) apdu_decode_confirmed_service_request(&apdu[0],
|
||||
apdu_decode_confirmed_service_request(&apdu[0],
|
||||
apdu_len, &service_data, &service_choice, &service_request,
|
||||
&service_request_len);
|
||||
if (apdu_confirmed_dcc_disabled(service_choice)) {
|
||||
|
||||
@@ -292,7 +292,9 @@ int bacapp_decode_data(
|
||||
(tag_data_type != BACNET_APPLICATION_TAG_BOOLEAN) &&
|
||||
(tag_data_type != BACNET_APPLICATION_TAG_OCTET_STRING)) {
|
||||
/* indicate that we were not able to decode the value */
|
||||
value->tag = MAX_BACNET_APPLICATION_TAG;
|
||||
if (value) {
|
||||
value->tag = MAX_BACNET_APPLICATION_TAG;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
@@ -309,7 +311,7 @@ int bacapp_decode_application_data(
|
||||
uint32_t len_value_type = 0;
|
||||
|
||||
/* FIXME: use max_apdu_len! */
|
||||
max_apdu_len = max_apdu_len;
|
||||
(void)max_apdu_len;
|
||||
if (apdu && value && !IS_CONTEXT_SPECIFIC(*apdu)) {
|
||||
value->context_specific = false;
|
||||
tag_len =
|
||||
@@ -446,7 +448,7 @@ int bacapp_decode_application_data_len(
|
||||
uint32_t len_value_type = 0;
|
||||
|
||||
/* FIXME: use max_apdu_len! */
|
||||
max_apdu_len = max_apdu_len;
|
||||
(void)max_apdu_len;
|
||||
if (apdu && !IS_CONTEXT_SPECIFIC(*apdu)) {
|
||||
tag_len =
|
||||
decode_tag_number_and_value(&apdu[0], &tag_number,
|
||||
@@ -798,7 +800,7 @@ int bacapp_decode_context_data_len(
|
||||
uint8_t tag = 0;
|
||||
|
||||
/* FIXME: use max_apdu_len! */
|
||||
max_apdu_len = max_apdu_len;
|
||||
(void)max_apdu_len;
|
||||
if (apdu && IS_CONTEXT_SPECIFIC(*apdu)) {
|
||||
tag_len =
|
||||
decode_tag_number_and_value(&apdu[0], &tag_number,
|
||||
|
||||
@@ -883,8 +883,10 @@ int encode_octet_string(
|
||||
to bounds check since it might not be the only data chunk */
|
||||
len = (int) octetstring_length(octet_string);
|
||||
value = octetstring_value(octet_string);
|
||||
for (i = 0; i < len; i++) {
|
||||
apdu[i] = value[i];
|
||||
if (value) {
|
||||
for (i = 0; i < len; i++) {
|
||||
apdu[i] = value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ int rp_decode_service_request(
|
||||
uint32_t array_value = 0; /* for decoding */
|
||||
|
||||
/* check for value pointers */
|
||||
if (rpdata != NULL) {
|
||||
if (rpdata) {
|
||||
/* Must have at least 2 tags, an object id and a property identifier
|
||||
* of at least 1 byte in length to have any chance of parsing */
|
||||
if (apdu_len < 7) {
|
||||
@@ -142,7 +142,9 @@ int rp_decode_service_request(
|
||||
|
||||
if (len < apdu_len) {
|
||||
/* If something left over now, we have an invalid request */
|
||||
rpdata->error_code = ERROR_CODE_REJECT_TOO_MANY_ARGUMENTS;
|
||||
if (rpdata) {
|
||||
rpdata->error_code = ERROR_CODE_REJECT_TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user