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
+4 -4
View File
@@ -90,7 +90,7 @@ void dlenv_init(
#endif #endif
pEnv = getenv("BACNET_IP_PORT"); pEnv = getenv("BACNET_IP_PORT");
if (pEnv) { if (pEnv) {
bip_set_port(strtol(pEnv, NULL, 0)); bip_set_port((uint16_t)strtol(pEnv, NULL, 0));
} else { } else {
bip_set_port(0xBAC0); bip_set_port(0xBAC0);
} }
@@ -122,7 +122,7 @@ void dlenv_init(
#endif #endif
pEnv = getenv("BACNET_APDU_TIMEOUT"); pEnv = getenv("BACNET_APDU_TIMEOUT");
if (pEnv) { 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); fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv);
} else { } else {
#if defined(BACDL_MSTP) #if defined(BACDL_MSTP)
@@ -160,8 +160,8 @@ void dlenv_init(
fprintf(stderr, fprintf(stderr,
"Registering with BBMD at %s:%ld for %ld seconds\n", "Registering with BBMD at %s:%ld for %ld seconds\n",
inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds); inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds);
bvlc_register_with_bbmd(bbmd_address, bbmd_port, bvlc_register_with_bbmd(bbmd_address, (uint16_t)bbmd_port,
bbmd_timetolive_seconds); (uint16_t)bbmd_timetolive_seconds);
} }
} }
#endif #endif
+7 -7
View File
@@ -222,7 +222,7 @@ void handler_read_property_multiple(
apdu_len = apdu_len =
rpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len], rpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id); service_data->invoke_id);
do { for(;;) {
len = len =
rpm_decode_object_id(&service_request[decode_len], rpm_decode_object_id(&service_request[decode_len],
service_len - decode_len, &object_type, &object_instance); service_len - decode_len, &object_type, &object_instance);
@@ -272,7 +272,7 @@ void handler_read_property_multiple(
apdu_len += copy_len; apdu_len += copy_len;
} }
/* do each property of this object of the RPM request */ /* do each property of this object of the RPM request */
do { for(;;) {
len = len =
rpm_decode_object_property(&service_request[decode_len], rpm_decode_object_property(&service_request[decode_len],
service_len - decode_len, &object_property, &array_index); 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 */ /* handle the error code - but use the special property */
len = len =
RPM_Encode_Property(&Handler_Transmit_Buffer[0], 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); object_instance, object_property, array_index);
if (len > 0) { if (len > 0) {
apdu_len += len; apdu_len += len;
@@ -344,7 +344,7 @@ void handler_read_property_multiple(
special_object_property, index); special_object_property, index);
len = len =
RPM_Encode_Property(&Handler_Transmit_Buffer[0], 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); object_instance, object_property, array_index);
if (len > 0) { if (len > 0) {
apdu_len += len; apdu_len += len;
@@ -361,7 +361,7 @@ void handler_read_property_multiple(
/* handle an individual property */ /* handle an individual property */
len = len =
RPM_Encode_Property(&Handler_Transmit_Buffer[0], 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, object_type, object_instance, object_property,
array_index); array_index);
if (len > 0) { if (len > 0) {
@@ -374,11 +374,11 @@ void handler_read_property_multiple(
goto RPM_ABORT; goto RPM_ABORT;
} }
} }
} while (1); }
if (decode_len >= service_len) { if (decode_len >= service_len) {
break; break;
} }
} while (1); }
if (apdu_len > service_data->max_resp) { if (apdu_len > service_data->max_resp) {
/* too big for the sender - send an abort */ /* too big for the sender - send an abort */
apdu_len = apdu_len =
+1 -1
View File
@@ -95,7 +95,7 @@ uint8_t Send_Atomic_Read_File_Stream(
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, 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 = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+1 -1
View File
@@ -97,7 +97,7 @@ uint8_t Send_Atomic_Write_File_Stream(
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len <= max_apdu) { if ((unsigned) pdu_len <= max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, 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 = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+1 -1
View File
@@ -101,7 +101,7 @@ uint8_t Send_Device_Communication_Control_Request(
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, 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 = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+1 -1
View File
@@ -118,7 +118,7 @@ uint8_t Send_Private_Transfer_Request(
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, 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 = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+1 -1
View File
@@ -98,7 +98,7 @@ uint8_t Send_Reinitialize_Device_Request(
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, 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 = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+2 -2
View File
@@ -78,7 +78,7 @@ void Send_Who_Is_Router_To_Network(
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data); npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
/* encode the optional DNET portion of the packet */ /* encode the optional DNET portion of the packet */
if (dnet >= 0) { 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; pdu_len += len;
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "Send Who-Is-Router-To-Network message to %u\n", dnet); 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"); fprintf(stderr, "Send I-Am-Router-To-Network message to:\n");
#endif #endif
while (DNET_list[index] != -1) { while (DNET_list[index] != -1) {
dnet = DNET_list[index]; dnet = (uint16_t)DNET_list[index];
len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], dnet); len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], dnet);
pdu_len += len; pdu_len += len;
index++; index++;
+1 -1
View File
@@ -369,7 +369,7 @@ uint32_t bacfile_instance_from_tsm(
BACNET_ADDRESS dest; /* where the original packet was destined */ BACNET_ADDRESS dest; /* where the original packet was destined */
uint8_t apdu[MAX_PDU] = { 0 }; /* original APDU packet */ uint8_t apdu[MAX_PDU] = { 0 }; /* original APDU packet */
uint16_t apdu_len = 0; /* original APDU packet length */ 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 }; BACNET_ATOMIC_READ_FILE_DATA data = { 0 };
uint32_t object_instance = BACNET_MAX_INSTANCE + 1; /* return value */ uint32_t object_instance = BACNET_MAX_INSTANCE + 1; /* return value */
bool found = false; bool found = false;
+2 -1
View File
@@ -448,6 +448,7 @@ unsigned Device_Count(
uint32_t Device_Index_To_Instance( uint32_t Device_Index_To_Instance(
unsigned index) unsigned index)
{ {
index = index;
return Object_Instance_Number; return Object_Instance_Number;
} }
@@ -808,7 +809,7 @@ bool Device_Object_List_Identifier(
* look for the index to instance to get the ID */ * look for the index to instance to get the ID */
if (pObject->Object_Iterator) { if (pObject->Object_Iterator) {
/* First find the first object */ /* 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 */ /* Then step through the objects to find the nth */
while (object_index != 0) { while (object_index != 0) {
temp_index = pObject->Object_Iterator(temp_index); temp_index = pObject->Object_Iterator(temp_index);
+2
View File
@@ -141,6 +141,8 @@ int Lighting_Output_Decode_Lighting_Command(
uint32_t len_value_type = 0; uint32_t len_value_type = 0;
float real_value = 0.0; float real_value = 0.0;
apdu_max_len = apdu_max_len;
/* check for value pointers */ /* check for value pointers */
if (apdu_len && data) { if (apdu_len && data) {
/* Tag 0: operation */ /* Tag 0: operation */
+1 -1
View File
@@ -174,7 +174,7 @@ bool Multistate_Input_Present_Value_Set(
index = Multistate_Input_Instance_To_Index(object_instance); index = Multistate_Input_Instance_To_Index(object_instance);
if (index < MAX_MULTISTATE_INPUTS) { if (index < MAX_MULTISTATE_INPUTS) {
if (value < MULTISTATE_NUMBER_OF_STATES) { if (value < MULTISTATE_NUMBER_OF_STATES) {
Present_Value[index] = value; Present_Value[index] = (uint8_t)value;
status = true; status = true;
} }
} }
+21 -31
View File
@@ -1043,20 +1043,20 @@ void TL_Local_Time_To_BAC(
struct tm *TempTime; struct tm *TempTime;
TempTime = localtime(&SourceTime); TempTime = localtime(&SourceTime);
DestTime->date.year = TempTime->tm_year + 1900; DestTime->date.year = (uint16_t)(TempTime->tm_year + 1900);
DestTime->date.month = TempTime->tm_mon + 1; DestTime->date.month = (uint8_t)(TempTime->tm_mon + 1);
DestTime->date.day = TempTime->tm_mday; DestTime->date.day = (uint8_t)TempTime->tm_mday;
/* BACnet is 1 to 7 = Monday to Sunday /* BACnet is 1 to 7 = Monday to Sunday
* Windows is days from Sunday 0 - 6 so we * Windows is days from Sunday 0 - 6 so we
* have to adjust */ * have to adjust */
if (TempTime->tm_wday == 0) if (TempTime->tm_wday == 0)
DestTime->date.wday = 7; DestTime->date.wday = 7;
else else
DestTime->date.wday = TempTime->tm_wday; DestTime->date.wday = (uint8_t)TempTime->tm_wday;
DestTime->time.hour = TempTime->tm_hour; DestTime->time.hour = (uint8_t)TempTime->tm_hour;
DestTime->time.min = TempTime->tm_min; DestTime->time.min = (uint8_t)TempTime->tm_min;
DestTime->time.sec = TempTime->tm_sec; DestTime->time.sec = (uint8_t)TempTime->tm_sec;
DestTime->time.hundredths = 0; DestTime->time.hundredths = 0;
} }
@@ -1489,7 +1489,7 @@ int TL_encode_entry(
int iLen = 0; int iLen = 0;
TL_DATA_REC *pSource = NULL; TL_DATA_REC *pSource = NULL;
BACNET_BIT_STRING TempBits; BACNET_BIT_STRING TempBits;
int iCount = 0; uint8_t ucCount = 0;
BACNET_DATE_TIME TempTime; BACNET_DATE_TIME TempTime;
/* Convert from BACnet 1 based to 0 based array index and then /* 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 * have limited to 32 bits maximum as allowed by the standard
*/ */
bitstring_init(&TempBits); bitstring_init(&TempBits);
bitstring_set_bits_used(&TempBits, bitstring_set_bits_used(&TempBits, (pSource->Datum.Bits.ucLen >> 4) & 0x0F, pSource->Datum.Bits.ucLen & 0x0F);
(pSource->Datum.Bits.ucLen >> 4) & 0x0F, for(ucCount = pSource->Datum.Bits.ucLen >> 4; ucCount > 0; ucCount--)
pSource->Datum.Bits.ucLen & 0x0F); bitstring_set_octet(&TempBits, ucCount - 1, pSource->Datum.Bits.ucStore[ucCount-1]);
for (iCount = pSource->Datum.Bits.ucLen >> 4; iCount > 0; iCount--)
bitstring_set_octet(&TempBits, iCount - 1, iLen += encode_context_bitstring(&apdu[iLen], pSource->ucRecType, &TempBits);
pSource->Datum.Bits.ucStore[iCount - 1]);
iLen +=
encode_context_bitstring(&apdu[iLen], pSource->ucRecType,
&TempBits);
break; break;
case TL_TYPE_NULL: case TL_TYPE_NULL:
@@ -1631,7 +1626,8 @@ static int local_read_property(
*error_code = rpdata.error_code; *error_code = rpdata.error_code;
} }
} }
if ((len >= 0) && (status != NULL)) {
if((len >= 0) && (status != NULL)){
/* Fetch the status flags if required */ /* Fetch the status flags if required */
rpdata.application_data = status; rpdata.application_data = status;
rpdata.application_data_len = MAX_APDU; rpdata.application_data_len = MAX_APDU;
@@ -1642,9 +1638,6 @@ static int local_read_property(
*error_class = rpdata.error_class; *error_class = rpdata.error_class;
*error_code = rpdata.error_code; *error_code = rpdata.error_code;
} }
} else {
*error_class = rpdata.error_class;
*error_code = rpdata.error_code;
} }
return (len); return (len);
@@ -1662,7 +1655,7 @@ void TL_fetch_property(
BACNET_ERROR_CLASS error_class; BACNET_ERROR_CLASS error_class;
BACNET_ERROR_CODE error_code; BACNET_ERROR_CODE error_code;
int iLen; int iLen;
int iCount; uint8_t ucCount;
TL_LOG_INFO *CurrentLog; TL_LOG_INFO *CurrentLog;
TL_DATA_REC TempRec; TL_DATA_REC TempRec;
uint8_t tag_number = 0; uint8_t tag_number = 0;
@@ -1729,16 +1722,13 @@ void TL_fetch_property(
TempRec.Datum.Bits.ucLen |= TempRec.Datum.Bits.ucLen |=
(8 - (bitstring_bits_used(&TempBits) % 8)) & 7; (8 - (bitstring_bits_used(&TempBits) % 8)) & 7;
/* Fetch the octets with the bits directly */ /* Fetch the octets with the bits directly */
for (iCount = 0; iCount < bitstring_bytes_used(&TempBits); for(ucCount = 0; ucCount < bitstring_bytes_used(&TempBits); ucCount++)
iCount++) TempRec.Datum.Bits.ucStore[ucCount] = bitstring_octet(&TempBits, ucCount);
TempRec.Datum.Bits.ucStore[iCount] =
bitstring_octet(&TempBits, iCount);
} else { } else {
/* We will only use the first 4 octets to save space */ /* We will only use the first 4 octets to save space */
TempRec.Datum.Bits.ucLen = 4 << 4; TempRec.Datum.Bits.ucLen = 4 << 4;
for (iCount = 0; iCount < 4; iCount++) for(ucCount = 0; ucCount < 4; ucCount++)
TempRec.Datum.Bits.ucStore[iCount] = TempRec.Datum.Bits.ucStore[ucCount] = bitstring_octet(&TempBits, ucCount);
bitstring_octet(&TempBits, iCount);
} }
break; break;
+7 -1
View File
@@ -39,6 +39,12 @@
#include "bacenum.h" #include "bacenum.h"
#include "config.h" #include "config.h"
#if defined(_MSC_VER)
// Silence the warnings about unsafe versions of library functions
// as we need to keep the code portable
#pragma warning( disable : 4996)
#endif
/* This stack implements this version of BACnet */ /* This stack implements this version of BACnet */
#define BACNET_PROTOCOL_VERSION 1 #define BACNET_PROTOCOL_VERSION 1
#define BACNET_PROTOCOL_REVISION 5 #define BACNET_PROTOCOL_REVISION 5
@@ -50,7 +56,7 @@
/* large BACnet Object Type */ /* large BACnet Object Type */
#define BACNET_MAX_OBJECT (0x3FF) #define BACNET_MAX_OBJECT (0x3FF)
/* Array index 0=size of array, n=array element n, MAX=all array elements */ /* Array index 0=size of array, n=array element n, MAX=all array elements */
#define BACNET_ARRAY_ALL (~0) #define BACNET_ARRAY_ALL (~(unsigned int)0)
/* Priority Array for commandable objects */ /* Priority Array for commandable objects */
#define BACNET_NO_PRIORITY 0 #define BACNET_NO_PRIORITY 0
#define BACNET_MIN_PRIORITY 1 #define BACNET_MIN_PRIORITY 1
+1 -1
View File
@@ -97,7 +97,7 @@
/* some modules have debugging enabled using PRINT_ENABLED */ /* some modules have debugging enabled using PRINT_ENABLED */
#if !defined(PRINT_ENABLED) #if !defined(PRINT_ENABLED)
#define PRINT_ENABLED 0 #define PRINT_ENABLED 1
#endif #endif
/* BACAPP decodes WriteProperty service requests /* BACAPP decodes WriteProperty service requests
+6 -5
View File
@@ -28,6 +28,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <process.h>
#include "bacdef.h" #include "bacdef.h"
#include "bacaddr.h" #include "bacaddr.h"
#include "mstp.h" #include "mstp.h"
@@ -125,7 +126,7 @@ int dlmstp_send_pdu(
Transmit_Packet.frame_type = Transmit_Packet.frame_type =
FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY; FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
} }
Transmit_Packet.pdu_len = pdu_len; Transmit_Packet.pdu_len = (uint16_t)pdu_len;
for (i = 0; i < pdu_len; i++) { for (i = 0; i < pdu_len; i++) {
Transmit_Packet.pdu[i] = pdu[i]; Transmit_Packet.pdu[i] = pdu[i];
} }
@@ -179,7 +180,7 @@ static void dlmstp_receive_fsm_task(
(void) pArg; (void) pArg;
(void) SetThreadPriority(GetCurrentThread(), (void) SetThreadPriority(GetCurrentThread(),
THREAD_PRIORITY_TIME_CRITICAL); THREAD_PRIORITY_TIME_CRITICAL);
while (TRUE) { for(;;) {
/* only do receive state machine while we don't have a frame */ /* only do receive state machine while we don't have a frame */
if ((MSTP_Port.ReceivedValidFrame == false) && if ((MSTP_Port.ReceivedValidFrame == false) &&
(MSTP_Port.ReceivedInvalidFrame == false)) { (MSTP_Port.ReceivedInvalidFrame == false)) {
@@ -205,7 +206,7 @@ static void dlmstp_master_fsm_task(
(void) pArg; (void) pArg;
(void) SetThreadPriority(GetCurrentThread(), (void) SetThreadPriority(GetCurrentThread(),
THREAD_PRIORITY_TIME_CRITICAL); THREAD_PRIORITY_TIME_CRITICAL);
while (TRUE) { for(;;) {
switch (MSTP_Port.master_state) { switch (MSTP_Port.master_state) {
case MSTP_MASTER_STATE_IDLE: case MSTP_MASTER_STATE_IDLE:
dwMilliseconds = Tno_token; dwMilliseconds = Tno_token;
@@ -348,7 +349,7 @@ bool dlmstp_compare_data_expecting_reply(
request.address.mac[0] = src_address; request.address.mac[0] = src_address;
request.address.mac_len = 1; request.address.mac_len = 1;
offset = offset =
npdu_decode(&request_pdu[0], NULL, &request.address, (uint16_t)npdu_decode(&request_pdu[0], NULL, &request.address,
&request.npdu_data); &request.npdu_data);
if (request.npdu_data.network_layer_message) { if (request.npdu_data.network_layer_message) {
return false; return false;
@@ -366,7 +367,7 @@ bool dlmstp_compare_data_expecting_reply(
/* decode the reply data */ /* decode the reply data */
bacnet_address_copy(&reply.address, dest_address); bacnet_address_copy(&reply.address, dest_address);
offset = offset =
npdu_decode(&reply_pdu[0], &reply.address, NULL, &reply.npdu_data); (uint16_t)npdu_decode(&reply_pdu[0], &reply.address, NULL, &reply.npdu_data);
if (reply.npdu_data.network_layer_message) { if (reply.npdu_data.network_layer_message) {
return false; return false;
} }
+2 -1
View File
@@ -94,9 +94,10 @@ void strupper(
{ {
char *p; char *p;
for (p = str; *p != '\0'; ++p) { for (p = str; *p != '\0'; ++p) {
*p = toupper(*p); *p = (char)toupper(*p);
} }
} }
#pragma
/**************************************************************************** /****************************************************************************
* DESCRIPTION: Initializes the RS485 hardware and variables, and starts in * DESCRIPTION: Initializes the RS485 hardware and variables, and starts in
+2 -2
View File
@@ -222,7 +222,7 @@ void address_file_init(
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
src.mac_len = (uint8_t) count; src.mac_len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) { 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; src.net = (uint16_t) snet;
if (snet) { if (snet) {
@@ -231,7 +231,7 @@ void address_file_init(
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
src.len = (uint8_t) count; src.len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) { for (index = 0; index < MAX_MAC_LEN; index++) {
src.adr[index] = mac[index]; src.adr[index] = (uint8_t)mac[index];
} }
} else { } else {
src.len = 0; src.len = 0;
+8 -9
View File
@@ -211,7 +211,7 @@ bool apdu_service_supported_to_index(
} }
/* Confirmed ACK Function Handlers */ /* 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( void apdu_set_confirmed_simple_ack_handler(
BACNET_CONFIRMED_SERVICE service_choice, BACNET_CONFIRMED_SERVICE service_choice,
@@ -238,7 +238,7 @@ void apdu_set_confirmed_simple_ack_handler(
case SERVICE_CONFIRMED_VT_CLOSE: case SERVICE_CONFIRMED_VT_CLOSE:
/* Security Services */ /* Security Services */
case SERVICE_CONFIRMED_REQUEST_KEY: case SERVICE_CONFIRMED_REQUEST_KEY:
Confirmed_ACK_Function[service_choice] = (void *) pFunction; Confirmed_ACK_Function[service_choice] = (confirmed_ack_function)pFunction;
break; break;
default: default:
break; break;
@@ -269,7 +269,7 @@ void apdu_set_confirmed_ack_handler(
case SERVICE_CONFIRMED_VT_DATA: case SERVICE_CONFIRMED_VT_DATA:
/* Security Services */ /* Security Services */
case SERVICE_CONFIRMED_AUTHENTICATE: case SERVICE_CONFIRMED_AUTHENTICATE:
Confirmed_ACK_Function[service_choice] = (void *) pFunction; Confirmed_ACK_Function[service_choice] = pFunction;
break; break;
default: default:
break; break;
@@ -366,7 +366,7 @@ void apdu_handler(
uint8_t service_choice = 0; uint8_t service_choice = 0;
uint8_t *service_request = NULL; uint8_t *service_request = NULL;
uint16_t service_request_len = 0; 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; uint8_t tag_number = 0;
uint32_t len_value = 0; uint32_t len_value = 0;
uint32_t error_code = 0; uint32_t error_code = 0;
@@ -434,7 +434,7 @@ void apdu_handler(
case SERVICE_CONFIRMED_VT_CLOSE: case SERVICE_CONFIRMED_VT_CLOSE:
/* Security Services */ /* Security Services */
case SERVICE_CONFIRMED_REQUEST_KEY: case SERVICE_CONFIRMED_REQUEST_KEY:
if (Confirmed_ACK_Function[service_choice]) { if (Confirmed_ACK_Function[service_choice] != NULL) {
((confirmed_simple_ack_function) ((confirmed_simple_ack_function)
Confirmed_ACK_Function[service_choice]) (src, Confirmed_ACK_Function[service_choice]) (src,
invoke_id); invoke_id);
@@ -458,7 +458,7 @@ void apdu_handler(
} }
service_choice = apdu[len++]; service_choice = apdu[len++];
service_request = &apdu[len]; service_request = &apdu[len];
service_request_len = apdu_len - len; service_request_len = apdu_len - (uint16_t)len;
switch (service_choice) { switch (service_choice) {
case SERVICE_CONFIRMED_GET_ALARM_SUMMARY: case SERVICE_CONFIRMED_GET_ALARM_SUMMARY:
case SERVICE_CONFIRMED_GET_ENROLLMENT_SUMMARY: case SERVICE_CONFIRMED_GET_ENROLLMENT_SUMMARY:
@@ -478,9 +478,8 @@ void apdu_handler(
case SERVICE_CONFIRMED_VT_DATA: case SERVICE_CONFIRMED_VT_DATA:
/* Security Services */ /* Security Services */
case SERVICE_CONFIRMED_AUTHENTICATE: case SERVICE_CONFIRMED_AUTHENTICATE:
if (Confirmed_ACK_Function[service_choice]) { if (Confirmed_ACK_Function[service_choice] != NULL) {
((confirmed_ack_function) (Confirmed_ACK_Function[service_choice])
Confirmed_ACK_Function[service_choice])
(service_request, service_request_len, src, (service_request, service_request_len, src,
&service_ack_data); &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 */ /* The static variables that store the apdu buffer between function calls */
static uint8_t *apdu = NULL; 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; static uint32_t apdu_len = 0;
int len = 0; int len = 0;
int tag_len = 0; int tag_len = 0;
@@ -1084,10 +1084,10 @@ bool bacapp_parse_application_data(
datetime_set_date(&value->type.Date, (uint16_t) year, datetime_set_date(&value->type.Date, (uint16_t) year,
(uint8_t) month, (uint8_t) day); (uint8_t) month, (uint8_t) day);
} else if (count == 4) { } else if (count == 4) {
value->type.Date.year = year; value->type.Date.year = (uint16_t)year;
value->type.Date.month = month; value->type.Date.month = (uint8_t)month;
value->type.Date.day = day; value->type.Date.day = (uint8_t)day;
value->type.Date.wday = wday; value->type.Date.wday = (uint8_t)wday;
} else { } else {
status = false; status = false;
} }
@@ -1097,18 +1097,18 @@ bool bacapp_parse_application_data(
sscanf(argv, "%d:%d:%d.%d", &hour, &min, &sec, sscanf(argv, "%d:%d:%d.%d", &hour, &min, &sec,
&hundredths); &hundredths);
if (count == 4) { if (count == 4) {
value->type.Time.hour = hour; value->type.Time.hour = (uint8_t)hour;
value->type.Time.min = min; value->type.Time.min = (uint8_t)min;
value->type.Time.sec = sec; value->type.Time.sec = (uint8_t)sec;
value->type.Time.hundredths = hundredths; value->type.Time.hundredths = (uint8_t)hundredths;
} else if (count == 3) { } else if (count == 3) {
value->type.Time.hour = hour; value->type.Time.hour = (uint8_t)hour;
value->type.Time.min = min; value->type.Time.min = (uint8_t)min;
value->type.Time.sec = sec; value->type.Time.sec = (uint8_t)sec;
value->type.Time.hundredths = 0; value->type.Time.hundredths = 0;
} else if (count == 2) { } else if (count == 2) {
value->type.Time.hour = hour; value->type.Time.hour = (uint8_t)hour;
value->type.Time.min = min; value->type.Time.min = (uint8_t)min;
value->type.Time.sec = 0; value->type.Time.sec = 0;
value->type.Time.hundredths = 0; value->type.Time.hundredths = 0;
} else { } else {
@@ -1118,7 +1118,7 @@ bool bacapp_parse_application_data(
case BACNET_APPLICATION_TAG_OBJECT_ID: case BACNET_APPLICATION_TAG_OBJECT_ID:
count = sscanf(argv, "%d:%d", &object_type, &instance); count = sscanf(argv, "%d:%d", &object_type, &instance);
if (count == 2) { 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; value->type.Object_Id.instance = instance;
} else { } else {
status = false; 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, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ 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); encode_unsigned16(&pdu[2], BVLC_length);
len = 4; 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, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ 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); encode_unsigned16(&pdu[2], BVLC_length);
len = 4; 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, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ 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); encode_unsigned16(&pdu[2], BVLC_length);
len = 4; len = 4;
} }
@@ -408,7 +408,7 @@ static int bvlc_encode_read_fdt_ack(
pdu_len += len; pdu_len += len;
len = encode_unsigned16(&pdu[pdu_len], FD_Table[i].time_to_live); len = encode_unsigned16(&pdu[pdu_len], FD_Table[i].time_to_live);
pdu_len += len; 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); len = encode_unsigned16(&pdu[pdu_len], seconds_remaining);
pdu_len += len; pdu_len += len;
} }
@@ -455,7 +455,7 @@ int bvlc_encode_original_unicast_npdu(
/* The 2-octet BVLC Length field is the length, in octets, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ 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; len = encode_unsigned16(&pdu[2], BVLC_length) + 2;
for (i = 0; i < npdu_length; i++) { for (i = 0; i < npdu_length; i++) {
pdu[len] = npdu[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, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ 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; len = encode_unsigned16(&pdu[2], BVLC_length) + 2;
for (i = 0; i < npdu_length; i++) { for (i = 0; i < npdu_length; i++) {
pdu[len] = npdu[i]; pdu[len] = npdu[i];
@@ -507,7 +507,7 @@ static void bvlc_internet_to_bacnet_address(
len = encode_unsigned32(&src->mac[0], address); len = encode_unsigned32(&src->mac[0], address);
port = ntohs(sin->sin_port); port = ntohs(sin->sin_port);
len += encode_unsigned16(&src->mac[4], port); len += encode_unsigned16(&src->mac[4], port);
src->mac_len = len; src->mac_len = (uint8_t)len;
src->net = 0; src->net = 0;
src->len = 0; src->len = 0;
} }
@@ -668,7 +668,7 @@ static void bvlc_bdt_forward_npdu(
unsigned i = 0; /* loop counter */ unsigned i = 0; /* loop counter */
struct sockaddr_in bip_dest = { 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);
/* loop through the BDT and send one to each entry, except us */ /* loop through the BDT and send one to each entry, except us */
for (i = 0; i < MAX_BBMD_ENTRIES; i++) { for (i = 0; i < MAX_BBMD_ENTRIES; i++) {
if (BBMD_Table[i].valid) { if (BBMD_Table[i].valid) {
@@ -710,7 +710,7 @@ static void bvlc_forward_npdu(
uint16_t mtu_len = 0; uint16_t mtu_len = 0;
struct sockaddr_in bip_dest = { 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_addr.s_addr = htonl(bip_get_broadcast_addr());
bip_dest.sin_port = htons(bip_get_port()); bip_dest.sin_port = htons(bip_get_port());
bvlc_send_mpdu(&bip_dest, mtu, mtu_len); bvlc_send_mpdu(&bip_dest, mtu, mtu_len);
@@ -727,7 +727,7 @@ static void bvlc_fdt_forward_npdu(
unsigned i = 0; /* loop counter */ unsigned i = 0; /* loop counter */
struct sockaddr_in bip_dest = { 0 }; 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 */ /* loop through the FDT and send one to each entry */
for (i = 0; i < MAX_FD_ENTRIES; i++) { for (i = 0; i < MAX_FD_ENTRIES; i++) {
if (FD_Table[i].valid && FD_Table[i].seconds_remaining) { if (FD_Table[i].valid && FD_Table[i].seconds_remaining) {
@@ -769,7 +769,7 @@ void bvlc_register_with_bbmd(
Write Broadcast Distribution Table, or Write Broadcast Distribution Table, or
register with the BBMD as a Foreign Device */ register with the BBMD as a Foreign Device */
mtu_len = 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); bvlc_send_mpdu(&Remote_BBMD, &mtu[0], mtu_len);
} }
@@ -780,7 +780,7 @@ static void bvlc_send_result(
uint8_t mtu[MAX_MPDU] = { 0 }; uint8_t mtu[MAX_MPDU] = { 0 };
uint16_t mtu_len = 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); bvlc_send_mpdu(dest, mtu, mtu_len);
return; return;
@@ -792,7 +792,7 @@ static int bvlc_send_bdt(
uint8_t mtu[MAX_MPDU] = { 0 }; uint8_t mtu[MAX_MPDU] = { 0 };
uint16_t mtu_len = 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) { if (mtu_len) {
bvlc_send_mpdu(dest, &mtu[0], 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 }; uint8_t mtu[MAX_MPDU] = { 0 };
uint16_t mtu_len = 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) { if (mtu_len) {
bvlc_send_mpdu(dest, &mtu[0], 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_addr.s_addr = htonl(address.s_addr);
bvlc_dest.sin_port = htons(port); 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 = 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); 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); 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, decode_tag_number_and_value(&apdu[len], &tag_number,
&len_value); &len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value); len += decode_unsigned(&apdu[len], len_value, &decoded_value);
value->priority = decoded_value; value->priority = (uint8_t)decoded_value;
} else { } else {
value->priority = BACNET_NO_PRIORITY; 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 frame_type = mstp_port->OutputBuffer[2];
uint8_t destination = mstp_port->OutputBuffer[3]; uint8_t destination = mstp_port->OutputBuffer[3];
RS485_Send_Frame(mstp_port, RS485_Send_Frame(mstp_port,
(uint8_t *) & mstp_port->OutputBuffer[0], length); (uint8_t *) & mstp_port->OutputBuffer[0], (uint16_t)length);
mstp_port->FrameCount++; mstp_port->FrameCount++;
switch (frame_type) { switch (frame_type) {
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: 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 */ /* then call MSTP_Create_And_Send_Frame to transmit the reply frame */
/* and enter the IDLE state to wait for the next frame. */ /* and enter the IDLE state to wait for the next frame. */
RS485_Send_Frame(mstp_port, 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; mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
} else { } else {
/* DeferredReply */ /* DeferredReply */
+2 -2
View File
@@ -139,7 +139,7 @@ int ptransfer_decode_service_request(
return -1; return -1;
} }
len = decode_len; len = decode_len;
private_data->vendorID = unsigned_value; private_data->vendorID = (uint16_t)unsigned_value;
/* Tag 1: serviceNumber */ /* Tag 1: serviceNumber */
decode_len = decode_context_unsigned(&apdu[len], 1, &unsigned_value); decode_len = decode_context_unsigned(&apdu[len], 1, &unsigned_value);
if (decode_len < 0) { if (decode_len < 0) {
@@ -279,7 +279,7 @@ int ptransfer_error_decode_service_request(
return -1; return -1;
} }
len += decode_len; len += decode_len;
private_data->vendorID = unsigned_value; private_data->vendorID = (uint16_t)unsigned_value;
/* Tag 2: serviceNumber */ /* Tag 2: serviceNumber */
decode_len = decode_context_unsigned(&apdu[len], 2, &unsigned_value); decode_len = decode_context_unsigned(&apdu[len], 2, &unsigned_value);
if (decode_len < 0) { 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++) { for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) {
if (TSM_List[i].InvokeID == invokeID) { if (TSM_List[i].InvokeID == invokeID) {
index = i; index = (uint8_t)i;
break; break;
} }
} }
@@ -89,7 +89,7 @@ static uint8_t tsm_find_first_free_index(
for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) { for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) {
if (TSM_List[i].InvokeID == 0) { if (TSM_List[i].InvokeID == 0) {
index = i; index = (uint8_t)i;
break; break;
} }
} }
@@ -238,7 +238,7 @@ bool tsm_get_transaction_pdu(
/* FIXME: we may want to free the transaction so it doesn't timeout */ /* FIXME: we may want to free the transaction so it doesn't timeout */
/* retrieve the transaction */ /* retrieve the transaction */
/* FIXME: bounds check the pdu_len? */ /* 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++) { for (j = 0; j < *apdu_len; j++) {
apdu[j] = TSM_List[index].apdu[j]; apdu[j] = TSM_List[index].apdu[j];
} }