From c3326b324c120143d06e5ff8de6e36b71137a259 Mon Sep 17 00:00:00 2001 From: skarg Date: Tue, 14 Jan 2014 20:03:00 +0000 Subject: [PATCH] Cleaned up some warnings found when compiling with Visual Studio Express 2010. --- bacnet-stack/demo/object/bacfile.c | 4 ++-- bacnet-stack/demo/object/channel.c | 20 ++++++++++---------- bacnet-stack/demo/object/lo.c | 4 ++-- bacnet-stack/src/bacapp.c | 2 +- bacnet-stack/src/datetime.c | 2 +- bacnet-stack/src/indtext.c | 3 +++ bacnet-stack/src/timesync.c | 2 +- bacnet-stack/src/whois.c | 6 +++--- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/bacnet-stack/demo/object/bacfile.c b/bacnet-stack/demo/object/bacfile.c index 94a880b2..002a281f 100644 --- a/bacnet-stack/demo/object/bacfile.c +++ b/bacnet-stack/demo/object/bacfile.c @@ -542,7 +542,7 @@ bool bacfile_write_record_data( if (pFile) { if ((data->type.record.fileStartRecord != -1) && (data->type.record.fileStartRecord > 0)) { - for (i = 0; i < data->type.record.fileStartRecord; i++) { + for (i = 0; i < (uint32_t)data->type.record.fileStartRecord; i++) { pData = fgets(&dummy_data[0], sizeof(dummy_data), pFile); if ((pData == NULL) || feof(pFile)) { break; @@ -608,7 +608,7 @@ bool bacfile_read_ack_record_data( pFile = fopen(pFilename, "rb"); if (pFile) { if (data->type.record.fileStartRecord > 0) { - for (i = 0; i < data->type.record.fileStartRecord; i++) { + for (i = 0; i < (uint32_t)data->type.record.fileStartRecord; i++) { pData = fgets(&dummy_data[0], sizeof(dummy_data), pFile); if ((pData == NULL) || feof(pFile)) { break; diff --git a/bacnet-stack/demo/object/channel.c b/bacnet-stack/demo/object/channel.c index 1fbfc627..27ffa9c6 100644 --- a/bacnet-stack/demo/object/channel.c +++ b/bacnet-stack/demo/object/channel.c @@ -866,7 +866,7 @@ int Channel_Coerce_Data_Encode( } } else if (tag == BACNET_APPLICATION_TAG_REAL) { if (value->type.Unsigned_Int <= 9999999) { - float_value = value->type.Unsigned_Int; + float_value = (float)value->type.Unsigned_Int; apdu_len = encode_application_real(&apdu[0], float_value); } else { @@ -908,7 +908,7 @@ int Channel_Coerce_Data_Encode( signed_value); } else if (tag == BACNET_APPLICATION_TAG_REAL) { if (value->type.Signed_Int <= 9999999) { - float_value = value->type.Signed_Int; + float_value = (float)value->type.Signed_Int; apdu_len = encode_application_real(&apdu[0], float_value); } else { @@ -938,7 +938,7 @@ int Channel_Coerce_Data_Encode( } else if (tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { if ((value->type.Real >= 0.0) && (value->type.Real <= 2147483000.0)) { - unsigned_value = value->type.Real; + unsigned_value = (uint32_t)value->type.Real; apdu_len = encode_application_unsigned(&apdu[0], unsigned_value); } else { @@ -947,7 +947,7 @@ int Channel_Coerce_Data_Encode( } else if (tag == BACNET_APPLICATION_TAG_SIGNED_INT) { if ((value->type.Real >= -2147483000.0) && (value->type.Real <= 214783000.0)) { - signed_value = value->type.Real; + signed_value = (int32_t)value->type.Real; apdu_len = encode_application_signed(&apdu[0], signed_value); } else { @@ -964,7 +964,7 @@ int Channel_Coerce_Data_Encode( } else if (tag == BACNET_APPLICATION_TAG_ENUMERATED) { if ((value->type.Real >= 0.0) && (value->type.Real <= 2147483000.0)) { - unsigned_value = value->type.Real; + unsigned_value = (uint32_t)value->type.Real; apdu_len = encode_application_enumerated(&apdu[0], unsigned_value); } else { @@ -986,7 +986,7 @@ int Channel_Coerce_Data_Encode( } else if (tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { if ((value->type.Double >= 0.0) && (value->type.Double <= 2147483000.0)) { - unsigned_value = value->type.Double; + unsigned_value = (uint32_t)value->type.Double; apdu_len = encode_application_unsigned(&apdu[0], unsigned_value); } else { @@ -995,7 +995,7 @@ int Channel_Coerce_Data_Encode( } else if (tag == BACNET_APPLICATION_TAG_SIGNED_INT) { if ((value->type.Double >= -2147483000.0) && (value->type.Double <= 214783000.0)) { - signed_value = value->type.Double; + signed_value = (int32_t)value->type.Double; apdu_len = encode_application_signed(&apdu[0], signed_value); } else { @@ -1004,7 +1004,7 @@ int Channel_Coerce_Data_Encode( } else if (tag == BACNET_APPLICATION_TAG_REAL) { if ((value->type.Double >= 3.4E-38) && (value->type.Double <= 3.4E+38)) { - float_value = value->type.Double; + float_value = (float)value->type.Double; apdu_len = encode_application_real(&apdu[0], float_value); } else { @@ -1017,7 +1017,7 @@ int Channel_Coerce_Data_Encode( } else if (tag == BACNET_APPLICATION_TAG_ENUMERATED) { if ((value->type.Double >= 0.0) && (value->type.Double <= 2147483000.0)) { - unsigned_value = value->type.Double; + unsigned_value = (uint32_t)value->type.Double; apdu_len = encode_application_enumerated(&apdu[0], unsigned_value); } else { @@ -1050,7 +1050,7 @@ int Channel_Coerce_Data_Encode( } } else if (tag == BACNET_APPLICATION_TAG_REAL) { if (value->type.Enumerated <= 9999999) { - float_value = value->type.Enumerated; + float_value = (float)value->type.Enumerated; apdu_len = encode_application_real(&apdu[0], float_value); } else { diff --git a/bacnet-stack/demo/object/lo.c b/bacnet-stack/demo/object/lo.c index 3f477174..04e60f8c 100644 --- a/bacnet-stack/demo/object/lo.c +++ b/bacnet-stack/demo/object/lo.c @@ -802,7 +802,7 @@ bool Lighting_Output_Default_Step_Increment_Set( unsigned Lighting_Output_Default_Priority( uint32_t object_instance) { - unsigned value = 0.0; + unsigned value = 0; unsigned int index = 0; index = Lighting_Output_Instance_To_Index(object_instance); @@ -1222,7 +1222,7 @@ bool Lighting_Output_Write_Property( if (status) { Lighting_Output_Out_Of_Service_Set( wp_data->object_instance, - &value.type.Boolean); + value.type.Boolean); } break; case PROP_OBJECT_IDENTIFIER: diff --git a/bacnet-stack/src/bacapp.c b/bacnet-stack/src/bacapp.c index 7f759fc0..7405f64b 100644 --- a/bacnet-stack/src/bacapp.c +++ b/bacnet-stack/src/bacapp.c @@ -1389,7 +1389,7 @@ bool bacapp_print_value( /* Try to extract the value into allocated memory. If unable, try again */ /* another time with a string that is twice as large. */ status = bacapp_snprintf_value(str, str_len, object_value); - if ((status < 0) || (status >= str_len)) { + if ((status < 0) || ((size_t)status >= str_len)) { free(str); str_len *= 2; } else if (status == 0) { diff --git a/bacnet-stack/src/datetime.c b/bacnet-stack/src/datetime.c index 0b516a76..a3c2b327 100644 --- a/bacnet-stack/src/datetime.c +++ b/bacnet-stack/src/datetime.c @@ -502,7 +502,7 @@ void datetime_add_minutes( if (minutes < 0) { /* convert to positive for easier math */ minutes *= -1; - if (minutes > bdatetime_minutes) { + if ((uint32_t)minutes > bdatetime_minutes) { /* previous day */ bdatetime_days -= 1; bdatetime_minutes += ((24 * 60) - minutes); diff --git a/bacnet-stack/src/indtext.c b/bacnet-stack/src/indtext.c index fb720c58..2faee0b2 100644 --- a/bacnet-stack/src/indtext.c +++ b/bacnet-stack/src/indtext.c @@ -57,6 +57,9 @@ int stricmp( return (int) c1 - c2; } #endif +#if defined(_MSC_VER) +#define stricmp _stricmp +#endif bool indtext_by_string( INDTEXT_DATA * data_list, diff --git a/bacnet-stack/src/timesync.c b/bacnet-stack/src/timesync.c index b96ecfba..2c7e2c83 100644 --- a/bacnet-stack/src/timesync.c +++ b/bacnet-stack/src/timesync.c @@ -166,7 +166,7 @@ int timesync_encode_timesync_recipients( } else { len = 1 + 3 + 2 + pRecipient->type.address.mac_len + 1; } - if (max_apdu >= len) { + if (max_apdu >= (unsigned)len) { /* CHOICE - address [1] BACnetAddress - opening */ len = encode_opening_tag(&apdu[apdu_len], 1); apdu_len += len; diff --git a/bacnet-stack/src/whois.c b/bacnet-stack/src/whois.c index 44213a69..58940722 100644 --- a/bacnet-stack/src/whois.c +++ b/bacnet-stack/src/whois.c @@ -84,20 +84,20 @@ int whois_decode_service_request( if (tag_number != 0) { return BACNET_STATUS_ERROR; } - if (apdu_len > len) { + if (apdu_len > (unsigned)len) { len += decode_unsigned(&apdu[len], len_value, &decoded_value); if (decoded_value <= BACNET_MAX_INSTANCE) { if (pLow_limit) { *pLow_limit = decoded_value; } } - if (apdu_len > len) { + if (apdu_len > (unsigned)len) { len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value); if (tag_number != 1) { return BACNET_STATUS_ERROR; } - if (apdu_len > len) { + if (apdu_len > (unsigned)len) { len += decode_unsigned(&apdu[len], len_value, &decoded_value); if (decoded_value <= BACNET_MAX_INSTANCE) { if (pHigh_limit) {