Changes to reduce the number of warnings with Visual C++2008 warning level 4 to a minimum.

This commit is contained in:
petermcs
2010-05-14 14:21:48 +00:00
parent 286c372d2c
commit 04e99f3671
25 changed files with 111 additions and 111 deletions
+2 -2
View File
@@ -222,7 +222,7 @@ void address_file_init(
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
src.mac_len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) {
src.mac[index] = mac[index];
src.mac[index] = (uint8_t)mac[index];
}
src.net = (uint16_t) snet;
if (snet) {
@@ -231,7 +231,7 @@ void address_file_init(
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
src.len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) {
src.adr[index] = mac[index];
src.adr[index] = (uint8_t)mac[index];
}
} else {
src.len = 0;
+8 -9
View File
@@ -211,7 +211,7 @@ bool apdu_service_supported_to_index(
}
/* Confirmed ACK Function Handlers */
static void *Confirmed_ACK_Function[MAX_BACNET_CONFIRMED_SERVICE];
static confirmed_ack_function Confirmed_ACK_Function[MAX_BACNET_CONFIRMED_SERVICE];
void apdu_set_confirmed_simple_ack_handler(
BACNET_CONFIRMED_SERVICE service_choice,
@@ -238,7 +238,7 @@ void apdu_set_confirmed_simple_ack_handler(
case SERVICE_CONFIRMED_VT_CLOSE:
/* Security Services */
case SERVICE_CONFIRMED_REQUEST_KEY:
Confirmed_ACK_Function[service_choice] = (void *) pFunction;
Confirmed_ACK_Function[service_choice] = (confirmed_ack_function)pFunction;
break;
default:
break;
@@ -269,7 +269,7 @@ void apdu_set_confirmed_ack_handler(
case SERVICE_CONFIRMED_VT_DATA:
/* Security Services */
case SERVICE_CONFIRMED_AUTHENTICATE:
Confirmed_ACK_Function[service_choice] = (void *) pFunction;
Confirmed_ACK_Function[service_choice] = pFunction;
break;
default:
break;
@@ -366,7 +366,7 @@ void apdu_handler(
uint8_t service_choice = 0;
uint8_t *service_request = NULL;
uint16_t service_request_len = 0;
uint16_t len = 0; /* counts where we are in PDU */
int len = 0; /* counts where we are in PDU */
uint8_t tag_number = 0;
uint32_t len_value = 0;
uint32_t error_code = 0;
@@ -434,7 +434,7 @@ void apdu_handler(
case SERVICE_CONFIRMED_VT_CLOSE:
/* Security Services */
case SERVICE_CONFIRMED_REQUEST_KEY:
if (Confirmed_ACK_Function[service_choice]) {
if (Confirmed_ACK_Function[service_choice] != NULL) {
((confirmed_simple_ack_function)
Confirmed_ACK_Function[service_choice]) (src,
invoke_id);
@@ -458,7 +458,7 @@ void apdu_handler(
}
service_choice = apdu[len++];
service_request = &apdu[len];
service_request_len = apdu_len - len;
service_request_len = apdu_len - (uint16_t)len;
switch (service_choice) {
case SERVICE_CONFIRMED_GET_ALARM_SUMMARY:
case SERVICE_CONFIRMED_GET_ENROLLMENT_SUMMARY:
@@ -478,9 +478,8 @@ void apdu_handler(
case SERVICE_CONFIRMED_VT_DATA:
/* Security Services */
case SERVICE_CONFIRMED_AUTHENTICATE:
if (Confirmed_ACK_Function[service_choice]) {
((confirmed_ack_function)
Confirmed_ACK_Function[service_choice])
if (Confirmed_ACK_Function[service_choice] != NULL) {
(Confirmed_ACK_Function[service_choice])
(service_request, service_request_len, src,
&service_ack_data);
}
+15 -15
View File
@@ -316,7 +316,7 @@ bool bacapp_decode_application_data_safe(
{
/* The static variables that store the apdu buffer between function calls */
static uint8_t *apdu = NULL;
static int32_t apdu_len_remaining = 0;
static uint32_t apdu_len_remaining = 0;
static uint32_t apdu_len = 0;
int len = 0;
int tag_len = 0;
@@ -1084,10 +1084,10 @@ bool bacapp_parse_application_data(
datetime_set_date(&value->type.Date, (uint16_t) year,
(uint8_t) month, (uint8_t) day);
} else if (count == 4) {
value->type.Date.year = year;
value->type.Date.month = month;
value->type.Date.day = day;
value->type.Date.wday = wday;
value->type.Date.year = (uint16_t)year;
value->type.Date.month = (uint8_t)month;
value->type.Date.day = (uint8_t)day;
value->type.Date.wday = (uint8_t)wday;
} else {
status = false;
}
@@ -1097,18 +1097,18 @@ bool bacapp_parse_application_data(
sscanf(argv, "%d:%d:%d.%d", &hour, &min, &sec,
&hundredths);
if (count == 4) {
value->type.Time.hour = hour;
value->type.Time.min = min;
value->type.Time.sec = sec;
value->type.Time.hundredths = hundredths;
value->type.Time.hour = (uint8_t)hour;
value->type.Time.min = (uint8_t)min;
value->type.Time.sec = (uint8_t)sec;
value->type.Time.hundredths = (uint8_t)hundredths;
} else if (count == 3) {
value->type.Time.hour = hour;
value->type.Time.min = min;
value->type.Time.sec = sec;
value->type.Time.hour = (uint8_t)hour;
value->type.Time.min = (uint8_t)min;
value->type.Time.sec = (uint8_t)sec;
value->type.Time.hundredths = 0;
} else if (count == 2) {
value->type.Time.hour = hour;
value->type.Time.min = min;
value->type.Time.hour = (uint8_t)hour;
value->type.Time.min = (uint8_t)min;
value->type.Time.sec = 0;
value->type.Time.hundredths = 0;
} else {
@@ -1118,7 +1118,7 @@ bool bacapp_parse_application_data(
case BACNET_APPLICATION_TAG_OBJECT_ID:
count = sscanf(argv, "%d:%d", &object_type, &instance);
if (count == 2) {
value->type.Object_Id.type = object_type;
value->type.Object_Id.type = (uint16_t)object_type;
value->type.Object_Id.instance = instance;
} else {
status = false;
+17 -17
View File
@@ -206,7 +206,7 @@ int bvlc_encode_write_bdt_init(
/* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */
BVLC_length = 4 + (entries * 10);
BVLC_length = 4 + (uint16_t)(entries * 10);
encode_unsigned16(&pdu[2], BVLC_length);
len = 4;
}
@@ -245,7 +245,7 @@ static int bvlc_encode_read_bdt_ack_init(
/* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */
BVLC_length = 4 + (entries * 10);
BVLC_length = 4 + (uint16_t)(entries * 10);
encode_unsigned16(&pdu[2], BVLC_length);
len = 4;
}
@@ -370,7 +370,7 @@ static int bvlc_encode_read_fdt_ack_init(
/* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */
BVLC_length = 4 + (entries * 10);
BVLC_length = 4 + (uint16_t)(entries * 10);
encode_unsigned16(&pdu[2], BVLC_length);
len = 4;
}
@@ -408,7 +408,7 @@ static int bvlc_encode_read_fdt_ack(
pdu_len += len;
len = encode_unsigned16(&pdu[pdu_len], FD_Table[i].time_to_live);
pdu_len += len;
seconds_remaining = FD_Table[i].seconds_remaining;
seconds_remaining = (uint16_t)FD_Table[i].seconds_remaining;
len = encode_unsigned16(&pdu[pdu_len], seconds_remaining);
pdu_len += len;
}
@@ -455,7 +455,7 @@ int bvlc_encode_original_unicast_npdu(
/* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */
BVLC_length = 4 + npdu_length;
BVLC_length = 4 + (uint16_t)npdu_length;
len = encode_unsigned16(&pdu[2], BVLC_length) + 2;
for (i = 0; i < npdu_length; i++) {
pdu[len] = npdu[i];
@@ -481,7 +481,7 @@ int bvlc_encode_original_broadcast_npdu(
/* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */
BVLC_length = 4 + npdu_length;
BVLC_length = 4 + (uint16_t)npdu_length;
len = encode_unsigned16(&pdu[2], BVLC_length) + 2;
for (i = 0; i < npdu_length; i++) {
pdu[len] = npdu[i];
@@ -507,7 +507,7 @@ static void bvlc_internet_to_bacnet_address(
len = encode_unsigned32(&src->mac[0], address);
port = ntohs(sin->sin_port);
len += encode_unsigned16(&src->mac[4], port);
src->mac_len = len;
src->mac_len = (uint8_t)len;
src->net = 0;
src->len = 0;
}
@@ -668,7 +668,7 @@ static void bvlc_bdt_forward_npdu(
unsigned i = 0; /* loop counter */
struct sockaddr_in bip_dest = { 0 };
mtu_len = bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, npdu_length);
mtu_len = (uint16_t)bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, npdu_length);
/* loop through the BDT and send one to each entry, except us */
for (i = 0; i < MAX_BBMD_ENTRIES; i++) {
if (BBMD_Table[i].valid) {
@@ -710,7 +710,7 @@ static void bvlc_forward_npdu(
uint16_t mtu_len = 0;
struct sockaddr_in bip_dest = { 0 };
mtu_len = bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, npdu_length);
mtu_len = (uint16_t)bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, npdu_length);
bip_dest.sin_addr.s_addr = htonl(bip_get_broadcast_addr());
bip_dest.sin_port = htons(bip_get_port());
bvlc_send_mpdu(&bip_dest, mtu, mtu_len);
@@ -727,7 +727,7 @@ static void bvlc_fdt_forward_npdu(
unsigned i = 0; /* loop counter */
struct sockaddr_in bip_dest = { 0 };
mtu_len = bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, max_npdu);
mtu_len = (uint16_t)bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, max_npdu);
/* loop through the FDT and send one to each entry */
for (i = 0; i < MAX_FD_ENTRIES; i++) {
if (FD_Table[i].valid && FD_Table[i].seconds_remaining) {
@@ -769,7 +769,7 @@ void bvlc_register_with_bbmd(
Write Broadcast Distribution Table, or
register with the BBMD as a Foreign Device */
mtu_len =
bvlc_encode_register_foreign_device(&mtu[0], time_to_live_seconds);
(uint16_t)bvlc_encode_register_foreign_device(&mtu[0], time_to_live_seconds);
bvlc_send_mpdu(&Remote_BBMD, &mtu[0], mtu_len);
}
@@ -780,7 +780,7 @@ static void bvlc_send_result(
uint8_t mtu[MAX_MPDU] = { 0 };
uint16_t mtu_len = 0;
mtu_len = bvlc_encode_bvlc_result(&mtu[0], result_code);
mtu_len = (uint16_t)bvlc_encode_bvlc_result(&mtu[0], result_code);
bvlc_send_mpdu(dest, mtu, mtu_len);
return;
@@ -792,7 +792,7 @@ static int bvlc_send_bdt(
uint8_t mtu[MAX_MPDU] = { 0 };
uint16_t mtu_len = 0;
mtu_len = bvlc_encode_read_bdt_ack(&mtu[0], sizeof(mtu));
mtu_len = (uint16_t)bvlc_encode_read_bdt_ack(&mtu[0], sizeof(mtu));
if (mtu_len) {
bvlc_send_mpdu(dest, &mtu[0], mtu_len);
}
@@ -806,7 +806,7 @@ static int bvlc_send_fdt(
uint8_t mtu[MAX_MPDU] = { 0 };
uint16_t mtu_len = 0;
mtu_len = bvlc_encode_read_fdt_ack(&mtu[0], sizeof(mtu));
mtu_len = (uint16_t)bvlc_encode_read_fdt_ack(&mtu[0], sizeof(mtu));
if (mtu_len) {
bvlc_send_mpdu(dest, &mtu[0], mtu_len);
}
@@ -1194,11 +1194,11 @@ int bvlc_send_pdu(
}
bvlc_dest.sin_addr.s_addr = htonl(address.s_addr);
bvlc_dest.sin_port = htons(port);
BVLC_length = pdu_len + 4 /*inclusive */ ;
BVLC_length = (uint16_t)pdu_len + 4 /*inclusive */ ;
mtu_len = 2;
mtu_len += encode_unsigned16(&mtu[mtu_len], BVLC_length);
mtu_len += (uint16_t)encode_unsigned16(&mtu[mtu_len], BVLC_length);
memcpy(&mtu[mtu_len], pdu, pdu_len);
mtu_len += pdu_len;
mtu_len += (uint16_t)pdu_len;
return bvlc_send_mpdu(&bvlc_dest, mtu, mtu_len);
}
+1 -1
View File
@@ -274,7 +274,7 @@ int cov_notify_decode_service_request(
decode_tag_number_and_value(&apdu[len], &tag_number,
&len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value);
value->priority = decoded_value;
value->priority = (uint8_t)decoded_value;
} else {
value->priority = BACNET_NO_PRIORITY;
}
+2 -2
View File
@@ -714,7 +714,7 @@ bool MSTP_Master_Node_FSM(
uint8_t frame_type = mstp_port->OutputBuffer[2];
uint8_t destination = mstp_port->OutputBuffer[3];
RS485_Send_Frame(mstp_port,
(uint8_t *) & mstp_port->OutputBuffer[0], length);
(uint8_t *) & mstp_port->OutputBuffer[0], (uint16_t)length);
mstp_port->FrameCount++;
switch (frame_type) {
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
@@ -1049,7 +1049,7 @@ bool MSTP_Master_Node_FSM(
/* then call MSTP_Create_And_Send_Frame to transmit the reply frame */
/* and enter the IDLE state to wait for the next frame. */
RS485_Send_Frame(mstp_port,
(uint8_t *) & mstp_port->OutputBuffer[0], length);
(uint8_t *) & mstp_port->OutputBuffer[0], (uint16_t)length);
mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
} else {
/* DeferredReply */
+2 -2
View File
@@ -139,7 +139,7 @@ int ptransfer_decode_service_request(
return -1;
}
len = decode_len;
private_data->vendorID = unsigned_value;
private_data->vendorID = (uint16_t)unsigned_value;
/* Tag 1: serviceNumber */
decode_len = decode_context_unsigned(&apdu[len], 1, &unsigned_value);
if (decode_len < 0) {
@@ -279,7 +279,7 @@ int ptransfer_error_decode_service_request(
return -1;
}
len += decode_len;
private_data->vendorID = unsigned_value;
private_data->vendorID = (uint16_t)unsigned_value;
/* Tag 2: serviceNumber */
decode_len = decode_context_unsigned(&apdu[len], 2, &unsigned_value);
if (decode_len < 0) {
+3 -3
View File
@@ -73,7 +73,7 @@ static uint8_t tsm_find_invokeID_index(
for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) {
if (TSM_List[i].InvokeID == invokeID) {
index = i;
index = (uint8_t)i;
break;
}
}
@@ -89,7 +89,7 @@ static uint8_t tsm_find_first_free_index(
for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) {
if (TSM_List[i].InvokeID == 0) {
index = i;
index = (uint8_t)i;
break;
}
}
@@ -238,7 +238,7 @@ bool tsm_get_transaction_pdu(
/* FIXME: we may want to free the transaction so it doesn't timeout */
/* retrieve the transaction */
/* FIXME: bounds check the pdu_len? */
*apdu_len = TSM_List[index].apdu_len;
*apdu_len = (uint16_t)TSM_List[index].apdu_len;
for (j = 0; j < *apdu_len; j++) {
apdu[j] = TSM_List[index].apdu[j];
}