// if new socket object is added in socket list after below logic is ran.
// new socket will be started to read after next while loop
- uint32_t length = CAEDRGetSocketListLength();
+ size_t length = CAEDRGetSocketListLength();
if (0 != length)
{
- for (uint32_t idx = 0; idx < length; idx++)
+ for (size_t idx = 0; idx < length; idx++)
{
CAEDRNativeReadData(env, idx);
}
return CA_STATUS_OK;
}
-CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t idx)
+CAResult_t CAEDRNativeReadData(JNIEnv *env, size_t idx)
{
if ((*env)->ExceptionCheck(env))
{
* @param[in] id index of remote address.
* @return ::CA_STATUS_OK or Appropriate error code.
*/
-CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id);
+CAResult_t CAEDRNativeReadData(JNIEnv *env, size_t id);
/**
* Start Listen Task.
return;
}
-jobject CAEDRNativeGetDeviceSocket(uint32_t index)
+jobject CAEDRNativeGetDeviceSocket(size_t index)
{
if (!g_deviceObjectList)
{
return NULL;
}
-jobject CAEDRNativeGetInputStream(uint32_t index)
+jobject CAEDRNativeGetInputStream(size_t index)
{
if (!g_deviceObjectList)
{
return jarrayObj;
}
-uint32_t CAEDRGetSocketListLength()
+size_t CAEDRGetSocketListLength()
{
if (!g_deviceObjectList)
{
* @param[in] index index of device list.
* @return Device socket object or NULL.
*/
-jobject CAEDRNativeGetDeviceSocket(uint32_t index);
+jobject CAEDRNativeGetDeviceSocket(size_t index);
/**
* Get device socket address.
* @param[in] index index of device list.
* @return Input stream object or NULL.
*/
-jobject CAEDRNativeGetInputStream(uint32_t index);
+jobject CAEDRNativeGetInputStream(size_t index);
/**
* Get length of device socket list.
* @return length of list.
*/
-uint32_t CAEDRGetSocketListLength();
+size_t CAEDRGetSocketListLength();
/**
* Get device information from list.
return sentLen;
}
-CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
+CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, size_t *size)
{
VERIFY_NON_NULL(info, TAG, "LocalConnectivity info is null");
return;
}
- int lengthData = u_arraylist_length(g_multicastDataList);
- for(int len = 0; len < lengthData; len++)
+ size_t lengthData = u_arraylist_length(g_multicastDataList);
+ for(size_t len = 0; len < lengthData; len++)
{
// Adding to pending list
EDRData *multicastData =
return NULL;
}
- uint32_t length = u_arraylist_length(g_deviceStateList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_deviceStateList);
+ for (size_t index = 0; index < length; index++)
{
CAConnectedDeviceInfo_t* deviceInfo =
(CAConnectedDeviceInfo_t*) u_arraylist_get(g_deviceStateList, index);
if (g_context && g_deviceList)
{
- uint32_t length = u_arraylist_length(g_deviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_deviceList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceList, index);
if (!jarrayObj)
goto error_exit;
}
- uint32_t length = u_arraylist_length(g_deviceList);
+ size_t length = u_arraylist_length(g_deviceList);
g_targetCnt = length;
jbyteArray jni_arr = (*env)->NewByteArray(env, dataLen);
(*env)->SetByteArrayRegion(env, jni_arr, 0, dataLen, (jbyte*) data);
g_sendBuffer = (jbyteArray)(*env)->NewGlobalRef(env, jni_arr);
- for (uint32_t index = 0; index < length; index++)
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceList, index);
if (!jarrayObj)
return CA_STATUS_OK;
}
- uint32_t length = u_arraylist_length(g_gattObjectList);
+ size_t length = u_arraylist_length(g_gattObjectList);
OIC_LOG_V(DEBUG, TAG, "list length : %d", length);
- for (uint32_t index = 0; index < length; index++)
+ for (size_t index = 0; index < length; index++)
{
OIC_LOG(DEBUG, TAG, "start CALEClientDisconnectAll");
jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
return CA_STATUS_FAILED;
}
- uint32_t length = u_arraylist_length(g_gattObjectList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_gattObjectList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
if (!jarrayObj)
return true;
}
- uint32_t length = u_arraylist_length(g_deviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_deviceList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceList, index);
if (!jarrayObj)
return CA_STATUS_FAILED;
}
- uint32_t length = u_arraylist_length(g_deviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_deviceList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceList, index);
if (!jarrayObj)
return CA_STATUS_FAILED;
}
- uint32_t length = u_arraylist_length(g_deviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_deviceList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_deviceList, index);
if (!jarrayObj)
VERIFY_NON_NULL(env, TAG, "env is null");
VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", true);
- uint32_t length = u_arraylist_length(g_gattObjectList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_gattObjectList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
if (!jarrayObj)
VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", NULL);
oc_mutex_lock(g_gattObjectMutex);
- uint32_t length = u_arraylist_length(g_gattObjectList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_gattObjectList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
if (!jarrayObj)
return CA_STATUS_OK;
}
- uint32_t length = u_arraylist_length(g_gattObjectList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_gattObjectList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
if (!jarrayObj)
return CA_STATUS_OK;
}
- uint32_t length = u_arraylist_length(g_gattObjectList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_gattObjectList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
if (!jarrayObj)
return CA_STATUS_OK;
}
- uint32_t length = u_arraylist_length(g_gattObjectList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_gattObjectList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
if (!jarrayObj)
return CA_STATUS_FAILED;
}
- uint32_t length = u_arraylist_length(g_connectedDeviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_connectedDeviceList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_connectedDeviceList, index);
if (!jarrayObj)
oc_mutex_lock(g_threadSendMutex);
- uint32_t length = u_arraylist_length(g_connectedDeviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_connectedDeviceList);
+ for (size_t index = 0; index < length; index++)
{
OIC_LOG(DEBUG, TAG, "check device address");
jobject jarrayObj = (jobject) u_arraylist_get(g_connectedDeviceList, index);
g_sendBuffer = (jbyteArray)(*env)->NewGlobalRef(env, jni_arr);
CACheckJNIException(env);
- uint32_t length = u_arraylist_length(g_connectedDeviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_connectedDeviceList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_connectedDeviceList, index);
if (!jarrayObj)
return false;
}
- uint32_t length = u_arraylist_length(g_connectedDeviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_connectedDeviceList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_connectedDeviceList, index);
return CA_STATUS_FAILED;
}
- uint32_t length = u_arraylist_length(g_connectedDeviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_connectedDeviceList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_connectedDeviceList, index);
if (jarrayObj)
return CA_STATUS_FAILED;
}
- uint32_t length = u_arraylist_length(g_connectedDeviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(g_connectedDeviceList);
+ for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_connectedDeviceList, index);
VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", false);
VERIFY_NON_NULL_RET(deviceList, TAG, "deviceList is null", false);
- uint32_t length = u_arraylist_length(deviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(deviceList);
+ for (size_t index = 0; index < length; index++)
{
CALEState_t* state = (CALEState_t*) u_arraylist_get(deviceList, index);
if (!state)
VERIFY_NON_NULL(deviceList, TAG, "deviceList is null");
oc_mutex_lock(deviceListMutex);
- uint32_t length = u_arraylist_length(deviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(deviceList);
+ for (size_t index = 0; index < length; index++)
{
CALEState_t* state = (CALEState_t*) u_arraylist_get(deviceList, index);
if (!state)
VERIFY_NON_NULL(remoteAddress, TAG, "remoteAddress is null");
VERIFY_NON_NULL(deviceList, TAG, "deviceList is null");
- uint32_t length = u_arraylist_length(deviceList);
- for (uint32_t index = 0; index < length; index++)
+ size_t length = u_arraylist_length(deviceList);
+ for (size_t index = 0; index < length; index++)
{
CALEState_t* state = (CALEState_t*) u_arraylist_get(deviceList, index);
if (!state)
VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", NULL);
VERIFY_NON_NULL_RET(deviceList, TAG, "deviceList is null", NULL);
- uint32_t length = u_arraylist_length(deviceList);
+ size_t length = u_arraylist_length(deviceList);
- for (uint32_t index = 0; index < length; index++)
+ for (size_t index = 0; index < length; index++)
{
CALEState_t* state = (CALEState_t*) u_arraylist_get(deviceList, index);
if (!state)
{
return state;
}
- OIC_LOG_V(DEBUG, TAG, "state addr[%s, %d]", state->address, index);
+ OIC_LOG_V(DEBUG, TAG, "state addr[%s, %" PRIuPTR "]", state->address, index);
}
OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in deviceStateList", remoteAddress, length);
const uint16_t port,
u_arraylist_t *senderInfoList,
CABLESenderInfo_t **senderInfo,
- uint32_t *senderIndex);
+ size_t *senderIndex);
/**
* get ports related to remote address. It is need because multi application
const uint16_t port,
u_arraylist_t *senderInfoList,
CABLESenderInfo_t **senderInfo,
- uint32_t *senderIndex)
+ size_t *senderIndex)
{
VERIFY_NON_NULL_RET(leAddress,
CALEADAPTER_TAG,
"NULL index argument",
CA_STATUS_INVALID_PARAM);
- const uint32_t listLength = u_arraylist_length(senderInfoList);
- const uint32_t addrLength = strlen(leAddress);
- for (uint32_t index = 0; index < listLength; index++)
+ const size_t listLength = u_arraylist_length(senderInfoList);
+ const size_t addrLength = strlen(leAddress);
+ for (size_t index = 0; index < listLength; index++)
{
CABLESenderInfo_t *info = (CABLESenderInfo_t *) u_arraylist_get(senderInfoList, index);
if (!info || !(info->remoteEndpoint))
}
CABLESenderInfo_t *senderInfo = NULL;
- uint32_t senderIndex = 0;
+ size_t senderIndex = 0;
//packet parsing
CABLEPacketStart_t startFlag = CA_BLE_PACKET_NOT_START;
bleData->dataLen - (CA_BLE_HEADER_SIZE + CA_BLE_LENGTH_HEADER_SIZE);
OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Total data to be accumulated [%u] bytes",
newSender->totalDataLen);
- OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "data received in the first packet [%zu] bytes",
+ OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "data received in the first packet [%" PRIuPTR "] bytes",
dataOnlyLen);
newSender->defragData = OICCalloc(newSender->totalDataLen + 1,
if (senderInfo->recvDataLen + dataOnlyLen > senderInfo->totalDataLen)
{
OIC_LOG_V(ERROR, CALEADAPTER_TAG,
- "Data Length exceeding error!! Receiving [%zu] total length [%u]",
+ "Data Length exceeding error!! Receiving [%" PRIuPTR "] total length [%u]",
senderInfo->recvDataLen + dataOnlyLen, senderInfo->totalDataLen);
u_arraylist_remove(bleData->senderInfo, senderIndex);
OICFree(senderInfo->defragData);
oc_mutex_unlock(bleReceiveDataMutex);
return;
}
- OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Copying the data of length [%zu]",
+ OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Copying the data of length [%" PRIuPTR "]",
dataOnlyLen);
memcpy(senderInfo->defragData + senderInfo->recvDataLen,
bleData->data + CA_BLE_HEADER_SIZE,
}
OIC_LOG_V(DEBUG, CALEADAPTER_TAG,
- "Packet info: data size[%d] midPacketCount[%u] remainingLen[%zu] totalLength[%zu]",
+ "Packet info: data size[%d] midPacketCount[%u] remainingLen[%" PRIuPTR "] totalLength[%" PRIuPTR "]",
bleData->dataLen, midPacketCount, remainingLen, totalLength);
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
- "Server total Data length with header is [%zu]",
+ "Server total Data length with header is [%" PRIuPTR "]",
totalLength);
uint8_t dataSegment[CA_SUPPORTED_BLE_MTU_SIZE] = {0};
}
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
- "Server Sent Unicast Last Data - data length [%zu]",
+ "Server Sent Unicast Last Data - data length [%" PRIuPTR "]",
remainingLen + CA_BLE_HEADER_SIZE);
}
}
}
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
- "Server Sent Multicast Last Data - data length [%zu]",
+ "Server Sent Multicast Last Data - data length [%" PRIuPTR "]",
remainingLen + CA_BLE_HEADER_SIZE);
}
#else
}
OIC_LOG_V(DEBUG, CALEADAPTER_TAG,
- "Packet info: data size[%d] midPacketCount[%u] remainingLen[%zu] totalLength[%zu]",
+ "Packet info: data size[%d] midPacketCount[%u] remainingLen[%" PRIuPTR "] totalLength[%" PRIuPTR "]",
bleData->dataLen, midPacketCount, remainingLen, totalLength);
uint8_t dataSegment[CA_SUPPORTED_BLE_MTU_SIZE] = {0};
}
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
- "Client Sent Unicast Last Data - data length [%zu]",
+ "Client Sent Unicast Last Data - data length [%" PRIuPTR "]",
remainingLen + CA_BLE_HEADER_SIZE);
}
}
}
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
- "Client Sent Multicast Last Data - data length [%zu]",
+ "Client Sent Multicast Last Data - data length [%" PRIuPTR "]",
remainingLen + CA_BLE_HEADER_SIZE);
}
#else
* @return ::CA_STATUS_OK or Appropriate error code.
*/
static CAResult_t CAGetLEInterfaceInformation(CAEndpoint_t **info,
- uint32_t *size);
+ size_t *size);
/**
* Read Synchronous API callback.
return dataLen;
}
-static CAResult_t CAGetLEInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
+static CAResult_t CAGetLEInterfaceInformation(CAEndpoint_t **info, size_t *size)
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
VERIFY_NON_NULL_VOID(address, CALEADAPTER_TAG, "address");
CABLESenderInfo_t *senderInfo = NULL;
- uint32_t senderIndex = 0;
+ size_t senderIndex = 0;
u_arraylist_t *portList = u_arraylist_create();
if (CA_STATUS_OK == CALEGetPortsFromSenderInfo(address, dataInfoList, portList))
{
- uint32_t arrayLength = u_arraylist_length(portList);
- for (uint32_t i = 0; i < arrayLength; i++)
+ size_t arrayLength = u_arraylist_length(portList);
+ for (size_t i = 0; i < arrayLength; i++)
{
uint16_t *port = (uint16_t *)u_arraylist_get(portList, i);
if (!port)
CALEADAPTER_TAG,
"NULL BLE address argument");
- const uint32_t listLength = u_arraylist_length(senderInfoList);
- const uint32_t addrLength = strlen(leAddress);
+ const size_t listLength = u_arraylist_length(senderInfoList);
+ const size_t addrLength = strlen(leAddress);
- for (uint32_t index = 0; index < listLength; index++)
+ for (size_t index = 0; index < listLength; index++)
{
CABLESenderInfo_t *info = (CABLESenderInfo_t *) u_arraylist_get(senderInfoList, index);
if (!info || !(info->remoteEndpoint))
if (g_deviceDiscoveredList)
{
oc_mutex_lock(g_deviceDiscoveredListMutex);
- uint32_t arrayLength = u_arraylist_length(g_deviceDiscoveredList);
- for (int i = 0; i < arrayLength; i++)
+ size_t arrayLength = u_arraylist_length(g_deviceDiscoveredList);
+ for (size_t i = 0; i < arrayLength; i++)
{
char *deviceAddr = u_arraylist_get(g_deviceDiscoveredList, i);
if (0 == strcasecmp(deviceAddr, address))
if (g_multicastDataList)
{
oc_mutex_lock(g_multicastDataListMutex);
- uint32_t arrayLength = u_arraylist_length(g_multicastDataList);
- for (int i = 0; i < arrayLength; i++)
+ size_t arrayLength = u_arraylist_length(g_multicastDataList);
+ for (size_t i = 0; i < arrayLength; i++)
{
CALEData_t *multicastData = u_arraylist_get(g_multicastDataList, i);
if (NULL == multicastData)
static CAErrorHandleCallback g_errorCallback = NULL;
static void CANFCPacketReceivedCB(const CASecureEndpoint_t *endpoint, const void *data,
- uint32_t dataLength);
+ size_t dataLength);
#ifndef SINGLE_THREAD
static CAResult_t CANFCInitializeQueueHandles();
(void)status;
}
-void CANFCPacketReceivedCB(const CASecureEndpoint_t *sep, const void *data, uint32_t dataLength)
+void CANFCPacketReceivedCB(const CASecureEndpoint_t *sep, const void *data, size_t dataLength)
{
OIC_LOG(DEBUG, TAG, "IN");
OIC_LOG(DEBUG, TAG, "OUT");
}
-void CANFCErrorHandler(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
+void CANFCErrorHandler(const CAEndpoint_t *endpoint, const void *data, size_t dataLength,
CAResult_t result)
{
OIC_LOG(DEBUG, TAG, "IN");
(void)size;
}
-CAResult_t CAGetNFCInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
+CAResult_t CAGetNFCInterfaceInformation(CAEndpoint_t **info, size_t *size)
{
OIC_LOG(DEBUG, TAG, "CAGetNFCInterfaceInformation not supported");
if (!info || !size)
return dataLength;
}
-CAResult_t CAGetRAInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
+CAResult_t CAGetRAInterfaceInformation(CAEndpoint_t **info, size_t *size)
{
VERIFY_NON_NULL(info, RA_ADAPTER_TAG, "info is NULL");
VERIFY_NON_NULL(size, RA_ADAPTER_TAG, "size is NULL");
if target_os not in ['msys_nt', 'windows']:
catest_env.AppendUnique(LIBS = ['m'])
+else:
+ catest_env.AppendUnique(CCFLAGS=['/W3', '/WX'])
catest_env.AppendUnique(LIBS = ['timer'])
*
******************************************************************/
+// Warning disabled globally but VS2013 ignores the /wd4200 option in C++ files.
+#if defined(_MSC_VER) && _MSC_VER < 1900
+#pragma warning(disable : 4200)
+#endif
+
#include "gtest/gtest.h"
#include "cainterface.h"
#include "cautilinterface.h"
#include "cacommon.h"
-#include "caprotocolmessage.h"
#include "cablockwisetransfer.h"
#define LARGE_PAYLOAD_LENGTH 1024
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+// Warning disabled globally but VS2013 ignores the /wd4200 option in C++ files.
+#if defined(_MSC_VER) && _MSC_VER < 1900
+#pragma warning(disable : 4200)
+#endif
+
#include <stdio.h>
#include "gtest/gtest.h"
coap_transport_t transport = COAP_UDP;
CAInfo_t inData;
+ size_t tokenLength = 0;
memset(&inData, 0, sizeof(CAInfo_t));
inData.token = (CAToken_t)"token";
- inData.tokenLength = strlen(inData.token);
+ tokenLength = strlen(inData.token);
+ ASSERT_LE(tokenLength, UINT8_MAX);
+ inData.tokenLength = (uint8_t)tokenLength;
inData.type = CA_MSG_NONCONFIRM;
pdu = CAGeneratePDU(CA_GET, &inData, &tempRep, &options, &transport);
CAInfo_t inData;
memset(&inData, 0, sizeof(CAInfo_t));
inData.token = (CAToken_t)"token";
- inData.tokenLength = strlen(inData.token);
+ inData.tokenLength = (uint8_t)strlen(inData.token);
inData.type = CA_MSG_NONCONFIRM;
inData.payload = (CAPayload_t) "requestPayload";
inData.payloadSize = sizeof(inData.payload);;
uint64_t beg = getAbsTime();
OCWaitResult_t ret = oc_cond_wait_for(sharedCond, sharedMutex,
- TARGET_WAIT * USECS_PER_SEC);
+ (uint64_t)(TARGET_WAIT * USECS_PER_SEC));
EXPECT_EQ(OC_WAIT_TIMEDOUT,ret);
uint64_t end = getAbsTime();
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+// Warning disabled globally but VS2013 ignores the /wd4200 option in C++ files.
+#if defined(_MSC_VER) && _MSC_VER < 1900
+#pragma warning(disable : 4200)
+#endif
+
#include <cinttypes>
#include "iotivity_config.h"
#include "gtest/gtest.h"
#endif
#if defined(_WIN32)
-#include "../../../../c_common/windows/include/pthread_create.h"
+#include "pthread_create.h"
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
TEST_F(UArrayListF, Length)
{
- ASSERT_EQ(static_cast<uint32_t>(0), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(0), u_arraylist_length(list));
int dummy = 0;
bool rc = u_arraylist_add(list, &dummy);
ASSERT_TRUE(rc);
- ASSERT_EQ(static_cast<uint32_t>(1), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(1), u_arraylist_length(list));
// Add a few times without checking, just in case checking has side-effects
rc = u_arraylist_add(list, &dummy);
rc = u_arraylist_add(list, &dummy);
ASSERT_TRUE(rc);
- ASSERT_EQ(static_cast<uint32_t>(4), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(4), u_arraylist_length(list));
}
TEST_F(UArrayListF, LengthMulti)
{
- ASSERT_EQ(static_cast<uint32_t>(0), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(0), u_arraylist_length(list));
int dummy = 0;
for (int i = 0; i < 1000; ++i)
ASSERT_TRUE(rc);
}
- ASSERT_EQ(static_cast<uint32_t>(1000), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(1000), u_arraylist_length(list));
}
TEST_F(UArrayListF, NoReserve)
TEST_F(UArrayListF, Reserve)
{
- static const int PAD_SIZE = 10000;
+ static const size_t PAD_SIZE = 10000;
int dummy = 0;
u_arraylist_reserve(list, PAD_SIZE);
- for (int i = 0; i < PAD_SIZE; ++i)
+ for (size_t i = 0; i < PAD_SIZE; ++i)
{
bool rc = u_arraylist_add(list, &dummy);
ASSERT_TRUE(rc);
TEST_F(UArrayListF, ShrinkToFit)
{
- static const int PAD_SIZE = 100;
+ static const size_t PAD_SIZE = 100;
int dummy = 0;
u_arraylist_reserve(list, PAD_SIZE);
- for (int i = 0; i < PAD_SIZE; ++i)
+ for (size_t i = 0; i < PAD_SIZE; ++i)
{
bool rc = u_arraylist_add(list, &dummy);
ASSERT_TRUE(rc);
}
- for (int i = PAD_SIZE; i > 0; --i)
+ for (size_t i = PAD_SIZE; i > 0; --i)
{
u_arraylist_remove(list, i);
}
TEST_F(UArrayListF, Get)
{
- ASSERT_EQ(static_cast<uint32_t>(0), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(0), u_arraylist_length(list));
int dummy[1000] = {0};
size_t cap = sizeof(dummy) / sizeof(dummy[0]);
bool rc = u_arraylist_add(list, &dummy[i]);
ASSERT_TRUE(rc);
}
- ASSERT_EQ(static_cast<uint32_t>(1000), u_arraylist_length(list));
+ ASSERT_EQ(cap, u_arraylist_length(list));
for (size_t i = 0; i < cap; ++i)
{
TEST_F(UArrayListF, Remove)
{
- ASSERT_EQ(static_cast<uint32_t>(0), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(0), u_arraylist_length(list));
int dummy[1000] = {0};
size_t cap = sizeof(dummy) / sizeof(dummy[0]);
bool rc = u_arraylist_add(list, &dummy[i]);
ASSERT_TRUE(rc);
}
- ASSERT_EQ(static_cast<uint32_t>(1000), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(1000), u_arraylist_length(list));
// Remove walking forward so as to have a non-trivial case.
- for (uint32_t idx = 0, old = 0;
+ for (size_t idx = 0, old = 0;
idx < u_arraylist_length(list);
++idx, old += 2)
{
ASSERT_TRUE(value != NULL);
ASSERT_EQ(value, &dummy[old]);
}
- ASSERT_EQ(static_cast<uint32_t>(500), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(500), u_arraylist_length(list));
}
TEST_F(UArrayListF, Contains)
{
- ASSERT_EQ(static_cast<uint32_t>(0), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(0), u_arraylist_length(list));
int dummy[1000] = {0};
size_t cap = sizeof(dummy) / sizeof(dummy[0]);
bool rc = u_arraylist_add(list, &dummy[i]);
ASSERT_TRUE(rc);
}
- ASSERT_EQ(static_cast<uint32_t>(1000), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(1000), u_arraylist_length(list));
// Remove walking forward so as to have a non-trivial case.
- for (uint32_t idx = 0, old = 0;
+ for (size_t idx = 0, old = 0;
idx < u_arraylist_length(list);
++idx, old += 2)
{
ASSERT_TRUE(value != NULL);
ASSERT_EQ(value, &dummy[old]);
}
- ASSERT_EQ(static_cast<uint32_t>(500), u_arraylist_length(list));
+ ASSERT_EQ(static_cast<size_t>(500), u_arraylist_length(list));
// Finally, check that the ones we expect are present, and others are not.
for (size_t i = 0; i < cap; ++i)
// a poor implmentation will thrash memory.
TEST_F(UArrayListF, Thrash)
{
- static const int PAD_SIZE = 1000;
- static const int THRASH_COUNT = 1500;
- ASSERT_EQ(static_cast<uint32_t>(0), u_arraylist_length(list));
+ static const size_t PAD_SIZE = 1000;
+ static const size_t THRASH_COUNT = 1500;
+ ASSERT_EQ(static_cast<size_t>(0), u_arraylist_length(list));
int dummy2 = 0;
int dummy[PAD_SIZE] = {0};
bool rc = u_arraylist_add(list, &dummy[i]);
ASSERT_TRUE(rc);
}
- ASSERT_EQ(static_cast<uint32_t>(PAD_SIZE), u_arraylist_length(list));
+ ASSERT_EQ(PAD_SIZE, u_arraylist_length(list));
// Finally add and remove a lot.
- for (int i = 0; i < THRASH_COUNT; ++i)
+ for (size_t i = 0; i < THRASH_COUNT; ++i)
{
bool rc = u_arraylist_add(list, &dummy2);
ASSERT_TRUE(rc);
- ASSERT_EQ(static_cast<uint32_t>(PAD_SIZE + 1),
+ ASSERT_EQ((PAD_SIZE + 1),
u_arraylist_length(list));
ASSERT_EQ(&dummy2,
u_arraylist_remove(list, u_arraylist_length(list) - 1));
- ASSERT_EQ(static_cast<uint32_t>(PAD_SIZE), u_arraylist_length(list));
+ ASSERT_EQ(PAD_SIZE, u_arraylist_length(list));
}
}
{
ASSERT_EQ(static_cast<uint32_t>(0), u_linklist_length(list));
- int dummy[1000] = {0};
+ size_t dummy[1000] = {0};
size_t cap = sizeof(dummy) / sizeof(dummy[0]);
for (size_t i = 0; i < cap; ++i)
EXPECT_EQ(CA_STATUS_OK, u_linklist_add(list, &dummy[i]));
}
- ASSERT_EQ(static_cast<uint32_t>(1000), u_linklist_length(list));
+ ASSERT_EQ(static_cast<uint32_t>(cap), u_linklist_length(list));
}
TEST_F(ULinkListF, Get)
{
ASSERT_EQ(static_cast<uint32_t>(0), u_linklist_length(list));
- int dummy[1000] = {0};
+ size_t dummy[1000] = {0};
size_t cap = sizeof(dummy) / sizeof(dummy[0]);
for (size_t i = 0; i < cap; ++i)
dummy[i] = i;
EXPECT_EQ(CA_STATUS_OK, u_linklist_add(list, &dummy[i]));
}
- ASSERT_EQ(static_cast<uint32_t>(1000), u_linklist_length(list));
+ ASSERT_EQ(static_cast<uint32_t>(cap), u_linklist_length(list));
u_linklist_iterator_t *iterTable = NULL;
u_linklist_init_iterator(list, &iterTable);
{
ASSERT_EQ(static_cast<uint32_t>(0), u_linklist_length(list));
- int dummy[1000] = {0};
+ size_t dummy[1000] = {0};
size_t cap = sizeof(dummy) / sizeof(dummy[0]);
for (size_t i = 0; i < cap; ++i)
dummy[i] = i;
EXPECT_EQ(CA_STATUS_OK, u_linklist_add(list, &dummy[i]));
}
- ASSERT_EQ(static_cast<uint32_t>(1000), u_linklist_length(list));
+ ASSERT_EQ(static_cast<uint32_t>(cap), u_linklist_length(list));
u_linklist_iterator_t *iterTable = NULL;
u_linklist_init_iterator(list, &iterTable);
#include <stdlib.h>
#include <string.h>
-#include "cathreadpool.h"
-#include "octhread.h"
-#include "uarraylist.h"
-#include "cacommon.h"
+#include "oic_string.h"
#include "logger.h"
#include "caconnectionmanager.h"
-#include "capolicymanager.h"
#define TAG "OIC_CM_POLICY"
*
******************************************************************/
+#include "caadapterutils.h"
#include "camanagerleinterface.h"
#include "cabtpairinginterface.h"
#include "cautilinterface.h"