Bugfix/fix splint warnings (#250)

* Fix SPLINT to perform static defect analysis

Fix the SPLINT invocation in Makefile
Fix C files where SPLINT detected problems.
Remove UCIX check from SPLINT
Use SPLINT friendly parsing code disable for bacsec

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-04-12 13:00:29 -05:00
committed by GitHub
parent f6fad83f61
commit c9d42d268e
13 changed files with 268 additions and 256 deletions
+7 -7
View File
@@ -592,8 +592,8 @@ int bvlc_send_pdu(BACNET_ADDRESS *dest,
#if BBMD_ENABLED
if (mtu_len > 0) {
bip_get_addr(&bip_src);
bbmd_fdt_forward_npdu(&bip_src, pdu, pdu_len, true);
bbmd_bdt_forward_npdu(&bip_src, pdu, pdu_len, true);
(void)bbmd_fdt_forward_npdu(&bip_src, pdu, pdu_len, true);
(void)bbmd_bdt_forward_npdu(&bip_src, pdu, pdu_len, true);
}
#endif
}
@@ -928,7 +928,7 @@ int bvlc_bbmd_enabled_handler(BACNET_IP_ADDRESS *addr,
/* In addition, the constructed BVLL Forwarded-NPDU
message shall be unicast to each foreign device in
the BBMD's FDT. */
bbmd_fdt_forward_npdu(&fwd_address, mtu, mtu_len, false);
(void)bbmd_fdt_forward_npdu(&fwd_address, mtu, mtu_len, false);
/* prepare the message for me! */
bvlc_ip_address_to_bacnet_local(src, &fwd_address);
offset = header_len + function_len - npdu_len;
@@ -1032,8 +1032,8 @@ int bvlc_bbmd_enabled_handler(BACNET_IP_ADDRESS *addr,
attempt was unsuccessful */
npdu_len = bbmd_forward_npdu(addr, pdu, pdu_len);
if (npdu_len > 0) {
bbmd_fdt_forward_npdu(addr, pdu, pdu_len, false);
bbmd_bdt_forward_npdu(addr, pdu, pdu_len, false);
(void)bbmd_fdt_forward_npdu(addr, pdu, pdu_len, false);
(void)bbmd_bdt_forward_npdu(addr, pdu, pdu_len, false);
} else {
result_code = BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK;
send_result = true;
@@ -1099,8 +1099,8 @@ int bvlc_bbmd_enabled_handler(BACNET_IP_ADDRESS *addr,
"Original-Broadcast-NPDU: "
"Confirmed Service! Discard!");
} else {
bbmd_fdt_forward_npdu(addr, npdu, npdu_len, true);
bbmd_bdt_forward_npdu(addr, npdu, npdu_len, true);
(void)bbmd_fdt_forward_npdu(addr, npdu, npdu_len, true);
(void)bbmd_bdt_forward_npdu(addr, npdu, npdu_len, true);
debug_print_npdu("Original-Broadcast-NPDU",
offset, npdu_len);
}
+3 -2
View File
@@ -181,18 +181,19 @@ static bool bbmd6_add_vmac(uint32_t device_id, BACNET_IP6_ADDRESS *addr)
bool status = false;
struct vmac_data *vmac;
struct vmac_data new_vmac;
unsigned i = 0;
if (addr) {
vmac = VMAC_Find_By_Key(device_id);
if (vmac) {
/* already exists - replace? */
PRINTF("VMAC existing %u [", (unsigned int)device_id);
for (unsigned i = 0; i < vmac->mac_len; i++) {
for (i = 0; i < vmac->mac_len; i++) {
PRINTF("%02X", vmac->mac[i]);
}
PRINTF("]\n");
PRINTF("VMAC ignoring %u [", (unsigned int)device_id);
for (unsigned i = 0; i < IP6_ADDRESS_MAX; i++) {
for (i = 0; i < IP6_ADDRESS_MAX; i++) {
PRINTF("%02X", addr->address[i]);
}
PRINTF("%04X", addr->port);
+2 -1
View File
@@ -258,6 +258,7 @@ void VMAC_Cleanup(void)
struct vmac_data *pVMAC;
uint32_t device_id;
const int index = 0;
unsigned i = 0;
if (VMAC_List) {
do {
@@ -266,7 +267,7 @@ void VMAC_Cleanup(void)
if (pVMAC) {
PRINTF("VMAC List: %lu [", (unsigned long)device_id);
/* print the MAC */
for (unsigned i = 0; i < pVMAC->mac_len; i++) {
for (i = 0; i < pVMAC->mac_len; i++) {
PRINTF("%02X", pVMAC->mac[i]);
}
PRINTF("]\n");
+2 -2
View File
@@ -238,10 +238,10 @@ bool Analog_Input_Object_Name(
*/
unsigned Analog_Input_Event_State(uint32_t object_instance)
{
unsigned index = 0;
unsigned state = EVENT_STATE_NORMAL;
#if defined(INTRINSIC_REPORTING)
unsigned index = 0;
index = Analog_Input_Instance_To_Index(object_instance);
if (index < MAX_ANALOG_INPUTS) {
state = AI_Descr[index].Event_State;
+4 -3
View File
@@ -154,7 +154,7 @@ float Analog_Output_Present_Value(uint32_t object_instance)
if (index < MAX_ANALOG_OUTPUTS) {
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
if (Analog_Output_Level[index][i] != AO_LEVEL_NULL) {
value = Analog_Output_Level[index][i];
value = (float)Analog_Output_Level[index][i];
break;
}
}
@@ -342,7 +342,8 @@ int Analog_Output_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
if (Analog_Output_Level[object_index][i] == AO_LEVEL_NULL) {
len = encode_application_null(&apdu[apdu_len]);
} else {
real_value = Analog_Output_Level[object_index][i];
real_value =
(float)Analog_Output_Level[object_index][i];
len = encode_application_real(
&apdu[apdu_len], real_value);
}
@@ -365,7 +366,7 @@ int Analog_Output_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
apdu_len = encode_application_null(&apdu[0]);
} else {
real_value =
Analog_Output_Level[object_index]
(float)Analog_Output_Level[object_index]
[rpdata->array_index - 1];
apdu_len =
encode_application_real(&apdu[0], real_value);
+2 -2
View File
@@ -299,10 +299,10 @@ bool Analog_Value_Object_Name(
*/
unsigned Analog_Value_Event_State(uint32_t object_instance)
{
unsigned index = 0;
unsigned state = EVENT_STATE_NORMAL;
#if defined(INTRINSIC_REPORTING)
unsigned index = 0;
index = Analog_Value_Instance_To_Index(object_instance);
if (index < MAX_ANALOG_VALUES) {
state = AV_Descr[index].Event_State;
+11 -11
View File
@@ -850,7 +850,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
apdu_len = BACNET_STATUS_ERROR;
}
} else if (tag == BACNET_APPLICATION_TAG_DOUBLE) {
double_value = value->type.Unsigned_Int;
double_value = (double)value->type.Unsigned_Int;
apdu_len =
encode_application_double(&apdu[0], double_value);
} else if (tag == BACNET_APPLICATION_TAG_ENUMERATED) {
@@ -892,7 +892,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
apdu_len = BACNET_STATUS_ERROR;
}
} else if (tag == BACNET_APPLICATION_TAG_DOUBLE) {
double_value = value->type.Signed_Int;
double_value = (double)value->type.Signed_Int;
apdu_len =
encode_application_double(&apdu[0], double_value);
} else if (tag == BACNET_APPLICATION_TAG_ENUMERATED) {
@@ -907,14 +907,14 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
#if defined(BACAPP_REAL)
case BACNET_APPLICATION_TAG_REAL:
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
if (value->type.Real) {
if (value->type.Real != 0.0F) {
boolean_value = true;
}
apdu_len =
encode_application_boolean(&apdu[0], boolean_value);
} else if (tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
if ((value->type.Real >= 0.0) &&
(value->type.Real <= 2147483000.0)) {
if ((value->type.Real >= 0.0F) &&
(value->type.Real <= 2147483000.0F)) {
unsigned_value = (uint32_t)value->type.Real;
apdu_len = encode_application_unsigned(
&apdu[0], unsigned_value);
@@ -922,8 +922,8 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
apdu_len = BACNET_STATUS_ERROR;
}
} else if (tag == BACNET_APPLICATION_TAG_SIGNED_INT) {
if ((value->type.Real >= -2147483000.0) &&
(value->type.Real <= 214783000.0)) {
if ((value->type.Real >= -2147483000.0F) &&
(value->type.Real <= 214783000.0F)) {
signed_value = (int32_t)value->type.Real;
apdu_len =
encode_application_signed(&apdu[0], signed_value);
@@ -938,8 +938,8 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
apdu_len =
encode_application_double(&apdu[0], double_value);
} else if (tag == BACNET_APPLICATION_TAG_ENUMERATED) {
if ((value->type.Real >= 0.0) &&
(value->type.Real <= 2147483000.0)) {
if ((value->type.Real >= 0.0F) &&
(value->type.Real <= 2147483000.0F)) {
unsigned_value = (uint32_t)value->type.Real;
apdu_len = encode_application_enumerated(
&apdu[0], unsigned_value);
@@ -954,7 +954,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
#if defined(BACAPP_DOUBLE)
case BACNET_APPLICATION_TAG_DOUBLE:
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
if (value->type.Double) {
if (value->type.Double != 0.0) {
boolean_value = true;
}
apdu_len =
@@ -1033,7 +1033,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
apdu_len = BACNET_STATUS_ERROR;
}
} else if (tag == BACNET_APPLICATION_TAG_DOUBLE) {
double_value = value->type.Enumerated;
double_value = (double)value->type.Enumerated;
apdu_len =
encode_application_double(&apdu[0], double_value);
} else if (tag == BACNET_APPLICATION_TAG_ENUMERATED) {
+1 -1
View File
@@ -333,7 +333,7 @@ int Integer_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_CHARACTER_STRING char_string;
uint8_t *apdu = NULL;
uint32_t units = 0;
int32_t integer_value = 0.0;
int32_t integer_value = 0;
bool state = false;
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
+1 -1
View File
@@ -372,7 +372,7 @@ bool Multistate_Value_Encode_Value_List(
const bool fault = false;
const bool overridden = false;
bool out_of_service = false;
uint32_t present_value = 0.0;
uint32_t present_value = 0;
unsigned index = 0;
index = Multistate_Value_Instance_To_Index(object_instance);