std::string deviceId = deviceInfo->deviceId;
std::string deviceName = deviceInfo->deviceName;
std::vector<std::string> deviceUris;
- for (int i = 0; i < deviceInfo->deviceUriCount; i++)
+ for (size_t i = 0; i < deviceInfo->deviceUriCount; i++)
{
deviceUris.push_back(deviceInfo->deviceUris[i]);
}
}
m_resourceList.clear();
- size_t i;
- for (i = 0 ; i < resourceListCount ; i++)
+ for (size_t i = 0 ; i < resourceListCount ; i++)
{
char** resourceTypes;
size_t resourceTypeCount;
resourcePathList[i], &resourceTypes, &resourceTypeCount);
if (IPCA_OK == status)
{
- int j;
- for (j = 0 ; j < resourceTypeCount; j++)
+ for (size_t j = 0 ; j < resourceTypeCount; j++)
{
m_resourceList[resourcePathList[i]].push_back(resourceTypes[j]);
}
OCRepresentation rep;
rep["x.org.iotivity.CurrentFloor"] = GetCurrentFloor();
- rep["x.org.iotivity.Direction"] = GetElevatorDirection();
+ rep["x.org.iotivity.Direction"] = (int)GetElevatorDirection();
rep["x.org.iotivity.TargetFloor"] = GetTargetFloor();
// Prepare the response.
}
std::map<std::string, IPCAValueType> properties;
- for (int i = 0 ; i < count ; i++)
+ for (size_t i = 0 ; i < count ; i++)
{
properties[allKeys[i]] = allValueTypes[i];
}
uint64_t currentTime = OICGetCurrentTime(TIME_IN_MS);
// Do periodic discovery for active IPCADiscoverDevices() requests.
- std::map<uint32_t, std::vector<std::string>> resourceTypesToDiscover;
+ std::map<size_t, std::vector<std::string>> resourceTypesToDiscover;
{
std::lock_guard<std::mutex> lock(app->m_appMutex);
for (auto& entry : app->m_discoveryList)
uint32_t i = 0;
while (i++ < UINT_MAX)
{
- uint32_t newKey = m_nextKey++;
+ size_t newKey = m_nextKey++;
if (m_callbackInfoList.find(newKey) == m_callbackInfoList.end())
{
- OIC_LOG_V(INFO, TAG, "AddCallbackInfo() with key: %d", newKey);
+ OIC_LOG_V(INFO, TAG, "AddCallbackInfo() with key: %" PRIuPTR, newKey);
cbInfo->mapKey = newKey;
m_callbackInfoList[newKey] = cbInfo;
return IPCA_OK;
return;
}
- for (int i = 0; i < count; i++)
+ for (size_t i = 0; i < count; i++)
{
OICFree((void*)(array[i]));
}
// List of resource types to discover periodically.
// Key is cbInfo->mapKey of each IPCADiscoverDevices() request.
- std::map<uint32_t, DiscoveryDetails::Ptr> m_discoveryList;
+ std::map<size_t, DiscoveryDetails::Ptr> m_discoveryList;
// Password callback registration
InputPinCallbackHandle m_passwordInputCallbackHandle;
std::mutex m_discoverDeviceCallbackMutex;
// Table of CallbackInfo. Key is autogenerated.
- std::atomic<uint32_t> m_nextKey; // next key for the m_callbackInfoList map.
- std::map<uint32_t, CallbackInfo::Ptr> m_callbackInfoList; // List of expected callbacks.
+ std::atomic<size_t> m_nextKey; // next key for the m_callbackInfoList map.
+ std::map<size_t, CallbackInfo::Ptr> m_callbackInfoList; // List of expected callbacks.
App* m_app; // Callback object is per app.
volatile bool m_stopCalled; // Set to true when Stop() is called.
#include <condition_variable>
#include <stdbool.h>
-#include <inttypes.h>
#include <assert.h>
#include <stdint.h>
// Callback from OCF for MOT completion
void OnMultipleOwnershipTransferCompleteCallback(PMResultList_t* result,
- bool error,
+ int error,
std::string deviceId,
CallbackInfo::Ptr callbackInfo);
// rollback if any failure.
if (i != ocrepCount)
{
- for (int x = 0; x < i; x++)
+ for (size_t x = 0; x < i; x++)
{
IPCAPropertyBagDestroy(*value[x]);
}
OCDeviceInfo deviceInfo = { deviceName, &types, deviceSoftwareVersion, nullptr };
// Platform Info
- IPCAUuid platformUUID;
char platformManufacturerName[256] = "";
char manufacturerUrl[256] = "";
char modelNumber[] = "";
void OCFFramework::OnMultipleOwnershipTransferCompleteCallback(
PMResultList_t* result,
- bool error,
+ int error,
std::string deviceId,
CallbackInfo::Ptr callbackInfo)
{
size_t resourcePathCount;
EXPECT_EQ(IPCA_OK, IPCAGetResources(m_deviceHandle,
nullptr, nullptr, &resourcePathList, &resourcePathCount));
- EXPECT_LT(0, resourcePathCount); // At least there must be elevator resource.
- int i = 0;
+ EXPECT_LT(0U, resourcePathCount); // At least there must be elevator resource.
bool elevatorResourceFound = false;
- for (i = 0; i < resourcePathCount; i++)
+ for (size_t i = 0; i < resourcePathCount; i++)
{
std::string resourcePath = resourcePathList[i];
if (resourcePath.find(ELEVATOR_KEYWORD) != std::string::npos)
size_t resourceTypeCount;
EXPECT_EQ(IPCA_OK, IPCAGetResourceTypes(m_deviceHandle,
nullptr, &resourceTypes, &resourceTypeCount));
- EXPECT_LT(0, resourceTypeCount); // At least 1 resource type.
- int i = 0;
+ EXPECT_LT(0U, resourceTypeCount); // At least 1 resource type.
bool elevatorResourceTypeFound = false;
- for (i = 0; i < resourceTypeCount; i++)
+ for (size_t i = 0; i < resourceTypeCount; i++)
{
std::string rt = resourceTypes[i];
if (rt.find(ELEVATOR_KEYWORD) != std::string::npos)
// Function list for a given resource.
EXPECT_EQ(IPCA_RESOURCE_NOT_FOUND, IPCAGetResourceTypes(m_deviceHandle,
"oic/fake", &resourceTypes, &resourceTypeCount));
- EXPECT_EQ(0, resourceTypeCount);
+ EXPECT_EQ(0U, resourceTypeCount);
EXPECT_EQ(nullptr, resourceTypes);
EXPECT_EQ(IPCA_OK, IPCAGetResourceTypes(m_deviceHandle,
ELEVATOR_RESOURCE_PATH, &resourceTypes, &resourceTypeCount));
- EXPECT_LT(0, resourceTypeCount); // At least 1 function.
+ EXPECT_LT(0U, resourceTypeCount); // At least 1 function.
elevatorResourceTypeFound = false;
- for (i = 0; i < resourceTypeCount; i++)
+ for (size_t i = 0; i < resourceTypeCount; i++)
{
std::string rt = resourceTypes[i];
if (rt.find(ELEVATOR_KEYWORD) != std::string::npos)
size_t resourceInterfaceCount;
EXPECT_EQ(IPCA_OK, IPCAGetResourceInterfaces(m_deviceHandle,
nullptr, &resourceInterfaces, &resourceInterfaceCount));
- EXPECT_LT(1, resourceInterfaceCount);
+ EXPECT_LT(1U, resourceInterfaceCount);
// Should return only 1 resource with ELEVATOR_CO_PRIVATE_INTERFACE interface.
char** resourcePathList;
nullptr,
&resourcePathList,
&resourcePathCount));
- EXPECT_EQ(0, resourcePathCount);
+ EXPECT_EQ(0U, resourcePathCount);
IPCAFreeStringArray(resourcePathList, resourcePathCount);
// Should be at least 4 resouces with DEFAULT_INTERFACE created in ElevatorServer::Start().
nullptr,
&resourcePathList,
&resourcePathCount));
- EXPECT_LT(3, resourcePathCount);
+ EXPECT_LT(3U, resourcePathCount);
IPCAFreeStringArray(resourcePathList, resourcePathCount);
return IPCA_OK;
if (g_elevator1Name.compare(discoveredDeviceInfo->deviceName) == 0)
{
m_discoveredElevator1DeviceUris.clear();
- for (int i = 0; i < discoveredDeviceInfo->deviceUriCount; i++)
+ for (size_t i = 0; i < discoveredDeviceInfo->deviceUriCount; i++)
{
m_discoveredElevator1DeviceUris.push_back(discoveredDeviceInfo->deviceUris[i]);
}
std::lock_guard<std::recursive_mutex> lock(g_globalMutex);\r
for (auto request : g_requestList)\r
{\r
- PendingRequest::Ptr pendingRequest = request.second;\r
- if (pendingRequest->method & (OC_REST_OBSERVE | OC_REST_OBSERVE_ALL))\r
+ PendingRequest::Ptr localPendingRequest = request.second;\r
+ if (localPendingRequest->method & (OC_REST_OBSERVE | OC_REST_OBSERVE_ALL))\r
{\r
- if (pendingRequest->mockOCResource->m_uri.compare(uri) == 0)\r
+ if (localPendingRequest->mockOCResource->m_uri.compare(uri) == 0)\r
{\r
- observationIdToCancel = pendingRequest->observationId;\r
- g_requestList.erase(pendingRequest->requestNumber);\r
+ observationIdToCancel = localPendingRequest->observationId;\r
+ g_requestList.erase(localPendingRequest->requestNumber);\r
break;\r
}\r
}\r
return;
}
- for (int count = 0; count < *numOptions; count++)
+ for (uint8_t count = 0; count < *numOptions; count++)
{
if (options[count].protocolID == OC_COAP_ID &&
- options[count].optionID == COAP_OPTION_PROXY_URI)
+ options[count].optionID == COAP_OPTION_PROXY_URI)
{
OIC_LOG(DEBUG, TAG, "Proxy URI is present");
// Extract proxy-uri and delete it from headeroptions.
OICStrcpy(uri, uriLength, (char *)options[count].optionData);
- for (int fwd = count; fwd < *numOptions-1; fwd++)
+ for (uint8_t fwd = count; fwd < *numOptions - 1; fwd++)
{
- options[count] = options[count+1];
+ options[count] = options[count + 1];
}
*numOptions -= 1;
return;
return OC_STACK_ERROR;
}
- uint8_t vendorOptions = requestInfo->numRcvdVendorSpecificHeaderOptions;
- if (vendorOptions)
+ uint8_t vendorOptionsCount = requestInfo->numRcvdVendorSpecificHeaderOptions;
+ if (vendorOptionsCount)
{
httpRequest.headerOptions = u_arraylist_create();
- for (int option = 0; option < vendorOptions; option++)
+ for (uint8_t option = 0; option < vendorOptionsCount; option++)
{
HttpHeaderOption_t *httpOption = NULL;
result = CHPGetHttpOption(requestInfo->rcvdVendorSpecificHeaderOptions + option,
TEST_F(CoApHttpTest, CHPGetOCOption)
{
- int numOptions = 0;
OCHeaderOption *ret = NULL;
const HttpResponse_t *httpResponse = NULL;
HttpHeaderOption_t *httpOption = NULL;
OCResourceHandle rHandle;
OCObservationId obArray[255] = { 0, };
- int obCount = 0, i;
+ size_t obCount = 0;
if (NSPutMessageResource(msg, &rHandle) != NS_OK)
{
it = it->next;
}
- for (i = 0; i < obCount; ++i)
+ for (size_t i = 0; i < obCount; ++i)
{
NS_LOG(DEBUG, "-------------------------------------------------------message\n");
- NS_LOG_V(DEBUG, "SubScription WhiteList[%d] = %d", i, obArray[i]);
+ NS_LOG_V(DEBUG, "SubScription WhiteList[%" PRIuPTR "] = %d", i, obArray[i]);
NS_LOG(DEBUG, "-------------------------------------------------------message\n");
}
NS_LOG(DEBUG, "NSSendSync - IN");
OCObservationId obArray[255] = { 0, };
- int obCount = 0;
- int i;
+ size_t obCount = 0;
OCResourceHandle rHandle;
if (NSPutSyncResource(sync, &rHandle) != NS_OK)
}
#endif
- for (i = 0; i < obCount; ++i)
+ for (size_t i = 0; i < obCount; ++i)
{
NS_LOG(DEBUG, "-------------------------------------------------------message\n");
- NS_LOG_V(DEBUG, "Sync WhiteList[%d] = %d", i, obArray[i]);
+ NS_LOG_V(DEBUG, "Sync WhiteList[%" PRIuPTR "] = %d", i, obArray[i]);
NS_LOG(DEBUG, "-------------------------------------------------------message\n");
}
OCObservationId obArray[255] =
{ 0, };
- int obCount = 0;
+ size_t obCount = 0;
NSCacheElement * it = consumerSubList->head;