Changes to reduce the number of warnings with Visual C++2008 warning level 4 to a minimum.
This commit is contained in:
@@ -90,7 +90,7 @@ void dlenv_init(
|
||||
#endif
|
||||
pEnv = getenv("BACNET_IP_PORT");
|
||||
if (pEnv) {
|
||||
bip_set_port(strtol(pEnv, NULL, 0));
|
||||
bip_set_port((uint16_t)strtol(pEnv, NULL, 0));
|
||||
} else {
|
||||
bip_set_port(0xBAC0);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ void dlenv_init(
|
||||
#endif
|
||||
pEnv = getenv("BACNET_APDU_TIMEOUT");
|
||||
if (pEnv) {
|
||||
apdu_timeout_set(strtol(pEnv, NULL, 0));
|
||||
apdu_timeout_set((uint16_t)strtol(pEnv, NULL, 0));
|
||||
fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv);
|
||||
} else {
|
||||
#if defined(BACDL_MSTP)
|
||||
@@ -160,8 +160,8 @@ void dlenv_init(
|
||||
fprintf(stderr,
|
||||
"Registering with BBMD at %s:%ld for %ld seconds\n",
|
||||
inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds);
|
||||
bvlc_register_with_bbmd(bbmd_address, bbmd_port,
|
||||
bbmd_timetolive_seconds);
|
||||
bvlc_register_with_bbmd(bbmd_address, (uint16_t)bbmd_port,
|
||||
(uint16_t)bbmd_timetolive_seconds);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -222,7 +222,7 @@ void handler_read_property_multiple(
|
||||
apdu_len =
|
||||
rpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id);
|
||||
do {
|
||||
for(;;) {
|
||||
len =
|
||||
rpm_decode_object_id(&service_request[decode_len],
|
||||
service_len - decode_len, &object_type, &object_instance);
|
||||
@@ -272,7 +272,7 @@ void handler_read_property_multiple(
|
||||
apdu_len += copy_len;
|
||||
}
|
||||
/* do each property of this object of the RPM request */
|
||||
do {
|
||||
for(;;) {
|
||||
len =
|
||||
rpm_decode_object_property(&service_request[decode_len],
|
||||
service_len - decode_len, &object_property, &array_index);
|
||||
@@ -326,7 +326,7 @@ void handler_read_property_multiple(
|
||||
/* handle the error code - but use the special property */
|
||||
len =
|
||||
RPM_Encode_Property(&Handler_Transmit_Buffer[0],
|
||||
npdu_len + apdu_len, MAX_APDU, object_type,
|
||||
(uint16_t)(npdu_len + apdu_len), MAX_APDU, object_type,
|
||||
object_instance, object_property, array_index);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
@@ -344,7 +344,7 @@ void handler_read_property_multiple(
|
||||
special_object_property, index);
|
||||
len =
|
||||
RPM_Encode_Property(&Handler_Transmit_Buffer[0],
|
||||
npdu_len + apdu_len, MAX_APDU, object_type,
|
||||
(uint16_t)(npdu_len + apdu_len), MAX_APDU, object_type,
|
||||
object_instance, object_property, array_index);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
@@ -361,7 +361,7 @@ void handler_read_property_multiple(
|
||||
/* handle an individual property */
|
||||
len =
|
||||
RPM_Encode_Property(&Handler_Transmit_Buffer[0],
|
||||
npdu_len + apdu_len, sizeof(Handler_Transmit_Buffer),
|
||||
(uint16_t)(npdu_len + apdu_len), sizeof(Handler_Transmit_Buffer),
|
||||
object_type, object_instance, object_property,
|
||||
array_index);
|
||||
if (len > 0) {
|
||||
@@ -374,11 +374,11 @@ void handler_read_property_multiple(
|
||||
goto RPM_ABORT;
|
||||
}
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
if (decode_len >= service_len) {
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
if (apdu_len > service_data->max_resp) {
|
||||
/* too big for the sender - send an abort */
|
||||
apdu_len =
|
||||
|
||||
@@ -95,7 +95,7 @@ uint8_t Send_Atomic_Read_File_Stream(
|
||||
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);
|
||||
|
||||
@@ -97,7 +97,7 @@ uint8_t Send_Atomic_Write_File_Stream(
|
||||
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);
|
||||
|
||||
@@ -101,7 +101,7 @@ uint8_t Send_Device_Communication_Control_Request(
|
||||
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);
|
||||
|
||||
@@ -118,7 +118,7 @@ uint8_t Send_Private_Transfer_Request(
|
||||
|
||||
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);
|
||||
|
||||
@@ -98,7 +98,7 @@ uint8_t Send_Reinitialize_Device_Request(
|
||||
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);
|
||||
|
||||
@@ -78,7 +78,7 @@ void Send_Who_Is_Router_To_Network(
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
||||
/* encode the optional DNET portion of the packet */
|
||||
if (dnet >= 0) {
|
||||
len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], dnet);
|
||||
len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], (uint16_t)dnet);
|
||||
pdu_len += len;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Send Who-Is-Router-To-Network message to %u\n", dnet);
|
||||
@@ -122,7 +122,7 @@ void Send_I_Am_Router_To_Network(
|
||||
fprintf(stderr, "Send I-Am-Router-To-Network message to:\n");
|
||||
#endif
|
||||
while (DNET_list[index] != -1) {
|
||||
dnet = DNET_list[index];
|
||||
dnet = (uint16_t)DNET_list[index];
|
||||
len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], dnet);
|
||||
pdu_len += len;
|
||||
index++;
|
||||
|
||||
@@ -369,7 +369,7 @@ uint32_t bacfile_instance_from_tsm(
|
||||
BACNET_ADDRESS dest; /* where the original packet was destined */
|
||||
uint8_t apdu[MAX_PDU] = { 0 }; /* original APDU packet */
|
||||
uint16_t apdu_len = 0; /* original APDU packet length */
|
||||
uint16_t len = 0; /* apdu header length */
|
||||
int len = 0; /* apdu header length */
|
||||
BACNET_ATOMIC_READ_FILE_DATA data = { 0 };
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE + 1; /* return value */
|
||||
bool found = false;
|
||||
|
||||
@@ -448,6 +448,7 @@ unsigned Device_Count(
|
||||
uint32_t Device_Index_To_Instance(
|
||||
unsigned index)
|
||||
{
|
||||
index = index;
|
||||
return Object_Instance_Number;
|
||||
}
|
||||
|
||||
@@ -808,7 +809,7 @@ bool Device_Object_List_Identifier(
|
||||
* look for the index to instance to get the ID */
|
||||
if (pObject->Object_Iterator) {
|
||||
/* First find the first object */
|
||||
temp_index = pObject->Object_Iterator(~0);
|
||||
temp_index = pObject->Object_Iterator(~(unsigned)0);
|
||||
/* Then step through the objects to find the nth */
|
||||
while (object_index != 0) {
|
||||
temp_index = pObject->Object_Iterator(temp_index);
|
||||
|
||||
@@ -141,6 +141,8 @@ int Lighting_Output_Decode_Lighting_Command(
|
||||
uint32_t len_value_type = 0;
|
||||
float real_value = 0.0;
|
||||
|
||||
apdu_max_len = apdu_max_len;
|
||||
|
||||
/* check for value pointers */
|
||||
if (apdu_len && data) {
|
||||
/* Tag 0: operation */
|
||||
|
||||
@@ -174,7 +174,7 @@ bool Multistate_Input_Present_Value_Set(
|
||||
index = Multistate_Input_Instance_To_Index(object_instance);
|
||||
if (index < MAX_MULTISTATE_INPUTS) {
|
||||
if (value < MULTISTATE_NUMBER_OF_STATES) {
|
||||
Present_Value[index] = value;
|
||||
Present_Value[index] = (uint8_t)value;
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1043,20 +1043,20 @@ void TL_Local_Time_To_BAC(
|
||||
struct tm *TempTime;
|
||||
|
||||
TempTime = localtime(&SourceTime);
|
||||
|
||||
DestTime->date.year = TempTime->tm_year + 1900;
|
||||
DestTime->date.month = TempTime->tm_mon + 1;
|
||||
DestTime->date.day = TempTime->tm_mday;
|
||||
|
||||
DestTime->date.year = (uint16_t)(TempTime->tm_year + 1900);
|
||||
DestTime->date.month = (uint8_t)(TempTime->tm_mon + 1);
|
||||
DestTime->date.day = (uint8_t)TempTime->tm_mday;
|
||||
/* BACnet is 1 to 7 = Monday to Sunday
|
||||
* Windows is days from Sunday 0 - 6 so we
|
||||
* have to adjust */
|
||||
if (TempTime->tm_wday == 0)
|
||||
DestTime->date.wday = 7;
|
||||
else
|
||||
DestTime->date.wday = TempTime->tm_wday;
|
||||
DestTime->time.hour = TempTime->tm_hour;
|
||||
DestTime->time.min = TempTime->tm_min;
|
||||
DestTime->time.sec = TempTime->tm_sec;
|
||||
DestTime->date.wday = (uint8_t)TempTime->tm_wday;
|
||||
DestTime->time.hour = (uint8_t)TempTime->tm_hour;
|
||||
DestTime->time.min = (uint8_t)TempTime->tm_min;
|
||||
DestTime->time.sec = (uint8_t)TempTime->tm_sec;
|
||||
DestTime->time.hundredths = 0;
|
||||
}
|
||||
|
||||
@@ -1489,7 +1489,7 @@ int TL_encode_entry(
|
||||
int iLen = 0;
|
||||
TL_DATA_REC *pSource = NULL;
|
||||
BACNET_BIT_STRING TempBits;
|
||||
int iCount = 0;
|
||||
uint8_t ucCount = 0;
|
||||
BACNET_DATE_TIME TempTime;
|
||||
|
||||
/* Convert from BACnet 1 based to 0 based array index and then
|
||||
@@ -1555,16 +1555,11 @@ int TL_encode_entry(
|
||||
* have limited to 32 bits maximum as allowed by the standard
|
||||
*/
|
||||
bitstring_init(&TempBits);
|
||||
bitstring_set_bits_used(&TempBits,
|
||||
(pSource->Datum.Bits.ucLen >> 4) & 0x0F,
|
||||
pSource->Datum.Bits.ucLen & 0x0F);
|
||||
for (iCount = pSource->Datum.Bits.ucLen >> 4; iCount > 0; iCount--)
|
||||
bitstring_set_octet(&TempBits, iCount - 1,
|
||||
pSource->Datum.Bits.ucStore[iCount - 1]);
|
||||
|
||||
iLen +=
|
||||
encode_context_bitstring(&apdu[iLen], pSource->ucRecType,
|
||||
&TempBits);
|
||||
bitstring_set_bits_used(&TempBits, (pSource->Datum.Bits.ucLen >> 4) & 0x0F, pSource->Datum.Bits.ucLen & 0x0F);
|
||||
for(ucCount = pSource->Datum.Bits.ucLen >> 4; ucCount > 0; ucCount--)
|
||||
bitstring_set_octet(&TempBits, ucCount - 1, pSource->Datum.Bits.ucStore[ucCount-1]);
|
||||
|
||||
iLen += encode_context_bitstring(&apdu[iLen], pSource->ucRecType, &TempBits);
|
||||
break;
|
||||
|
||||
case TL_TYPE_NULL:
|
||||
@@ -1631,7 +1626,8 @@ static int local_read_property(
|
||||
*error_code = rpdata.error_code;
|
||||
}
|
||||
}
|
||||
if ((len >= 0) && (status != NULL)) {
|
||||
|
||||
if((len >= 0) && (status != NULL)){
|
||||
/* Fetch the status flags if required */
|
||||
rpdata.application_data = status;
|
||||
rpdata.application_data_len = MAX_APDU;
|
||||
@@ -1642,9 +1638,6 @@ static int local_read_property(
|
||||
*error_class = rpdata.error_class;
|
||||
*error_code = rpdata.error_code;
|
||||
}
|
||||
} else {
|
||||
*error_class = rpdata.error_class;
|
||||
*error_code = rpdata.error_code;
|
||||
}
|
||||
|
||||
return (len);
|
||||
@@ -1662,7 +1655,7 @@ void TL_fetch_property(
|
||||
BACNET_ERROR_CLASS error_class;
|
||||
BACNET_ERROR_CODE error_code;
|
||||
int iLen;
|
||||
int iCount;
|
||||
uint8_t ucCount;
|
||||
TL_LOG_INFO *CurrentLog;
|
||||
TL_DATA_REC TempRec;
|
||||
uint8_t tag_number = 0;
|
||||
@@ -1729,16 +1722,13 @@ void TL_fetch_property(
|
||||
TempRec.Datum.Bits.ucLen |=
|
||||
(8 - (bitstring_bits_used(&TempBits) % 8)) & 7;
|
||||
/* Fetch the octets with the bits directly */
|
||||
for (iCount = 0; iCount < bitstring_bytes_used(&TempBits);
|
||||
iCount++)
|
||||
TempRec.Datum.Bits.ucStore[iCount] =
|
||||
bitstring_octet(&TempBits, iCount);
|
||||
for(ucCount = 0; ucCount < bitstring_bytes_used(&TempBits); ucCount++)
|
||||
TempRec.Datum.Bits.ucStore[ucCount] = bitstring_octet(&TempBits, ucCount);
|
||||
} else {
|
||||
/* We will only use the first 4 octets to save space */
|
||||
TempRec.Datum.Bits.ucLen = 4 << 4;
|
||||
for (iCount = 0; iCount < 4; iCount++)
|
||||
TempRec.Datum.Bits.ucStore[iCount] =
|
||||
bitstring_octet(&TempBits, iCount);
|
||||
for(ucCount = 0; ucCount < 4; ucCount++)
|
||||
TempRec.Datum.Bits.ucStore[ucCount] = bitstring_octet(&TempBits, ucCount);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user