From b3f0ef2d741bfcc4174fbdbccdeeca403fd7ca17 Mon Sep 17 00:00:00 2001 From: skarg Date: Wed, 20 Jun 2007 21:21:26 +0000 Subject: [PATCH] Added casts to remove warnings on IAR compiler. --- bacnet-stack/bacenum.h | 3 ++- bacnet-stack/dcc.c | 2 +- bacnet-stack/demo/object/bo.c | 10 +++++----- bacnet-stack/demo/object/bv.c | 10 +++++----- bacnet-stack/demo/object/device.c | 13 +++++++------ bacnet-stack/npdu.c | 12 +++++++----- bacnet-stack/rd.c | 2 +- bacnet-stack/rp.c | 8 ++++---- bacnet-stack/wp.c | 6 +++--- 9 files changed, 35 insertions(+), 31 deletions(-) diff --git a/bacnet-stack/bacenum.h b/bacnet-stack/bacenum.h index 43df30ee..6caa672b 100644 --- a/bacnet-stack/bacenum.h +++ b/bacnet-stack/bacenum.h @@ -1034,9 +1034,10 @@ typedef enum { NETWORK_MESSAGE_INITIALIZE_ROUTING_TABLE = 6, NETWORK_MESSAGE_INITIALIZE_ROUTING_TABLE_ACK = 7, NETWORK_MESSAGE_ESTABLISH_CONNECTION_TO_NETWORK = 8, - NETWORK_MESSAGE_DISCONNECT_CONNECTION_TO_NETWORK = 9 + NETWORK_MESSAGE_DISCONNECT_CONNECTION_TO_NETWORK = 9, /* X'0A' to X'7F': Reserved for use by ASHRAE, */ /* X'80' to X'FF': Available for vendor proprietary messages */ + NETWORK_MESSAGE_INVALID = 0x100 } BACNET_NETWORK_MESSAGE_TYPE; diff --git a/bacnet-stack/dcc.c b/bacnet-stack/dcc.c index 10d6a883..ecc25e9c 100644 --- a/bacnet-stack/dcc.c +++ b/bacnet-stack/dcc.c @@ -184,7 +184,7 @@ int dcc_decode_service_request(uint8_t * apdu, &tag_number, &len_value_type); len += decode_enumerated(&apdu[len], len_value_type, &value); if (enable_disable) - *enable_disable = value; + *enable_disable = (BACNET_COMMUNICATION_ENABLE_DISABLE)value; /* Tag 2: password --optional-- */ if (len < apdu_len) { if (!decode_is_context_tag(&apdu[len], 2)) diff --git a/bacnet-stack/demo/object/bo.c b/bacnet-stack/demo/object/bo.c index a323b33b..31054b09 100644 --- a/bacnet-stack/demo/object/bo.c +++ b/bacnet-stack/demo/object/bo.c @@ -298,7 +298,7 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, (priority != 6 /* reserved */ ) && (value.type.Enumerated >= MIN_BINARY_PV) && (value.type.Enumerated <= MAX_BINARY_PV)) { - level = value.type.Enumerated; + level = (BACNET_BINARY_PV)value.type.Enumerated; object_index = Binary_Output_Instance_To_Index(wp_data-> object_instance); @@ -306,8 +306,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, Binary_Output_Level[object_index][priority] = level; /* Note: you could set the physical output here if we are the highest priority. - However, if Out of Service is TRUE, then don't set the - physical output. This comment may apply to the + However, if Out of Service is TRUE, then don't set the + physical output. This comment may apply to the main loop (i.e. check out of service before changing output) */ status = true; } else if (priority == 6) { @@ -331,8 +331,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, /* Note: you could set the physical output here to the next highest priority, or to the relinquish default if no priorities are set. - However, if Out of Service is TRUE, then don't set the - physical output. This comment may apply to the + However, if Out of Service is TRUE, then don't set the + physical output. This comment may apply to the main loop (i.e. check out of service before changing output) */ status = true; } else { diff --git a/bacnet-stack/demo/object/bv.c b/bacnet-stack/demo/object/bv.c index b915d8dc..7ebec87d 100644 --- a/bacnet-stack/demo/object/bv.c +++ b/bacnet-stack/demo/object/bv.c @@ -295,7 +295,7 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, (priority != 6 /* reserved */ ) && (value.type.Enumerated >= MIN_BINARY_PV) && (value.type.Enumerated <= MAX_BINARY_PV)) { - level = value.type.Enumerated; + level = (BACNET_BINARY_PV)value.type.Enumerated; object_index = Binary_Value_Instance_To_Index(wp_data-> object_instance); @@ -303,8 +303,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, Binary_Value_Level[object_index][priority] = level; /* Note: you could set the physical output here if we are the highest priority. - However, if Out of Service is TRUE, then don't set the - physical output. This comment may apply to the + However, if Out of Service is TRUE, then don't set the + physical output. This comment may apply to the main loop (i.e. check out of service before changing output) */ status = true; } else if (priority == 6) { @@ -328,8 +328,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, /* Note: you could set the physical output here to the next highest priority, or to the relinquish default if no priorities are set. - However, if Out of Service is TRUE, then don't set the - physical output. This comment may apply to the + However, if Out of Service is TRUE, then don't set the + physical output. This comment may apply to the main loop (i.e. check out of service before changing output) */ status = true; } else { diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index ab4a0c9a..55087674 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -47,8 +47,8 @@ #include "bacfile.h" /* object list dependency */ #endif -/* note: you really only need to define variables for - properties that are writable or that may change. +/* note: you really only need to define variables for + properties that are writable or that may change. The properties that are constant can be hard coded into the read-property encoding. */ static uint32_t Object_Instance_Number = 0; @@ -131,7 +131,7 @@ bool Device_Set_Object_Name(const char *name, size_t length) bool status = false; /*return value */ /* FIXME: All the object names in a device must be unique. - Disallow setting the Device Object Name to any objects in + Disallow setting the Device Object Name to any objects in the device. */ if (length < sizeof(Object_Name)) { memmove(Object_Name, name, length); @@ -570,7 +570,7 @@ char *Device_Valid_Object_Id(int object_type, uint32_t object_instance) return name; } -/* return the length of the apdu encoded or -1 for error or +/* return the length of the apdu encoded or -1 for error or -2 for abort message */ int Device_Encode_Property_APDU(uint8_t * apdu, BACNET_PROPERTY_ID property, @@ -670,7 +670,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu, for (i = 0; i < MAX_BACNET_SERVICES_SUPPORTED; i++) { /* automatic lookup based on handlers set */ bitstring_set_bit(&bit_string, (uint8_t) i, - apdu_service_supported(i)); + apdu_service_supported((BACNET_SERVICES_SUPPORTED)i)); } apdu_len = encode_tagged_bitstring(&apdu[0], &bit_string); break; @@ -858,7 +858,8 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, case PROP_SYSTEM_STATUS: if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) { - Device_Set_System_Status(value.type.Enumerated); + /* FIXME: bounds check? */ + Device_Set_System_Status((BACNET_DEVICE_STATUS)value.type.Enumerated); status = true; } else { *error_class = ERROR_CLASS_PROPERTY; diff --git a/bacnet-stack/npdu.c b/bacnet-stack/npdu.c index 03a37f61..f1aeacf0 100644 --- a/bacnet-stack/npdu.c +++ b/bacnet-stack/npdu.c @@ -196,7 +196,7 @@ void npdu_encode_npdu_data(BACNET_NPDU_DATA * npdu_data, npdu_data->data_expecting_reply = data_expecting_reply; npdu_data->protocol_version = BACNET_PROTOCOL_VERSION; npdu_data->network_layer_message = false; /* false if APDU */ - npdu_data->network_message_type = 0; /* optional */ + npdu_data->network_message_type = NETWORK_MESSAGE_INVALID; /* optional */ npdu_data->vendor_id = 0; /* optional, if net message type is > 0x80 */ npdu_data->priority = priority; npdu_data->hop_count = 0; @@ -239,7 +239,7 @@ int npdu_decode(uint8_t * npdu, /* B'10' = Critical Equipment message */ /* B'01' = Urgent message */ /* B'00' = Normal message */ - npdu_data->priority = npdu[1] & 0x03; + npdu_data->priority = (BACNET_MESSAGE_PRIORITY)(npdu[1] & 0x03); /* set the offset to where the optional stuff starts */ len = 2; /*Bit 5: Destination specifier where: */ @@ -310,14 +310,16 @@ int npdu_decode(uint8_t * npdu, /* Indicates that the NSDU conveys a network layer message. */ /* Message Type field is present. */ if (npdu_data->network_layer_message) { - npdu_data->network_message_type = npdu[len++]; + npdu_data->network_message_type = (BACNET_NETWORK_MESSAGE_TYPE)npdu[len++]; /* Message Type field contains a value in the range 0x80 - 0xFF, */ /* then a Vendor ID field shall be present */ if (npdu_data->network_message_type >= 0x80) len += decode_unsigned16(&npdu[len], &npdu_data->vendor_id); - } else - npdu_data->network_message_type = 0; + } else { + /* FIXME: another value for this? */ + npdu_data->network_message_type = NETWORK_MESSAGE_INVALID; + } } return len; diff --git a/bacnet-stack/rd.c b/bacnet-stack/rd.c index f814471d..001fb206 100644 --- a/bacnet-stack/rd.c +++ b/bacnet-stack/rd.c @@ -84,7 +84,7 @@ int rd_decode_service_request(uint8_t * apdu, &tag_number, &len_value_type); len += decode_enumerated(&apdu[len], len_value_type, &value); if (state) - *state = value; + *state = (BACNET_REINITIALIZED_STATE)value; /* Tag 1: password - optional */ if (len < apdu_len) { if (!decode_is_context_tag(&apdu[len], 1)) diff --git a/bacnet-stack/rp.c b/bacnet-stack/rp.c index d26613d3..4780a37b 100644 --- a/bacnet-stack/rp.c +++ b/bacnet-stack/rp.c @@ -84,14 +84,14 @@ int rp_decode_service_request(uint8_t * apdu, if (!decode_is_context_tag(&apdu[len++], 0)) return -1; len += decode_object_id(&apdu[len], &type, &data->object_instance); - data->object_type = type; + data->object_type = (BACNET_OBJECT_TYPE)type; /* Tag 1: Property ID */ len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); if (tag_number != 1) return -1; len += decode_enumerated(&apdu[len], len_value_type, &property); - data->object_property = property; + data->object_property = (BACNET_PROPERTY_ID)property; /* Tag 2: Optional Array Index */ if (len < apdu_len) { len += decode_tag_number_and_value(&apdu[len], &tag_number, @@ -157,14 +157,14 @@ int rp_ack_decode_service_request(uint8_t * apdu, int apdu_len, /* total length return -1; len = 1; len += decode_object_id(&apdu[len], &object, &data->object_instance); - data->object_type = object; + data->object_type = (BACNET_OBJECT_TYPE)object; /* Tag 1: Property ID */ len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); if (tag_number != 1) return -1; len += decode_enumerated(&apdu[len], len_value_type, &property); - data->object_property = property; + data->object_property = (BACNET_PROPERTY_ID)property; /* Tag 2: Optional Array Index */ tag_len = decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); diff --git a/bacnet-stack/wp.c b/bacnet-stack/wp.c index 7499f757..800fcf45 100644 --- a/bacnet-stack/wp.c +++ b/bacnet-stack/wp.c @@ -105,14 +105,14 @@ int wp_decode_service_request(uint8_t * apdu, if (!decode_is_context_tag(&apdu[len++], 0)) return -1; len += decode_object_id(&apdu[len], &type, &data->object_instance); - data->object_type = type; + data->object_type = (BACNET_OBJECT_TYPE)type; /* Tag 1: Property ID */ len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); if (tag_number != 1) return -1; len += decode_enumerated(&apdu[len], len_value_type, &property); - data->object_property = property; + data->object_property = (BACNET_PROPERTY_ID)property; /* Tag 2: Optional Array Index */ /* note: decode without incrementing len so we can check for opening tag */ tag_len = decode_tag_number_and_value(&apdu[len], @@ -129,7 +129,7 @@ int wp_decode_service_request(uint8_t * apdu, return -1; /* determine the length of the data blob */ data->application_data_len = bacapp_data_len(&apdu[len], - apdu_len - len, property); + apdu_len - len, (BACNET_PROPERTY_ID)property); /* a tag number of 3 is not extended so only one octet */ len++; /* copy the data from the APDU */