From f7d549dec6a729cf419194c25983a1266286eda7 Mon Sep 17 00:00:00 2001 From: skarg Date: Tue, 12 Dec 2006 15:45:01 +0000 Subject: [PATCH] Cleaned up warnings from Visual C++ 6.0 compile by adding casts. --- bacnet-stack/bacapp.c | 2 +- bacnet-stack/config.h | 4 ++-- bacnet-stack/demo/handler/h_rp_a.c | 3 ++- bacnet-stack/demo/handler/s_rp.c | 2 +- bacnet-stack/demo/handler/s_wp.c | 2 +- bacnet-stack/demo/object/ai.c | 4 ++-- bacnet-stack/demo/object/ao.c | 2 +- bacnet-stack/demo/object/av.c | 2 +- bacnet-stack/demo/object/bacfile.c | 3 +-- bacnet-stack/demo/object/mso.c | 4 ++-- bacnet-stack/npdu.c | 4 ++-- bacnet-stack/wp.c | 3 ++- 12 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bacnet-stack/bacapp.c b/bacnet-stack/bacapp.c index 07eac39e..a6c396d6 100644 --- a/bacnet-stack/bacapp.c +++ b/bacnet-stack/bacapp.c @@ -348,7 +348,7 @@ bool bacapp_print_value(FILE * stream, for (i = 0; i < len; i++) { fprintf(stream, "%s", bitstring_bit(&value->type.Bit_String, - i) ? "true" : "false"); + (uint8_t)i) ? "true" : "false"); if (i < len - 1) fprintf(stream, ","); } diff --git a/bacnet-stack/config.h b/bacnet-stack/config.h index 4cb16690..1c0233f3 100644 --- a/bacnet-stack/config.h +++ b/bacnet-stack/config.h @@ -12,8 +12,8 @@ /* This is used in constructing messages and to tell others our limits */ /* 50 is the minimum; adjust to your memory and physical layer constraints */ /* Lon=206, MS/TP=480, ARCNET=480, Ethernet=1476 */ -/* #define MAX_APDU 50 */ -#define MAX_APDU 480 +#define MAX_APDU 50 +/* #define MAX_APDU 480 */ /* #define MAX_APDU 1476 */ /* for confirmed messages, this is the number of transactions */ diff --git a/bacnet-stack/demo/handler/h_rp_a.c b/bacnet-stack/demo/handler/h_rp_a.c index d77ebac8..d6e18698 100644 --- a/bacnet-stack/demo/handler/h_rp_a.c +++ b/bacnet-stack/demo/handler/h_rp_a.c @@ -67,10 +67,11 @@ static void PrintReadPropertyData(BACNET_READ_PROPERTY_DATA * data) #endif application_data = data->application_data; application_data_len = data->application_data_len; + /* FIXME: what if application_data_len is bigger than 255? */ /* value? need to loop until all of the len is gone... */ for (;;) { len = bacapp_decode_application_data(application_data, - application_data_len, &value); + (uint8_t)application_data_len, &value); if (first_value && (len < application_data_len)) { first_value = false; fprintf(stdout, "{"); diff --git a/bacnet-stack/demo/handler/s_rp.c b/bacnet-stack/demo/handler/s_rp.c index 19a0472b..f73ce331 100644 --- a/bacnet-stack/demo/handler/s_rp.c +++ b/bacnet-stack/demo/handler/s_rp.c @@ -89,7 +89,7 @@ uint8_t Send_Read_Property_Request(uint32_t device_id, /* destination device */ max_apdu in the address binding table. */ if ((unsigned) pdu_len < max_apdu) { tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, - &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); + &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len); bytes_sent = datalink_send_pdu(&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); diff --git a/bacnet-stack/demo/handler/s_wp.c b/bacnet-stack/demo/handler/s_wp.c index ecec08e7..ab960943 100644 --- a/bacnet-stack/demo/handler/s_wp.c +++ b/bacnet-stack/demo/handler/s_wp.c @@ -92,7 +92,7 @@ uint8_t Send_Write_Property_Request(uint32_t device_id, /* destination device */ max_apdu in the address binding table. */ if ((unsigned) pdu_len < max_apdu) { tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, - &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); + &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len); bytes_sent = datalink_send_pdu(&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); diff --git a/bacnet-stack/demo/object/ai.c b/bacnet-stack/demo/object/ai.c index de6b6b8e..24359472 100644 --- a/bacnet-stack/demo/object/ai.c +++ b/bacnet-stack/demo/object/ai.c @@ -84,7 +84,7 @@ int Analog_Input_Encode_Property_APDU(uint8_t * apdu, int apdu_len = 0; /* return value */ BACNET_BIT_STRING bit_string; BACNET_CHARACTER_STRING char_string; - float value = 3.14; + float value = (float)3.14; (void) array_index; switch (property) { @@ -122,7 +122,7 @@ int Analog_Input_Encode_Property_APDU(uint8_t * apdu, apdu_len = encode_tagged_enumerated(&apdu[0], UNITS_PERCENT); break; case 9997: - apdu_len = encode_tagged_real(&apdu[0], 90.510); + apdu_len = encode_tagged_real(&apdu[0], (float)90.510); break; case 9998: apdu_len = encode_tagged_unsigned(&apdu[0], 90); diff --git a/bacnet-stack/demo/object/ao.c b/bacnet-stack/demo/object/ao.c index 322bc90d..b967885e 100644 --- a/bacnet-stack/demo/object/ao.c +++ b/bacnet-stack/demo/object/ao.c @@ -160,7 +160,7 @@ int Analog_Output_Encode_Property_APDU(uint8_t * apdu, int apdu_len = 0; /* return value */ BACNET_BIT_STRING bit_string; BACNET_CHARACTER_STRING char_string; - float real_value = 1.414; + float real_value = (float)1.414; unsigned object_index = 0; unsigned i = 0; bool state = false; diff --git a/bacnet-stack/demo/object/av.c b/bacnet-stack/demo/object/av.c index 2d077264..5146503b 100644 --- a/bacnet-stack/demo/object/av.c +++ b/bacnet-stack/demo/object/av.c @@ -159,7 +159,7 @@ int Analog_Value_Encode_Property_APDU(uint8_t * apdu, int apdu_len = 0; /* return value */ BACNET_BIT_STRING bit_string; BACNET_CHARACTER_STRING char_string; - float real_value = 1.414; + float real_value = (float)1.414; unsigned object_index = 0; unsigned i = 0; bool state = false; diff --git a/bacnet-stack/demo/object/bacfile.c b/bacnet-stack/demo/object/bacfile.c index 7a1fe001..941de60f 100644 --- a/bacnet-stack/demo/object/bacfile.c +++ b/bacnet-stack/demo/object/bacfile.c @@ -308,7 +308,6 @@ uint32_t bacfile_instance_from_tsm(uint8_t invokeID) BACNET_ATOMIC_READ_FILE_DATA data = { 0 }; uint32_t object_instance = BACNET_MAX_INSTANCE + 1; /* return value */ bool found = false; - int apdu_offset = 0; found = tsm_get_transaction_pdu(invokeID, &dest, &npdu_data, &apdu[0], &apdu_len); @@ -318,7 +317,7 @@ uint32_t bacfile_instance_from_tsm(uint8_t invokeID) && (apdu[0] == PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) { len = apdu_decode_confirmed_service_request(&apdu[0], - apdu_len - apdu_offset, &service_data, &service_choice, + apdu_len, &service_data, &service_choice, &service_request, &service_request_len); if (service_choice == SERVICE_CONFIRMED_ATOMIC_READ_FILE) { len = arf_decode_service_request(service_request, diff --git a/bacnet-stack/demo/object/mso.c b/bacnet-stack/demo/object/mso.c index e7d3e74b..e052ddcc 100644 --- a/bacnet-stack/demo/object/mso.c +++ b/bacnet-stack/demo/object/mso.c @@ -305,7 +305,7 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, Multistate_Output_Instance_To_Index(wp_data-> object_instance); priority--; - Multistate_Output_Level[object_index][priority] = level; + Multistate_Output_Level[object_index][priority] = (uint8_t)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 @@ -330,7 +330,7 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, priority = wp_data->priority; if (priority && (priority <= BACNET_MAX_PRIORITY)) { priority--; - Multistate_Output_Level[object_index][priority] = level; + Multistate_Output_Level[object_index][priority] = (uint8_t)level; /* Note: you could set the physical output here to the next highest priority, or to the relinquish default if no priorities are set. diff --git a/bacnet-stack/npdu.c b/bacnet-stack/npdu.c index 762b7114..de925f39 100644 --- a/bacnet-stack/npdu.c +++ b/bacnet-stack/npdu.c @@ -334,10 +334,10 @@ void npdu_handler(BACNET_ADDRESS * src, /* source address */ apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data); if (npdu_data.network_layer_message) { /*FIXME: network layer message received! Handle it! */ - } else { + } else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) { /* only handle the version that we know how to handle */ if (npdu_data.protocol_version == BACNET_PROTOCOL_VERSION) - apdu_handler(src, &pdu[apdu_offset], pdu_len - apdu_offset); + apdu_handler(src, &pdu[apdu_offset], (uint16_t)(pdu_len - apdu_offset)); } return; diff --git a/bacnet-stack/wp.c b/bacnet-stack/wp.c index f96d9e45..27b5b2a8 100644 --- a/bacnet-stack/wp.c +++ b/bacnet-stack/wp.c @@ -130,8 +130,9 @@ int wp_decode_service_request(uint8_t * apdu, /* FIXME: decode the length of the context specific tag value */ if (decode_is_context_specific(&apdu[len])) return -2; + /* FIXME: what if the length is more than 255 */ len += bacapp_decode_application_data(&apdu[len], - apdu_len - len, &data->value); + (uint8_t)(apdu_len - len), &data->value); /* FIXME: check the return value; abort if no valid data? */ /* FIXME: there might be more than one data element in here! */ if (!decode_is_closing_tag_number(&apdu[len], 3))