Corrected warnings found by splint.
This commit is contained in:
@@ -84,8 +84,8 @@ int ptransfer_decode_service_request(
|
||||
unsigned apdu_len,
|
||||
BACNET_PRIVATE_TRANSFER_DATA * private_data)
|
||||
{
|
||||
unsigned len = 0; /* return value */
|
||||
unsigned decode_len = 0; /* return value */
|
||||
int len = 0; /* return value */
|
||||
int decode_len = 0; /* return value */
|
||||
uint32_t unsigned_value = 0;
|
||||
|
||||
/* check for value pointers */
|
||||
@@ -111,15 +111,15 @@ int ptransfer_decode_service_request(
|
||||
/* don't decode the serviceParameters here */
|
||||
private_data->serviceParameters = &apdu[len];
|
||||
private_data->serviceParametersLen =
|
||||
apdu_len - len - 1 /*closing tag */ ;
|
||||
(int)apdu_len - len - 1 /*closing tag */ ;
|
||||
/* len includes the data and the closing tag */
|
||||
len = apdu_len;
|
||||
len = (int)apdu_len;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return (int) len;
|
||||
return len;
|
||||
}
|
||||
|
||||
int ptransfer_error_encode_apdu(
|
||||
@@ -181,8 +181,8 @@ int ptransfer_error_decode_service_request(
|
||||
BACNET_ERROR_CODE * error_code,
|
||||
BACNET_PRIVATE_TRANSFER_DATA * private_data)
|
||||
{
|
||||
unsigned len = 0; /* return value */
|
||||
unsigned decode_len = 0; /* return value */
|
||||
int len = 0; /* return value */
|
||||
int decode_len = 0; /* return value */
|
||||
uint8_t tag_number = 0;
|
||||
uint32_t len_value_type = 0;
|
||||
uint32_t unsigned_value = 0;
|
||||
@@ -248,14 +248,14 @@ int ptransfer_error_decode_service_request(
|
||||
len++;
|
||||
/* don't decode the serviceParameters here */
|
||||
private_data->serviceParameters = &apdu[len];
|
||||
private_data->serviceParametersLen = apdu_len - len - 1 /*closing tag */ ;
|
||||
private_data->serviceParametersLen = (int)apdu_len - len - 1 /*closing tag */ ;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
/* we could check for a closing tag of 3 */
|
||||
}
|
||||
|
||||
return (int) len;
|
||||
return len;
|
||||
}
|
||||
|
||||
int ptransfer_ack_encode_apdu(
|
||||
@@ -304,8 +304,8 @@ int ptransfer_ack_encode_apdu(
|
||||
#ifdef TEST
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "ctest.h"
|
||||
#include "bacapp.h"
|
||||
#include "ctest.h"
|
||||
#include "bacapp.h"
|
||||
|
||||
int ptransfer_decode_apdu(
|
||||
uint8_t * apdu,
|
||||
@@ -403,25 +403,25 @@ void test_Private_Transfer_Ack(
|
||||
uint8_t test_invoke_id = 0;
|
||||
BACNET_PRIVATE_TRANSFER_DATA private_data;
|
||||
BACNET_PRIVATE_TRANSFER_DATA test_data;
|
||||
uint8_t test_value[480] = { 0 };
|
||||
int private_data_len = 0;
|
||||
uint8_t private_data_chunk[32] = {"I Love You, Patricia!"};
|
||||
BACNET_APPLICATION_DATA_VALUE data_value;
|
||||
BACNET_APPLICATION_DATA_VALUE test_data_value;
|
||||
uint8_t test_value[480] = { 0 };
|
||||
int private_data_len = 0;
|
||||
uint8_t private_data_chunk[32] = {"I Love You, Patricia!"};
|
||||
BACNET_APPLICATION_DATA_VALUE data_value;
|
||||
BACNET_APPLICATION_DATA_VALUE test_data_value;
|
||||
|
||||
private_data.vendorID = BACNET_VENDOR_ID;
|
||||
private_data.serviceNumber = 1;
|
||||
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_OCTET_STRING,
|
||||
&private_data_chunk[0], &data_value);
|
||||
private_data_len = bacapp_encode_application_data(
|
||||
&test_value[0],
|
||||
&data_value);
|
||||
|
||||
private_data.serviceParameters = &test_value[0];
|
||||
private_data.serviceParametersLen = private_data_len;
|
||||
|
||||
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_OCTET_STRING,
|
||||
&private_data_chunk[0], &data_value);
|
||||
private_data_len = bacapp_encode_application_data(
|
||||
&test_value[0],
|
||||
&data_value);
|
||||
|
||||
private_data.serviceParameters = &test_value[0];
|
||||
private_data.serviceParametersLen = private_data_len;
|
||||
|
||||
|
||||
len = ptransfer_ack_encode_apdu(&apdu[0], invoke_id, &private_data);
|
||||
ct_test(pTest, len != 0);
|
||||
@@ -436,11 +436,11 @@ void test_Private_Transfer_Ack(
|
||||
ct_test(pTest, test_data.serviceNumber == private_data.serviceNumber);
|
||||
ct_test(pTest,
|
||||
test_data.serviceParametersLen == private_data.serviceParametersLen);
|
||||
len = bacapp_decode_application_data(
|
||||
test_data.serviceParameters,
|
||||
test_data.serviceParametersLen,
|
||||
&test_data_value);
|
||||
ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true);
|
||||
len = bacapp_decode_application_data(
|
||||
test_data.serviceParameters,
|
||||
test_data.serviceParametersLen,
|
||||
&test_data_value);
|
||||
ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true);
|
||||
}
|
||||
|
||||
void test_Private_Transfer_Error(
|
||||
@@ -455,26 +455,26 @@ void test_Private_Transfer_Error(
|
||||
BACNET_ERROR_CODE error_code = ERROR_CODE_OPERATIONAL_PROBLEM;
|
||||
BACNET_ERROR_CLASS test_error_class = 0;
|
||||
BACNET_ERROR_CODE test_error_code = 0;
|
||||
BACNET_PRIVATE_TRANSFER_DATA private_data;
|
||||
BACNET_PRIVATE_TRANSFER_DATA test_data;
|
||||
uint8_t test_value[480] = { 0 };
|
||||
int private_data_len = 0;
|
||||
uint8_t private_data_chunk[32] = {"I Love You, Patricia!"};
|
||||
BACNET_APPLICATION_DATA_VALUE data_value;
|
||||
BACNET_APPLICATION_DATA_VALUE test_data_value;
|
||||
BACNET_PRIVATE_TRANSFER_DATA private_data;
|
||||
BACNET_PRIVATE_TRANSFER_DATA test_data;
|
||||
uint8_t test_value[480] = { 0 };
|
||||
int private_data_len = 0;
|
||||
uint8_t private_data_chunk[32] = {"I Love You, Patricia!"};
|
||||
BACNET_APPLICATION_DATA_VALUE data_value;
|
||||
BACNET_APPLICATION_DATA_VALUE test_data_value;
|
||||
|
||||
private_data.vendorID = BACNET_VENDOR_ID;
|
||||
private_data.serviceNumber = 1;
|
||||
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_OCTET_STRING,
|
||||
&private_data_chunk[0], &data_value);
|
||||
private_data_len = bacapp_encode_application_data(
|
||||
&test_value[0],
|
||||
&data_value);
|
||||
private_data.serviceParameters = &test_value[0];
|
||||
private_data.serviceParametersLen = private_data_len;
|
||||
|
||||
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_OCTET_STRING,
|
||||
&private_data_chunk[0], &data_value);
|
||||
private_data_len = bacapp_encode_application_data(
|
||||
&test_value[0],
|
||||
&data_value);
|
||||
private_data.serviceParameters = &test_value[0];
|
||||
private_data.serviceParametersLen = private_data_len;
|
||||
|
||||
len = ptransfer_error_encode_apdu(&apdu[0], invoke_id,
|
||||
error_class, error_code, &private_data);
|
||||
ct_test(pTest, len != 0);
|
||||
@@ -493,41 +493,41 @@ void test_Private_Transfer_Error(
|
||||
ct_test(pTest, test_error_code == error_code);
|
||||
ct_test(pTest,
|
||||
test_data.serviceParametersLen == private_data.serviceParametersLen);
|
||||
len = bacapp_decode_application_data(
|
||||
test_data.serviceParameters,
|
||||
test_data.serviceParametersLen,
|
||||
&test_data_value);
|
||||
ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true);
|
||||
len = bacapp_decode_application_data(
|
||||
test_data.serviceParameters,
|
||||
test_data.serviceParametersLen,
|
||||
&test_data_value);
|
||||
ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true);
|
||||
}
|
||||
|
||||
void test_Private_Transfer_Request(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[480] = { 0 };
|
||||
uint8_t test_value[480] = { 0 };
|
||||
uint8_t test_value[480] = { 0 };
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
int apdu_len = 0;
|
||||
uint8_t invoke_id = 128;
|
||||
uint8_t test_invoke_id = 0;
|
||||
int private_data_len = 0;
|
||||
uint8_t private_data_chunk[32] = {"I Love You, Patricia!"};
|
||||
BACNET_APPLICATION_DATA_VALUE data_value;
|
||||
BACNET_APPLICATION_DATA_VALUE test_data_value;
|
||||
uint8_t test_invoke_id = 0;
|
||||
int private_data_len = 0;
|
||||
uint8_t private_data_chunk[32] = {"I Love You, Patricia!"};
|
||||
BACNET_APPLICATION_DATA_VALUE data_value;
|
||||
BACNET_APPLICATION_DATA_VALUE test_data_value;
|
||||
BACNET_PRIVATE_TRANSFER_DATA private_data;
|
||||
BACNET_PRIVATE_TRANSFER_DATA test_data;
|
||||
|
||||
private_data.vendorID = BACNET_VENDOR_ID;
|
||||
private_data.serviceNumber = 1;
|
||||
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_OCTET_STRING,
|
||||
&private_data_chunk[0], &data_value);
|
||||
private_data_len = bacapp_encode_application_data(
|
||||
&test_value[0],
|
||||
&data_value);
|
||||
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_OCTET_STRING,
|
||||
&private_data_chunk[0], &data_value);
|
||||
private_data_len = bacapp_encode_application_data(
|
||||
&test_value[0],
|
||||
&data_value);
|
||||
private_data.serviceParameters = &test_value[0];
|
||||
private_data.serviceParametersLen = private_data_len;
|
||||
|
||||
|
||||
len = ptransfer_encode_apdu(&apdu[0], invoke_id, &private_data);
|
||||
ct_test(pTest, len != 0);
|
||||
apdu_len = len;
|
||||
@@ -536,12 +536,12 @@ void test_Private_Transfer_Request(
|
||||
ct_test(pTest, test_data.vendorID == private_data.vendorID);
|
||||
ct_test(pTest, test_data.serviceNumber == private_data.serviceNumber);
|
||||
ct_test(pTest,
|
||||
test_data.serviceParametersLen == private_data.serviceParametersLen);
|
||||
len = bacapp_decode_application_data(
|
||||
test_data.serviceParameters,
|
||||
test_data.serviceParametersLen,
|
||||
&test_data_value);
|
||||
ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true);
|
||||
test_data.serviceParametersLen == private_data.serviceParametersLen);
|
||||
len = bacapp_decode_application_data(
|
||||
test_data.serviceParameters,
|
||||
test_data.serviceParametersLen,
|
||||
&test_data_value);
|
||||
ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user