Fix (most) compilation warnings in Intel C++ Compiler (#38)

* Use BACNET_OBJECT_TYPE for all object type variables.

* Fix ICC "mixing enumerated type" warnings for assignments and parameters.

* Network Port: Use enums for state structs and remove erroneous bounds checks copy-pasted from IP_Subnet_Prefix setter.

* Fix ICC "unreachable statement" warnings.

* Fix ICC "unused variable" warnings when printing is disabled.

* Fix ICC "mixing enumerated type" warnings for struct initializers { 0 } by ensuring the first member is an integer type.

* Send_GetEvent_Global: Return 0 (invalid TSM invoke ID) instead of -1 = 255 (technically valid invoke ID) on failure.

* Fix ICC "pointless comparison" warnings.

* Fix wrong import in objects.c (memset being used).

* Fix signedness warnings and inconsistencies. Include -1 = 255 check in cov_address_get().

* Add some guards for BACAPP_LIGHTING_COMMAND to avoid errors/warnings.

* RPM test fixes

* Address requested changes. (#38)
This commit is contained in:
Geert Linders
2020-01-23 15:18:47 +01:00
committed by Steve Karg
parent 76abcaedd1
commit f8ce70470c
92 changed files with 438 additions and 263 deletions
+8 -6
View File
@@ -190,7 +190,7 @@ bool Access_Door_Present_Value_Set(
index = Access_Door_Instance_To_Index(object_instance);
if (index < MAX_ACCESS_DOORS) {
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
(priority != 6 /* reserved */) && (value >= DOOR_VALUE_LOCK) &&
(priority != 6 /* reserved */) &&
(value <= DOOR_VALUE_EXTENDED_PULSE_UNLOCK)) {
ad_descr[index].value_active[priority - 1] = true;
ad_descr[index].priority_array[priority - 1] = value;
@@ -233,7 +233,7 @@ bool Access_Door_Present_Value_Relinquish(
BACNET_DOOR_VALUE Access_Door_Relinquish_Default(uint32_t object_instance)
{
BACNET_DOOR_VALUE status = -1;
BACNET_DOOR_VALUE status = DOOR_VALUE_LOCK;
unsigned index = 0;
index = Access_Door_Instance_To_Index(object_instance);
if (index < MAX_ACCESS_DOORS) {
@@ -467,7 +467,7 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
algorithm and may not be used for other purposes in any
object. */
status = Access_Door_Present_Value_Set(wp_data->object_instance,
value.type.Enumerated, wp_data->priority);
(BACNET_DOOR_VALUE)value.type.Enumerated, wp_data->priority);
if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -505,7 +505,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
&wp_data->error_class, &wp_data->error_code);
if (status) {
ad_descr[object_index].door_status = value.type.Enumerated;
ad_descr[object_index].door_status =
(BACNET_DOOR_STATUS)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -518,7 +519,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
&wp_data->error_class, &wp_data->error_code);
if (status) {
ad_descr[object_index].lock_status = value.type.Enumerated;
ad_descr[object_index].lock_status =
(BACNET_LOCK_STATUS)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -532,7 +534,7 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
&wp_data->error_class, &wp_data->error_code);
if (status) {
ad_descr[object_index].door_alarm_state =
value.type.Enumerated;
(BACNET_DOOR_ALARM_STATE)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+2 -1
View File
@@ -315,7 +315,8 @@ bool Access_Zone_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
&wp_data->error_class, &wp_data->error_code);
if (status) {
az_descr[object_index].reliability = value.type.Enumerated;
az_descr[object_index].reliability =
(BACNET_RELIABILITY)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+3
View File
@@ -1105,6 +1105,9 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL]
.Time_Stamp = event_data.timeStamp.value.dateTime;
break;
default: /* shouldn't happen */
break;
}
}
}
+3
View File
@@ -1111,6 +1111,9 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL]
.Time_Stamp = event_data.timeStamp.value.dateTime;
break;
default: /* shouldn't happen */
break;
}
}
}
+5 -5
View File
@@ -232,14 +232,14 @@ unsigned Channel_Last_Priority(uint32_t object_instance)
BACNET_WRITE_STATUS Channel_Write_Status(uint32_t object_instance)
{
unsigned index = 0;
unsigned priority = 0;
BACNET_WRITE_STATUS write_status = BACNET_WRITE_STATUS_IDLE;
index = Channel_Instance_To_Index(object_instance);
if (index < BACNET_CHANNELS_MAX) {
priority = Channel[index].Write_Status;
write_status = Channel[index].Write_Status;
}
return priority;
return write_status;
}
/**
@@ -451,12 +451,12 @@ unsigned Channel_Reference_List_Member_Element_Add(uint32_t object_instance,
* zero if not added
*/
unsigned Channel_Reference_List_Member_Local_Add(uint32_t object_instance,
uint16_t type,
BACNET_OBJECT_TYPE type,
uint32_t instance,
BACNET_PROPERTY_ID propertyIdentifier,
uint32_t arrayIndex)
{
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE member = { { 0 } };
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE member = { 0 };
member.objectIdentifier.type = type;
member.objectIdentifier.instance = instance;
+1 -1
View File
@@ -166,7 +166,7 @@ extern "C" {
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *pMemberSrc);
unsigned Channel_Reference_List_Member_Local_Add(
uint32_t object_instance,
uint16_t type,
BACNET_OBJECT_TYPE type,
uint32_t instance,
BACNET_PROPERTY_ID propertyIdentifier,
uint32_t arrayIndex);
@@ -562,7 +562,7 @@ unsigned Device_Object_List_Count(void)
* @return True if found, else false.
*/
bool Device_Object_List_Identifier(
uint32_t array_index, int *object_type, uint32_t *instance)
uint32_t array_index, BACNET_OBJECT_TYPE *object_type, uint32_t *instance)
{
bool status = false;
unsigned count = 0;
@@ -620,11 +620,11 @@ bool Device_Object_List_Identifier(
* @return True on success or else False if not found.
*/
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
int *object_type,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
bool found = false;
int type = 0;
BACNET_OBJECT_TYPE type = OBJECT_NONE;
uint32_t instance;
uint32_t max_objects = 0, i = 0;
bool check_id = false;
@@ -659,7 +659,8 @@ bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
* @param object_instance [in] The object instance number to be looked up.
* @return True if found, else False if no such Object in this device.
*/
bool Device_Valid_Object_Id(int object_type, uint32_t object_instance)
bool Device_Valid_Object_Id
(BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
{
bool status = false; /* return value */
struct object_functions *pObject = NULL;
@@ -851,7 +852,7 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_BIT_STRING bit_string;
BACNET_CHARACTER_STRING char_string;
uint32_t i = 0;
int object_type = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_NONE;
uint32_t instance = 0;
uint32_t count = 0;
uint8_t *apdu = NULL;
+4 -3
View File
@@ -50,6 +50,7 @@
#include "bacnet/config.h" /* the custom stuff */
#include "bacnet/basic/object/device.h"
#include "bacnet/basic/services.h"
#include "bacnet/lighting.h"
#include "bacnet/proplist.h"
#include "bacnet/timestamp.h"
#include "bacnet/basic/object/command.h"
@@ -71,8 +72,7 @@ int cl_encode_apdu(uint8_t *apdu, BACNET_ACTION_LIST *bcl)
int len = 0;
int apdu_len = 0;
if (bcl->Device_Id.instance >= 0 &&
bcl->Device_Id.instance <= BACNET_MAX_INSTANCE) {
if (bcl->Device_Id.instance <= BACNET_MAX_INSTANCE) {
len = encode_context_object_id(
&apdu[apdu_len], 0, bcl->Device_Id.type, bcl->Device_Id.instance);
if (len < 0) {
@@ -269,13 +269,14 @@ int cl_decode_apdu(uint8_t *apdu,
&bcl->Value.type.Object_Id.type,
&bcl->Value.type.Object_Id.instance);
break;
#if defined(BACAPP_LIGHTING_COMMAND)
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
len = lighting_command_decode(&apdu[dec_len], apdu_len - dec_len,
&bcl->Value.type.Lighting_Command);
break;
#endif
default:
return BACNET_STATUS_REJECT;
break;
}
if (len > 0) {
dec_len += len;
@@ -337,7 +337,8 @@ bool Credential_Data_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
&wp_data->error_class, &wp_data->error_code);
if (status) {
cdi_descr[object_index].reliability = value.type.Enumerated;
cdi_descr[object_index].reliability =
(BACNET_RELIABILITY)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+11 -9
View File
@@ -216,7 +216,7 @@ static object_functions_t My_Object_Table[] = {
Trend_Log_Write_Property, Trend_Log_Property_Lists, TrendLogGetRRInfo,
NULL /* Iterator */, NULL /* Value_Lists */, NULL /* COV */,
NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
#if (BACNET_PROTOCOL_REVISION >= 14)
#if (BACNET_PROTOCOL_REVISION >= 14) && defined(BACAPP_LIGHTING_COMMAND)
{ OBJECT_LIGHTING_OUTPUT, Lighting_Output_Init, Lighting_Output_Count,
Lighting_Output_Index_To_Instance, Lighting_Output_Valid_Instance,
Lighting_Output_Object_Name, Lighting_Output_Read_Property,
@@ -827,7 +827,7 @@ unsigned Device_Object_List_Count(void)
* @return True if found, else false.
*/
bool Device_Object_List_Identifier(
uint32_t array_index, int *object_type, uint32_t *instance)
uint32_t array_index, BACNET_OBJECT_TYPE *object_type, uint32_t *instance)
{
bool status = false;
uint32_t count = 0;
@@ -885,11 +885,11 @@ bool Device_Object_List_Identifier(
* @return True on success or else False if not found.
*/
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
int *object_type,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
bool found = false;
int type = 0;
BACNET_OBJECT_TYPE type = OBJECT_NONE;
uint32_t instance;
uint32_t max_objects = 0, i = 0;
bool check_id = false;
@@ -924,7 +924,8 @@ bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
* @param object_instance [in] The object instance number to be looked up.
* @return True if found, else False if no such Object in this device.
*/
bool Device_Valid_Object_Id(int object_type, uint32_t object_instance)
bool Device_Valid_Object_Id
(BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
{
bool status = false; /* return value */
struct object_functions *pObject = NULL;
@@ -1072,7 +1073,7 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_BIT_STRING bit_string = { 0 };
BACNET_CHARACTER_STRING char_string = { 0 };
uint32_t i = 0;
int object_type = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_NONE;
uint32_t instance = 0;
uint32_t count = 0;
uint8_t *apdu = NULL;
@@ -1183,7 +1184,8 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
pObject = Object_Table;
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
bitstring_set_bit(
&bit_string, (uint8_t)pObject->Object_Type, true);
}
pObject++;
}
@@ -1361,7 +1363,7 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
bool status = false; /* return value */
int len = 0;
BACNET_APPLICATION_DATA_VALUE value;
int object_type = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_NONE;
uint32_t object_instance = 0;
int result = 0;
#if defined(BACNET_TIME_MASTER)
@@ -1758,7 +1760,7 @@ void Device_local_reporting(void)
struct object_functions *pObject;
uint32_t objects_count;
uint32_t object_instance;
int object_type;
BACNET_OBJECT_TYPE object_type;
uint32_t idx;
objects_count = Device_Object_List_Count();
+3 -3
View File
@@ -279,7 +279,7 @@ extern "C" {
void);
bool Device_Object_List_Identifier(
uint32_t array_index,
int *object_type,
BACNET_OBJECT_TYPE *object_type,
uint32_t * instance);
unsigned Device_Count(
@@ -358,10 +358,10 @@ extern "C" {
bool Device_Valid_Object_Name(
BACNET_CHARACTER_STRING * object_name,
int *object_type,
BACNET_OBJECT_TYPE *object_type,
uint32_t * object_instance);
bool Device_Valid_Object_Id(
int object_type,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance);
int Device_Read_Property(
+3 -3
View File
@@ -112,8 +112,8 @@ uint16_t iCurrent_Device_Idx = 0;
* @param Object_Instance [in] Set the new Device to this instance number.
* @param sObject_Name [in] Use this Object Name for the Device.
* @param sDescription [in] Set this Description for the Device.
* @return The index of this instance in the Devices[] array,
* or -1 if there isn't enough room to add this Device.
* @return The index of this instance in the Devices[] array, or UINT16_MAX if
* there isn't enough room to add this Device.
*/
uint16_t Add_Routed_Device(uint32_t Object_Instance,
BACNET_CHARACTER_STRING *sObject_Name,
@@ -141,7 +141,7 @@ uint16_t Add_Routed_Device(uint32_t Object_Instance,
pDev->Database_Revision = 0; /* Reset/Initialize now */
return i;
} else {
return -1;
return UINT16_MAX;
}
}
+1 -1
View File
@@ -330,7 +330,7 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
object_index = Life_Safety_Point_Instance_To_Index(
wp_data->object_instance);
Life_Safety_Point_Mode[object_index] =
value.type.Enumerated;
(BACNET_LIFE_SAFETY_MODE)value.type.Enumerated;
} else {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
+1 -1
View File
@@ -581,7 +581,7 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
BACNET_APPLICATION_DATA_VALUE value;
uint32_t max_states = 0;
uint32_t array_index = 0;
int object_type = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_NONE;
uint32_t object_instance = 0;
/* decode the first chunk of the request */
+16 -20
View File
@@ -54,7 +54,7 @@ struct bacnet_ipv4_port {
uint8_t IP_Gateway[4];
uint8_t IP_DNS_Server[BIP_DNS_MAX][4];
uint16_t Port;
uint8_t Mode;
BACNET_IP_MODE Mode;
bool IP_DHCP_Enable;
uint32_t IP_DHCP_Lease_Seconds;
uint32_t IP_DHCP_Lease_Seconds_Remaining;
@@ -75,7 +75,7 @@ struct bacnet_ipv6_port {
uint8_t IP_Multicast_Address[IPV6_ADDR_SIZE];
uint8_t IP_DHCP_Server[IPV6_ADDR_SIZE];
uint16_t Port;
uint8_t Mode;
BACNET_IP_MODE Mode;
char Zone_Index[ZONE_INDEX_SIZE];
};
@@ -92,12 +92,12 @@ struct mstp_port {
struct object_data {
uint32_t Instance_Number;
char *Object_Name;
uint8_t Reliability;
BACNET_RELIABILITY Reliability;
bool Out_Of_Service : 1;
bool Changes_Pending : 1;
uint8_t Network_Type;
uint16_t Network_Number;
uint8_t Quality;
BACNET_PORT_QUALITY Quality;
uint16_t APDU_Length;
float Link_Speed;
union {
@@ -429,7 +429,7 @@ bool Network_Port_Reliability_Set(
index = Network_Port_Instance_To_Index(object_instance);
if (index < BACNET_NETWORK_PORTS_MAX) {
Object_List[index].Reliability = (uint8_t)value;
Object_List[index].Reliability = value;
status = true;
}
@@ -558,7 +558,7 @@ bool Network_Port_Quality_Set(
index = Network_Port_Instance_To_Index(object_instance);
if (index < BACNET_NETWORK_PORTS_MAX) {
Object_List[index].Quality = (uint8_t)value;
Object_List[index].Quality = value;
status = true;
}
@@ -1182,7 +1182,7 @@ bool Network_Port_BIP_Port_Set(uint32_t object_instance, uint16_t value)
*/
BACNET_IP_MODE Network_Port_BIP_Mode(uint32_t object_instance)
{
BACNET_IP_MODE value = 0;
BACNET_IP_MODE value = BACNET_IP_MODE_NORMAL;
unsigned index = 0;
index = Network_Port_Instance_To_Index(object_instance);
@@ -1212,13 +1212,11 @@ bool Network_Port_BIP_Mode_Set(uint32_t object_instance, BACNET_IP_MODE value)
index = Network_Port_Instance_To_Index(object_instance);
if (index < BACNET_NETWORK_PORTS_MAX) {
if (Object_List[index].Network_Type == PORT_TYPE_BIP) {
if (value <= 32) {
if (Object_List[index].Network.IPv4.Mode != value) {
Object_List[index].Changes_Pending = true;
}
Object_List[index].Network.IPv4.Mode = value;
status = true;
if (Object_List[index].Network.IPv4.Mode != value) {
Object_List[index].Changes_Pending = true;
}
Object_List[index].Network.IPv4.Mode = value;
status = true;
}
}
@@ -1287,7 +1285,7 @@ bool Network_Port_BBMD_Accept_FD_Registrations_Set(
*/
BACNET_IP_MODE Network_Port_BIP6_Mode(uint32_t object_instance)
{
BACNET_IP_MODE value = 0;
BACNET_IP_MODE value = BACNET_IP_MODE_NORMAL;
unsigned index = 0;
index = Network_Port_Instance_To_Index(object_instance);
@@ -1317,13 +1315,11 @@ bool Network_Port_BIP6_Mode_Set(uint32_t object_instance, BACNET_IP_MODE value)
index = Network_Port_Instance_To_Index(object_instance);
if (index < BACNET_NETWORK_PORTS_MAX) {
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
if (value <= 32) {
if (Object_List[index].Network.IPv4.Mode != value) {
Object_List[index].Changes_Pending = true;
}
Object_List[index].Network.IPv6.Mode = value;
status = true;
if (Object_List[index].Network.IPv4.Mode != value) {
Object_List[index].Changes_Pending = true;
}
Object_List[index].Network.IPv6.Mode = value;
status = true;
}
}
+1 -1
View File
@@ -35,7 +35,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include "bacnet/basic/sys/keylist.h"
#include "bacnet/basic/object/objects.h"
+2 -1
View File
@@ -545,7 +545,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
&wp_data->error_class, &wp_data->error_code);
if (status) {
if (value.type.Enumerated != LOGGING_TYPE_COV) {
CurrentLog->LoggingType = value.type.Enumerated;
CurrentLog->LoggingType =
(BACNET_LOGGING_TYPE)value.type.Enumerated;
if (value.type.Enumerated == LOGGING_TYPE_POLLED) {
/* As per 12.25.27 pick a suitable default if interval
* is 0 */