static void CARegisterCallback(CAConnectivityHandler_t handler, CATransportAdapter_t cType)
{
- OIC_LOG(DEBUG, TAG, "IN");
-
if(handler.startAdapter == NULL ||
handler.startListenServer == NULL ||
handler.stopListenServer == NULL ||
}
int index = CAGetAdapterIndex(cType);
-
- if (index == -1)
+ if (0 > index)
{
OIC_LOG(ERROR, TAG, "unknown connectivity type!");
return;
g_adapterHandler[index] = handler;
OIC_LOG_V(DEBUG, TAG, "%d type adapter, register complete!", cType);
- OIC_LOG(DEBUG, TAG, "OUT");
}
#ifdef RA_ADAPTER
void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback)
{
- OIC_LOG(DEBUG, TAG, "IN");
-
+ OIC_LOG(DEBUG, TAG, "Set Receiver handle callback");
g_networkPacketReceivedCallback = callback;
-
- OIC_LOG(DEBUG, TAG, "OUT");
}
void CASetNetworkChangeCallback(CANetworkChangeCallback callback)
{
- OIC_LOG(DEBUG, TAG, "IN");
-
+ OIC_LOG(DEBUG, TAG, "Set network handle callback");
g_networkChangeCallback = callback;
-
- OIC_LOG(DEBUG, TAG, "OUT");
}
void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback)
OIC_LOG_V(DEBUG, TAG, "Start the adapter of CAConnectivityType[%d]", transportType);
int index = CAGetAdapterIndex(transportType);
-
- if (index == -1)
+ if (0 > index)
{
OIC_LOG(ERROR, TAG, "unknown connectivity type!");
return CA_STATUS_FAILED;
}
+ CAResult_t res = CA_STATUS_FAILED;
if (g_adapterHandler[index].startAdapter != NULL)
{
- g_adapterHandler[index].startAdapter();
+ res = g_adapterHandler[index].startAdapter();
}
- return CA_STATUS_OK;
+ return res;
}
void CAStopAdapter(CATransportAdapter_t transportType)
OIC_LOG_V(DEBUG, TAG, "Stop the adapter of CATransportType[%d]", transportType);
int index = CAGetAdapterIndex(transportType);
-
- if (index == -1)
+ if (0 > index)
{
OIC_LOG(ERROR, TAG, "unknown transport type!");
return;
}
CAEndpoint_t *tempInfo[CA_TRANSPORT_TYPE_NUM] = { 0 };
- uint32_t tempSize[CA_TRANSPORT_TYPE_NUM] = { 0 };
+ size_t tempSize[CA_TRANSPORT_TYPE_NUM] = { 0 };
CAResult_t res = CA_STATUS_FAILED;
- uint32_t resSize = 0;
- for (int index = 0; index < CA_TRANSPORT_TYPE_NUM; index++)
+ size_t resSize = 0;
+ for (size_t index = 0; index < CA_TRANSPORT_TYPE_NUM; index++)
{
if (g_adapterHandler[index].GetnetInfo != NULL)
{
*info = resInfo;
*size = resSize;
- for (int index = 0; index < CA_TRANSPORT_TYPE_NUM; index++)
+ for (size_t index = 0; index < CA_TRANSPORT_TYPE_NUM; index++)
{
// check information
if (tempSize[index] == 0)
// memory error label.
memory_error_exit:
- for (int index = 0; index < CA_TRANSPORT_TYPE_NUM; index++)
+ for (size_t index = 0; index < CA_TRANSPORT_TYPE_NUM; index++)
{
-
OICFree(tempInfo[index]);
tempInfo[index] = NULL;
}
CATransportAdapter_t type = endpoint->adapter;
int index = CAGetAdapterIndex(type);
-
- if (index == -1)
+ if (0 > index)
{
OIC_LOG(ERROR, TAG, "unknown transport type!");
return CA_STATUS_INVALID_PARAM;
}
CATransportFlags_t requestedAdapter = endpoint->adapter ? endpoint->adapter : CA_ALL_ADAPTERS;
-
- for (uint32_t i = 0; i < u_arraylist_length(list); i++)
+ size_t selectedLength = u_arraylist_length(list);
+ for (size_t i = 0; i < selectedLength; i++)
{
void* ptrType = u_arraylist_get(list, i);
}
int index = CAGetAdapterIndex(connType);
-
- if (index == -1)
+ if (0 > index)
{
OIC_LOG(DEBUG, TAG, "unknown connectivity type!");
continue;
return result;
}
- for (uint32_t i = 0; i < u_arraylist_length(list); i++)
+ size_t length = u_arraylist_length(list);
+ for (size_t i = 0; i < length; i++)
{
void* ptrType = u_arraylist_get(list, i);
CATransportAdapter_t connType = *(CATransportAdapter_t *)ptrType;
int index = CAGetAdapterIndex(connType);
- if (index == -1)
+ if (0 > index)
{
OIC_LOG(ERROR, TAG, "unknown connectivity type!");
continue;
return CA_STATUS_FAILED;
}
- for (uint32_t i = 0; i < u_arraylist_length(list); i++)
+ size_t length = u_arraylist_length(list);
+ for (size_t i = 0; i < length; i++)
{
void* ptrType = u_arraylist_get(list, i);
if(ptrType == NULL)
CATransportAdapter_t connType = *(CATransportAdapter_t *)ptrType;
int index = CAGetAdapterIndex(connType);
- if (index == -1)
+ if (0 > index)
{
OIC_LOG(ERROR, TAG, "unknown connectivity type!");
continue;
return result;
}
- for (uint32_t i = 0; i < u_arraylist_length(list); i++)
+ size_t length = u_arraylist_length(list);
+ for (size_t i = 0; i < length; i++)
{
void* ptrType = u_arraylist_get(list, i);
CATransportAdapter_t connType = *(CATransportAdapter_t *)ptrType;
int index = CAGetAdapterIndex(connType);
-
- if (index == -1)
+ if (0 > index)
{
OIC_LOG(DEBUG, TAG, "unknown connectivity type!");
continue;
{
OIC_LOG(DEBUG, TAG, "IN");
- uint32_t index;
- for (index = 0; index < CA_TRANSPORT_TYPE_NUM; index++)
+ for (size_t index = 0; index < CA_TRANSPORT_TYPE_NUM; index++)
{
if (g_adapterHandler[index].terminate != NULL)
{
CATransportAdapter_t connType = *(CATransportAdapter_t *) ptrType;
int index = CAGetAdapterIndex(connType);
-
- if (-1 == index)
+ if (0 > index)
{
OIC_LOG(DEBUG, TAG, "unknown connectivity type!");
continue;