{
int ret = pthread_mutex_lock(&mutexInfo->mutex);
assert(0 == ret);
- (void)ret;
+ if(ret != 0)
+ {
+ OIC_LOG_V(ERROR, TAG, "Pthread Mutex lock failed: %d", ret);
+ exit(ret);
+ }
}
else
{
if (mutexInfo)
{
int ret = pthread_mutex_unlock(&mutexInfo->mutex);
+
assert ( 0 == ret);
+ if(ret != 0)
+ {
+ OIC_LOG_V(ERROR, TAG, "Pthread Mutex unlock failed: %d", ret);
+ exit(ret);
+ }
(void)ret;
}
else
{
OIC_LOG_V(ERROR, TAG, "%s: Failed to initialize condition variable attribute %d!",
__func__, ret);
+ OICFree(eventInfo);
return retVal;
}
{
OIC_LOG_V(ERROR, TAG, "%s: Failed to set condition variable clock %d!",
__func__, ret);
+ pthread_condattr_destroy(&(eventInfo->condattr));
+ OICFree(eventInfo);
return retVal;
}
#endif
else
{
OIC_LOG_V(ERROR, TAG, "%s: Failed to initialize condition variable %d!", __func__, ret);
+ pthread_condattr_destroy(&(eventInfo->condattr));
OICFree(eventInfo);
}
}
if(!thread_pool)
{
OIC_LOG(ERROR, TAG, "Invalid parameter thread_pool was NULL");
+ return;
}
ca_mutex_lock(thread_pool->details->list_lock);
return CA_STATUS_FAILED;
}
- strncpy((*info)->addressInfo.BT.btMacAddress, local_address, strlen(local_address));
+ size_t local_address_len = strlen(local_address);
+
+ if(local_address_len >= sizeof(g_localBLEAddress) ||
+ local_address_len >= sizeof((*info)->addressInfo.BT.btMacAddress))
+ {
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "local_address is too long");
+ OICFree(*info);
+ OICFree(local_address);
+ return CA_STATUS_FAILED;
+ }
+
+ strncpy((*info)->addressInfo.BT.btMacAddress, local_address,
+ sizeof((*info)->addressInfo.BT.btMacAddress) - 1);
+ (*info)->addressInfo.BT.btMacAddress[sizeof((*info)->addressInfo.BT.btMacAddress)-1] = '\0';
ca_mutex_lock(g_bleLocalAddressMutex);
- strncpy(g_localBLEAddress, local_address, sizeof(g_localBLEAddress));
+ strncpy(g_localBLEAddress, local_address, sizeof(g_localBLEAddress) - 1);
+ g_localBLEAddress[sizeof(g_localBLEAddress)-1] = '\0';
ca_mutex_unlock(g_bleLocalAddressMutex);
(*info)->type = CA_LE;
if (NULL == cadata)
{
OIC_LOG(ERROR, TAG, "CAReceivedPacketCallback, Memory allocation failed !");
- if (NULL != endpoint && NULL != endpoint->resourceUri)
- {
- OICFree(endpoint->resourceUri);
- }
-
OICFree(ReqInfo);
coap_delete_pdu(pdu);
CAAdapterFreeRemoteEndpoint(endpoint);
if (NULL == cadata)
{
OIC_LOG(ERROR, TAG, "CAReceivedPacketCallback, Memory allocation failed !");
- if (NULL != endpoint && NULL != endpoint->resourceUri)
- {
- OICFree(endpoint->resourceUri);
- }
OICFree(ResInfo);
coap_delete_pdu(pdu);
CAAdapterFreeRemoteEndpoint(endpoint);
#define CA_BUFSIZE (128)
#define CA_PDU_MIN_SIZE (4)
-#define CA_PORT_BUFFER_SIZE (2)
+#define CA_PORT_BUFFER_SIZE (4)
static const char COAP_URI_HEADER[] = "coap://[::]/";
// Make sure there is enough room in the optionResult buffer
if ((optionLength + bufLength) < sizeof(optionResult))
{
- memcpy(optionResult + optionLength, buf, bufLength);
+ memcpy(&optionResult[optionLength], buf, bufLength);
optionLength += bufLength;
}
else
// Make sure there is enough room in the optionResult buffer
if ((optionLength + bufLength) < sizeof(optionResult))
{
- memcpy(optionResult + optionLength, buf, bufLength);
+ memcpy(&optionResult[optionLength], buf, bufLength);
optionLength += bufLength;
}
else
if (isIp)
{
- strncpy(outAddress->IP.ipAddress, pAddress, ipLen == 0 ? len : ipLen);
+ if(ipLen && ipLen < sizeof(outAddress->IP.ipAddress))
+ {
+ strncpy(outAddress->IP.ipAddress, pAddress, ipLen);
+ outAddress->IP.ipAddress[ipLen] = '\0';
+ }
+ else if (!ipLen && len < sizeof(outAddress->IP.ipAddress))
+ {
+ strncpy(outAddress->IP.ipAddress, pAddress, len);
+ outAddress->IP.ipAddress[len] = '\0';
+ }
+ else
+ {
+ OIC_LOG_V(ERROR, TAG, "IP Address too long: %d", ipLen==0 ? len : ipLen);
+ return -1;
+ }
+
if (ipLen > 0)
{
}
memcpy(cloneUri, &uri[startIndex], sizeof(char) * len);
+ cloneUri[len] = '\0';
// #3. parse address
// #4. parse resource uri
}
if (netMask)
{
- strncpy(info->subNetMask, netMask, strlen(netMask));
+ strncpy(info->subNetMask, netMask, sizeof(info->subNetMask) - 1);
+ info->subNetMask[sizeof(info->subNetMask)-1] = '\0';
OICFree(netMask);
}
- strncpy(info->ipAddress, localAddress, strlen(localAddress));
+ strncpy(info->ipAddress, localAddress, sizeof(info->ipAddress) - 1);
+ info->ipAddress[sizeof(info->ipAddress) - 1] = '\0';
info->port = *port;
info->socketFd = unicastServerFd;
info->isSecured = isSecured;
info->isServerStarted = true;
info->isMulticastServer = false;
- strncpy(info->ifAddr, localAddress, strlen(localAddress));
+ strncpy(info->ifAddr, localAddress, sizeof(info->ifAddr) - 1);
+ info->ifAddr[sizeof(info->ifAddr) - 1] = '\0';
CAResult_t res = CAAddServerInfo(g_serverInfoList, info);
if (CA_STATUS_OK != res)
}
if (netMask)
{
- strncpy(info->subNetMask, netMask, strlen(netMask));
+ strncpy(info->subNetMask, netMask, sizeof(info->subNetMask) - 1);
+ info->subNetMask[sizeof(info->subNetMask) -1] = '\0';
OICFree(netMask);
}
- strncpy(info->ipAddress, multicastAddress, strlen(multicastAddress));
+ strncpy(info->ipAddress, multicastAddress, sizeof(info->ipAddress) - 1);
+ info->ipAddress[sizeof(info->ipAddress) -1] = '\0';
info->port = multicastPort;
info->socketFd = mulicastServerFd;
info->isSecured = false;
info->isServerStarted = true;
info->isMulticastServer = true;
- strncpy(info->ifAddr, localAddress, strlen(localAddress));
+ strncpy(info->ifAddr, localAddress, sizeof(info->ifAddr)-1);
+ info->ifAddr[sizeof(info->ifAddr) -1] = '\0';
ret = CAAddServerInfo(g_serverInfoList, info);
return;
}
// set interface name
- strncpy(netInfo->interfaceName, ifa->ifa_name, strlen(ifa->ifa_name));
+ strncpy(netInfo->interfaceName, ifa->ifa_name, sizeof(netInfo->interfaceName) - 1);
+ netInfo->interfaceName[sizeof(netInfo->interfaceName)-1] = '\0';
// set local ip address
strncpy(netInfo->ipAddress, interfaceAddress, strlen(interfaceAddress));
int length = strlen(NORMAL_INFO_DATA) + strlen("a/light");
requestData.payload = (CAPayload_t) calloc(length, sizeof(char));
+
+ if(!requestData.payload)
+ {
+ CADestroyToken(tempToken);
+ FAIL() << "requestData.payload allocation failed";
+ }
+
snprintf(requestData.payload, length, NORMAL_INFO_DATA, "a/light");
requestData.type = CA_MSG_NONCONFIRM;
int length = strlen(NORMAL_INFO_DATA) + strlen("a/light");
requestData.payload = (CAPayload_t) calloc(length, sizeof(char));
+
+ if(!requestData.payload)
+ {
+ CADestroyToken(tempToken);
+ FAIL() << "requestData.payload allocation failed";
+ }
+
snprintf(requestData.payload, length, NORMAL_INFO_DATA, "a/light");
requestData.type = CA_MSG_NONCONFIRM;
CAHeaderOption_t* headerOpt;
headerOpt = (CAHeaderOption_t *) calloc(1, optionNum * sizeof(CAHeaderOption_t));
+ if(!headerOpt)
+ {
+ FAIL() <<"Allocation for headerOpt failed";
+ }
+
char* tmpOptionData1 = (char *) "Hello";
size_t tmpOptionDataLen = (strlen(tmpOptionData1) < CA_MAX_HEADER_OPTION_DATA_LENGTH) ?
strlen(tmpOptionData1) : CA_MAX_HEADER_OPTION_DATA_LENGTH - 1;
CAHeaderOption_t* headerOpt;
headerOpt = (CAHeaderOption_t *) calloc(1, optionNum * sizeof(CAHeaderOption_t));
+ if(!headerOpt)
+ {
+ FAIL() << "Allocation for headerOpt failed";
+ }
+
char* tmpOptionData1 = (char *) "Hello";
size_t tmpOptionDataLen = (strlen(tmpOptionData1) < CA_MAX_HEADER_OPTION_DATA_LENGTH) ?
strlen(tmpOptionData1) : CA_MAX_HEADER_OPTION_DATA_LENGTH - 1;
CACreateRemoteEndpoint(uri, CA_IPV4, &tempRep);
CAGroupEndpoint_t *group = NULL;
group = (CAGroupEndpoint_t *) malloc(sizeof(CAGroupEndpoint_t));
+ if(!group)
+ {
+ FAIL() << "Allocation for group failed";
+ }
+
group->transportType = tempRep->transportType;
group->resourceUri = tempRep->resourceUri;
CAResult_t res = CAGetNetworkInformation(&tempInfo, &tempSize);
+ free(tempInfo);
+
if (CA_STATUS_OK == res || CA_ADAPTER_NOT_ENABLED == res ||
CA_NOT_SUPPORTED == res)
{
#ifndef OC_CLIENT_CB
#define OC_CLIENT_CB
-#include <ocstack.h>
+#include "ocstack.h"
-#include <ocresource.h>
+#include "ocresource.h"
#include "cacommon.h"
typedef struct OCPresence
struct OCMulticastNode * next;
} OCMulticastNode;
+typedef struct resourcetype_t OCResourceType;
+
typedef struct ClientCB {
// callback method defined in application address space
OCClientResponseHandler callBack;
#ifndef OCRESOURCE_H_
#define OCRESOURCE_H_
+#include "ocstackconfig.h"
+#include "occlientcb.h"
+
#define OC_OBSERVER_NOT_INTERESTED (0)
#define OC_OBSERVER_STILL_INTERESTED (1)
#define OC_OBSERVER_FAILED_COMM (2)
else
{
strncpy(szQueryUri, MULTICAST_DEVICE_DISCOVERY_QUERY,
- (strlen(MULTICAST_DEVICE_DISCOVERY_QUERY) + 1));
+ sizeof(szQueryUri) -1 );
+ szQueryUri[sizeof(szQueryUri) -1] = '\0';
}
if(UNICAST_DISCOVERY)
!= OC_STACK_OK)
{
OC_LOG(ERROR, TAG, "Error while parsing JSON payload in OCClientResponse");
+ OCFree(sid);
+ OCFree(uri);
+ return;
}
int i;
}
}
+ OCFree(sid);
OCFree(uri);
}
if(OC_REST_PUT == ehRequest->method)
{
// Get cJSON pointer to query
- cJSON *putJson = cJSON_Parse((char *)ehRequest->reqJSONPayload);
+ cJSON *putJson = cJSON_Parse(ehRequest->reqJSONPayload);
+
+ if(!putJson)
+ {
+ OC_LOG_V(ERROR, TAG, "Failed to parse JSON: %s", ehRequest->reqJSONPayload);
+ return NULL;
+ }
// Get root of JSON payload, then the 1st resource.
cJSON* carrier = cJSON_GetObjectItem(putJson, "oc");
char *payload, uint16_t maxPayloadSize)
{
OCEntityHandlerResult ehResult;
-
bool queryPassed = checkIfQueryForPowerPassed(ehRequest->query);
// Empty payload if the query has no match.
if (queryPassed)
{
char *getResp = constructJsonResponse(ehRequest);
+ if(!getResp)
+ {
+ OC_LOG(ERROR, TAG, "constructJsonResponse failed");
+ return OC_EH_ERROR;
+ }
- if (maxPayloadSize > strlen ((char *)getResp))
+ if (maxPayloadSize > strlen (getResp))
{
- strncpy(payload, getResp, strlen((char *)getResp));
+ strncpy(payload, getResp, strlen(getResp));
ehResult = OC_EH_OK;
}
else
OCEntityHandlerResult ehResult;
char *putResp = constructJsonResponse(ehRequest);
+ if(!putResp)
+ {
+ OC_LOG(ERROR, TAG, "Failed to construct Json response");
+ return OC_EH_ERROR;
+ }
+
if (maxPayloadSize > strlen ((char *)putResp))
{
strncpy(payload, putResp, strlen((char *)putResp));
{
OC_LOG(INFO, TAG, "Entering ProcessGetRequest");
char *getResp = constructJsonResponse(ehRequest);
+
+ if(!getResp)
+ {
+ OC_LOG(ERROR, TAG, "Failed to constructJsonResponse");
+ return;
+ }
OC_LOG(INFO, TAG, "After constructJsonResponse");
OCEntityHandlerResponse response;
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include "common.h"
-#include <ocstack.h>
-#include <ocsecurity.h>
-#include <logger.h>
+#include "ocsecurity.h"
+#include "logger.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#ifndef OCSAMPLE_COMMON_H_
#define OCSAMPLE_COMMON_H_
+#include "ocstack.h"
+
/* Get the result in string format. */
const char *getResult(OCStackResult result);
if(OC_REST_PUT == ehRequest->method)
{
- cJSON *putJson = cJSON_Parse((char *)ehRequest->reqJSONPayload);
+ cJSON *putJson = cJSON_Parse(ehRequest->reqJSONPayload);
+ if(!putJson)
+ {
+ OC_LOG_V(ERROR, TAG, "Failed to parse JSON: %s", ehRequest->reqJSONPayload);
+ return NULL;
+ }
+
currLEDResource->state = ( !strcmp(cJSON_GetObjectItem(putJson,"state")->valuestring ,
"on") ? true:false);
currLEDResource->power = cJSON_GetObjectItem(putJson,"power")->valuedouble;
// For POSIX.1-2001 base specification,
// Refer http://pubs.opengroup.org/onlinepubs/009695399/
#define _POSIX_C_SOURCE 200112L
+#include "occollection.h"
#include <string.h>
#include "ocstack.h"
#include "ocstackinternal.h"
{
cJSON_AddItemToObject (resObj, OC_RSRVD_HREF, cJSON_CreateString(resource->uri));
jsonStr = cJSON_PrintUnformatted (resObj);
+
+ if(!jsonStr)
+ {
+ cJSON_Delete(resObj);
+ return OC_STACK_NO_MEMORY;
+ }
+
jsonLen = strlen(jsonStr);
if (jsonLen < *remaining)
{
{
OCEntityHandlerResponse ehResponse = {};
ehResponse.ehResult = OC_EH_OK;
- ehResponse.payload = (char *) OCMalloc(MAX_RESPONSE_LENGTH);
+ ehResponse.payload = (char *) OCMalloc(MAX_RESPONSE_LENGTH + 1);
if(!ehResponse.payload)
{
FindAndDeleteServerRequest(request);
continue;
}
strncpy(ehResponse.payload, notificationJSONPayload, MAX_RESPONSE_LENGTH-1);
+ ehResponse.payload[MAX_RESPONSE_LENGTH] = '\0';
ehResponse.payloadSize = strlen(ehResponse.payload) + 1;
ehResponse.persistentBufferFlag = 0;
ehResponse.requestHandle = (OCRequestHandle) request;
// For POSIX.1-2001 base specification,
// Refer http://pubs.opengroup.org/onlinepubs/009695399/
#define _POSIX_C_SOURCE 200112L
+#include "ocresource.h"
#include <string.h>
-#include "ocstack.h"
-#include "ocstackconfig.h"
-#include "ocstackinternal.h"
#include "ocresourcehandler.h"
#include "ocobserve.h"
#include "occollection.h"
}
jsonStr = cJSON_PrintUnformatted (resObj);
+ if(!jsonStr)
+ {
+ cJSON_Delete(resObj);
+ return OC_STACK_NO_MEMORY;
+ }
+
jsonLen = strlen(jsonStr);
if (jsonLen < *remaining)
{
return OC_STACK_ERROR;
}
+ if(ehResponse->payloadSize >= (MAX_RESPONSE_LENGTH))// - OC_JSON_PREFIX_LEN - OC_JSON_SUFFIX_LEN))
+ {
+ OC_LOG_V(ERROR, TAG, "Response payload size was too large. Max is %hu, payload size was %hu",
+ (MAX_RESPONSE_LENGTH - OC_JSON_PREFIX_LEN - OC_JSON_SUFFIX_LEN), ehResponse->payloadSize);
+ return OC_STACK_INVALID_PARAM;
+ }
+
OCServerRequest *serverRequest = (OCServerRequest *)ehResponse->requestHandle;
// Copy the address
if(!responseInfo.info.options)
{
OC_LOG(FATAL, TAG, PCF("options is NULL"));
+ OCFree(responseInfo.info.token);
return OC_STACK_NO_MEMORY;
}
responseInfo.info.options = NULL;
}
- char payload[MAX_RESPONSE_LENGTH] = {};
+ char payload[MAX_RESPONSE_LENGTH + OC_JSON_PREFIX_LEN + OC_JSON_SUFFIX_LEN] = {};
// Put the JSON prefix and suffix around the payload
strcpy(payload, (const char *)OC_JSON_PREFIX);
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
requestInfo->info.tokenLength);
+ OCFree(serverRequest.requestToken);
return;
}
serverRequest.numRcvdVendorSpecificHeaderOptions = tempNum;
if(method == OC_REST_PRESENCE)
{
result = getQueryFromUri(requiredUri, &query, &newUri);
+
+ if(result != OC_STACK_OK)
+ {
+ OC_LOG_V(ERROR, TAG, "Invalid Param from getQueryFromUri: %d, URI is %s",
+ result, requiredUri);
+ goto exit;
+ }
+
if(query)
{
result = getResourceType((char *) query, &resourceType);
numOptions, OC_OBSERVE_REGISTER);
if (result != OC_STACK_OK)
{
+ CADestroyToken(token);
goto exit;
}
requestData.numOptions = numOptions + 1;
requestData.payload = (char *)request;
requestInfo.info = requestData;
-
CATransportType_t caConType;
result = OCToCATransportType((OCConnectivityType) conType, &caConType);
if(!grpEnd.resourceUri)
{
result = OC_STACK_NO_MEMORY;
+ CADestroyToken(token);
goto exit;
}
strncpy(grpEnd.resourceUri, requiredUri, (uriLen + 1));
}
CADestroyRemoteEndpoint(endpoint);
OCFree(grpEnd.resourceUri);
+
if (requestData.options && requestData.numOptions > 0)
{
if ((method == OC_REST_OBSERVE) || (method == OC_REST_OBSERVE_ALL))
}
strncpy(*uriWithoutQuery, uri, uriWithoutQueryLen);
}
+ else
+ {
+ return OC_STACK_INVALID_PARAM;
+ }
+
if (queryLen)
{
*query = (char *) OCCalloc(queryLen + 1, 1);
char *jsonResponse;
- ExtractKeyValueFromRequest((char *) ehRequest->reqJSONPayload, &doWhat,
- &details);
+ stackRet = ExtractKeyValueFromRequest((char *) ehRequest->reqJSONPayload,
+ &doWhat, &details);
+
+ if(stackRet != OC_STACK_OK)
+ {
+ OC_LOG_V(ERROR, TAG, "ExtractKeyValueFromRequest failed: %d", stackRet);
+ return stackRet;
+ }
+
+ stackRet = OC_STACK_ERROR;
cJSON *json;
cJSON *format;
{
cJSON_AddStringToObject(format, ACTIONSET, plainText);
}
-
+ OCFree(plainText);
stackRet = OC_STACK_OK;
}
}
try {
throw std::runtime_error("deadman timer expired");
}
- catch (std::exception &e)
+ catch (std::exception&)
{
std::terminate();
}
std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
}
}
- catch(std::exception& e)
+ catch(std::exception&)
{
std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
}
std::mutex blocker;
std::condition_variable cv;
std::unique_lock<std::mutex> lock(blocker);
- while(true)
- {
- cv.wait(lock);
- }
+ cv.wait(lock, []{return false;});
}catch(OCException& e)
{
- //log(e.what());
+ std::cerr << "Failure in main thread: "<<e.reason()<<std::endl;
}
return 0;
DuplicateString(&deviceInfo.platformVersion, platformVersion);
DuplicateString(&deviceInfo.supportUrl, supportUrl);
DuplicateString(&deviceInfo.version, version);
- }catch(std::exception &e)
+ }catch(std::exception &)
{
std::cout<<"String Copy failed!!\n";
return OC_STACK_ERROR;
std::mutex blocker;
std::condition_variable cv;
std::unique_lock<std::mutex> lock(blocker);
- while(true)
- {
- cv.wait(lock);
- }
+ cv.wait(lock, []{return false;});
// No explicit call to stop the platform.
// When OCPlatform::destructor is invoked, internally we do platform cleanup
std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
}
}
- catch(std::exception& e)
+ catch(std::exception&)
{
std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
}
}
catch(std::exception& e)
{
- //log(e.what());
+ std::cerr << "Exception in foundResource: "<< e.what()<<std::endl;
}
}
std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
}
}
- catch(std::exception& e)
+ catch(std::exception&)
{
std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
}
}
catch (std::exception& e)
{
- std::cout << "" << std::endl;
+ std::cerr << "Exception in foundResource: "<< e.what() << std::endl;
}
}
std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
}
}
- catch(exception& e)
+ catch(exception&)
{
std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
}
}
catch (std::exception& e)
{
- std::cout << "" << std::endl;
+ std::cout << "Exception in foundResource:"<< e.what() << std::endl;
}
}
std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
}
}
- catch(exception& e)
+ catch(exception&)
{
std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
}
}
catch(std::exception& e)
{
+ std::cerr << "Exception in foundResource: "<< e.what() << std::endl;
//log(e.what());
}
}
}
}
}
- catch(std::exception& e)
+ catch(std::exception& )
{
std::cout << "Invalid input argument. Using WIFI as connectivity type"
<< std::endl;
}
catch(std::exception& e)
{
+ std::cerr << "Exception in foundResource: "<< e.what() <<std::endl;
//log(e.what());
}
}
std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
}
}
- catch(std::exception& e)
+ catch(std::exception& )
{
std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
}
}
catch(std::exception& e)
{
- //log(e.what());
+ std::cerr << "Exception in foundResource: "<< e.what() << std::endl;
}
}
return -1;
}
}
- catch(std::exception& e)
+ catch(std::exception& )
{
std::cout << "<===Invalid input arguments===>\n\n";
return -1;
}
catch(std::exception& e)
{
- //log(e.what());
+ std::cerr << "Exception in foundResource: "<< e.what() <<std::endl;
}
}
return -1;
}
}
- catch(std::exception& e)
+ catch(std::exception&)
{
std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
}
std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
}
}
- catch(std::exception& e)
+ catch(std::exception& )
{
std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
}
if(isListOfObservers)
{
- std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
+ std::shared_ptr<OCResourceResponse> resourceResponse =
+ {std::make_shared<OCResourceResponse>()};
resourceResponse->setErrorCode(200);
resourceResponse->setResourceRepresentation(lightPtr->get(), DEFAULT_INTERFACE);
if(isListOfObservers)
{
- std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
+ std::shared_ptr<OCResourceResponse> resourceResponse =
+ std::make_shared<OCResourceResponse>();
resourceResponse->setErrorCode(200);
resourceResponse->setResourceRepresentation(lightPtr->get(), DEFAULT_INTERFACE);
std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
}
}
- catch(std::exception& e)
+ catch(std::exception& )
{
std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
}
/**
* @file
*
- * This file contains the declaration of classes and its members related
+ * This file contains the declaration of classes and its members related
* to OCRepresentation.
*/
result = OCProcess();
}
- // ...the value of variable result is simply ignored for now.
if(OC_STACK_ERROR == result)
- ;
+ {
+ oclog() << "OCProcess failed with result " << result <<std::flush;
+ // ...the value of variable result is simply ignored for now.
+ }
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
else
{
+ OCFree(response.payload);
result = OC_STACK_ERROR;
}
//
//*********************************************************************
+#include "OCPlatform_impl.h"
+
#include <random>
#include <utility>
#include <functional>
{
ar(v);
}
- catch(cereal::Exception& e)
+ catch(cereal::Exception&)
{
ar.setNextName(nullptr);
// Loading a key that doesn't exist results in an exception
std::vector<std::string> types = {"intel.rpost"};
std::vector<std::string> ifaces = {DEFAULT_INTERFACE};
- return OCPlatform::constructResourceObject(host, uri,
+ auto ret = OCPlatform::constructResourceObject(host, uri,
connectivityType, false, types, ifaces);
+
+ if(!ret)
+ {
+ ADD_FAILURE() << "ConstructResourceObject result was null";
+ throw std::runtime_error("ConstructResourceObject result was null");
+ }
+
+ return ret;
}
//Get Test
OCRepresentation rep;
EXPECT_ANY_THROW(
resource->put(nullptr, DEFAULT_INTERFACE, rep, QueryParamsMap(), &onGetPut));
- HeaderOptions headerOptions = {};
+ HeaderOptions headerOptions;
onGetPut(headerOptions, rep, OC_STACK_OK);
}
{
OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
EXPECT_TRUE(resource != NULL);
- HeaderOptions headerOptions = {};
+ HeaderOptions headerOptions;
EXPECT_NO_THROW(resource->setHeaderOptions(headerOptions));
EXPECT_NO_THROW(resource->unsetHeaderOptions());
}