Fix a logic in linking child representation payload in batch interface
authorJihun Ha <jihun.ha@samsung.com>
Sat, 6 Aug 2016 01:32:46 +0000 (10:32 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Mon, 8 Aug 2016 05:34:35 +0000 (05:34 +0000)
If provisioning resource receives a GET request with BATCH interface and
cloud resource is not created by user's decision, device configuration
resource's representation will not delivered even if device configuration
resource exists. This patch fixes this issue.

Change-Id: I90a43e58cf12dab0732857418fae7f4a7ef9dc1a
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10091
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/easy-setup/enrollee/src/resourcehandler.c

index ed90ddf..b655e27 100755 (executable)
@@ -552,25 +552,31 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
     {
         if(strstr(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
         {// When Provisioning resource has a GET with BatchInterface
-            payload->next = constructResponseOfWiFi();
+            OCRepPayload* head = payload;
+            OCRepPayload* nextPayload = NULL;
 
-            if(payload->next)
+            nextPayload = constructResponseOfWiFi();
+            if(nextPayload != NULL)
             {
-                payload->next->next = constructResponseOfCloud();
-            }
-            else
-            {
-                return payload;
+                payload->next = nextPayload;
+                payload = payload->next;
             }
 
-            if(payload->next->next)
+            nextPayload = constructResponseOfCloud();
+            if(nextPayload != NULL)
             {
-                payload->next->next->next = constructResponseOfDevConf();
+                payload->next = nextPayload;
+                payload = payload->next;
             }
-            else
+
+            nextPayload = constructResponseOfDevConf();
+            if(nextPayload != NULL)
             {
-                return payload;
+                payload->next = nextPayload;
+                payload = payload->next;
             }
+
+            payload = head;
         }
     }
 
@@ -978,4 +984,4 @@ const char *getResult(OCStackResult result)
         default:
             return "UNKNOWN";
     }
-}
\ No newline at end of file
+}