[IOT-1185] Add OCResultToSuccess to ensure success. 17/9217/2
authorJaehong Jo <jaehong.jo@samsung.com>
Thu, 7 Jul 2016 12:47:53 +0000 (21:47 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Fri, 8 Jul 2016 05:22:18 +0000 (05:22 +0000)
If just check only OC_STACK_OK, it can cause problems.
Below value is success like OC_STACK_OK.
OC_STACK_RESOURCE_CREATED,
OC_STACK_RESOURCE_DELETED,
OC_STACK_CONTINUE.

BUG : https://jira.iotivity.org/browse/IOT-1185

Change-Id: I60b369138df00b98c4dbeb952ffba140aa902b27
Signed-off-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9217
Reviewed-by: Hyuna Jo <hyuna0213.jo@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/stack/include/internal/ocstackinternal.h
resource/csdk/stack/src/ocstack.c

index 678618c..241f588 100644 (file)
@@ -265,6 +265,14 @@ OCStackResult BindResourceTypeToResource(OCResource* resource,
  */
 OCStackResult CAResultToOCResult(CAResult_t caResult);
 
+/**
+ * Converts a OCStackResult type to a bool type.
+ *
+ * @param ocResult OCStackResult value to convert.
+ * @return true on success, false upon failure.
+ */
+bool OCResultToSuccess(OCStackResult ocResult);
+
 /**
  * Map OCQualityOfService to CAMessageType.
  *
index 046a5fe..1b06e18 100644 (file)
@@ -1843,7 +1843,7 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
                                     CA_MSG_ACKNOWLEDGE,0, NULL, NULL, 0, NULL);
         }
     }
-    else if(requestResult != OC_STACK_OK)
+    else if(!OCResultToSuccess(requestResult))
     {
         OIC_LOG_V(ERROR, TAG, "HandleStackRequests failed. error: %d", requestResult);
 
@@ -4619,3 +4619,17 @@ OCStackResult CAResultToOCResult(CAResult_t caResult)
             return OC_STACK_ERROR;
     }
 }
+
+bool OCResultToSuccess(OCStackResult ocResult)
+{
+    switch (ocResult)
+    {
+        case OC_STACK_OK:
+        case OC_STACK_RESOURCE_CREATED:
+        case OC_STACK_RESOURCE_DELETED:
+        case OC_STACK_CONTINUE:
+            return true;
+        default:
+            return false;
+    }
+}