From: Oleksandr Dmytrenko Date: Wed, 9 Nov 2016 15:33:44 +0000 (+0200) Subject: D2D Get request error fix X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61060e6ca5eef88b047f13dfc50afb97a4502001;p=contrib%2Fiotivity.git D2D Get request error fix Removed payload type check in Get request Change-Id: I405a7a6bba7255d8c05cc8a34342217c6e04e819 Signed-off-by: Oleksandr Dmytrenko Reviewed-on: https://gerrit.iotivity.org/gerrit/14163 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi Reviewed-by: Randeep Singh (cherry picked from commit 0528ed289e063f7ea5ec139f579032acbfc31a61) Reviewed-on: https://gerrit.iotivity.org/gerrit/14601 --- diff --git a/resource/csdk/security/provisioning/sample/cloud/cloudResource.c b/resource/csdk/security/provisioning/sample/cloud/cloudResource.c index bf43744..35ec5c2 100644 --- a/resource/csdk/security/provisioning/sample/cloud/cloudResource.c +++ b/resource/csdk/security/provisioning/sample/cloud/cloudResource.c @@ -55,12 +55,16 @@ static OCRepPayload* getPayload(const char* uri, int64_t power, bool state) static OCEntityHandlerResult ProcessRequest (OCEntityHandlerRequest *request, OCRepPayload **payload) { - if(!request || !request->payload || request->payload->type != PAYLOAD_TYPE_REPRESENTATION) + OIC_LOG_V(DEBUG, TAG, "%s: IN", __func__); + + if(!request) { - OIC_LOG(ERROR, TAG, "Incoming payload not a representation"); + OIC_LOG_V(ERROR, TAG, "%s: OUT: request is NULL",__func__); return OC_EH_ERROR; } + OIC_LOG_V(DEBUG, TAG, "%s: method: %d", __func__, request->method); + LEDResource *currLEDResource = &LED; if (request->resource == gLedInstance[0].handle) @@ -76,6 +80,12 @@ static OCEntityHandlerResult ProcessRequest (OCEntityHandlerRequest *request, if(OC_REST_PUT == request->method) { + if (!request->payload || request->payload->type != PAYLOAD_TYPE_REPRESENTATION) + { + OIC_LOG_V(ERROR, TAG, "%s: OUT: Incoming payload type(%d) is not a representation", + __func__, request->payload ? request->payload->type : 0); + return OC_EH_ERROR; + } OCRepPayload* input = (OCRepPayload*)request->payload; // Get pointer to query int64_t pow; @@ -93,7 +103,9 @@ static OCEntityHandlerResult ProcessRequest (OCEntityHandlerRequest *request, *payload = getPayload(gResourceUri, currLEDResource->power, currLEDResource->state); - return (*payload)? OC_EH_OK : OC_EH_ERROR; + OIC_LOG_V(DEBUG, TAG, "%s: OUT", __func__); + + return (*payload) ? OC_EH_OK : OC_EH_ERROR; } static OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *request,