[easysetup] Static code analysis fix in provisioning
authorlankamadan <lanka.madan@samsung.com>
Thu, 10 Dec 2015 10:49:04 +0000 (19:49 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 21 Dec 2015 04:16:22 +0000 (04:16 +0000)
- Static code analysis bug is fixed

Change-Id: I7b7c5b3dd284de20a48aaf90a3b5bcbb72565714
Signed-off-by: lankamadan <lanka.madan@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4513
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/easy-setup/sdk/mediator/src/provisioning.cpp

index 26fb88e..a50d790 100644 (file)
@@ -135,46 +135,54 @@ OCStackApplicationResult ProvisionEnrolleeResponse(void* /*ctx*/, OCDoHandle /*h
         if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_PS, &ps)) {
 
             if (ps == 1) {
-                input = input->next;
-                continue;
+                OIC_LOG_V(DEBUG, ES_PROV_TAG, "PS is proper");
             }
             else {
-                OIC_LOG_V(DEBUG, ES_PROV_TAG, "PS is NOT proper");
+                OIC_LOG_V(ERROR, ES_PROV_TAG, "PS is NOT proper");
                 goto Error;
 
             }
         }
+        else {
+            OIC_LOG_V(ERROR, ES_PROV_TAG, "PS is NOT proper");
+            goto Error;
+        }
 
         if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn)) {
             if (!strcmp(tnn, netProvInfo->netAddressInfo.WIFI.ssid)) {
                 OIC_LOG_V(DEBUG, ES_PROV_TAG, "SSID is proper");
-                input = input->next;
-                continue;
+                OICFree(tnn);
             }
             else {
-                OIC_LOG_V(DEBUG, ES_PROV_TAG, "SSID is NOT proper");
+                OIC_LOG_V(ERROR, ES_PROV_TAG, "SSID is NOT proper");
+                OICFree(tnn);
                 goto Error;
             }
         }
+        else {
+            OIC_LOG_V(ERROR, ES_PROV_TAG, "SSID is NOT proper");
+            goto Error;
+        }
 
         if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd)) {
             if (!strcmp(cd, netProvInfo->netAddressInfo.WIFI.pwd)) {
                 OIC_LOG_V(DEBUG, ES_PROV_TAG, "Password is proper");
-                input = input->next;
-                continue;
+                OICFree(cd);
             }
             else {
-                OIC_LOG_V(DEBUG, ES_PROV_TAG, "Password is NOT proper");
+                OIC_LOG_V(ERROR, ES_PROV_TAG, "Password is NOT proper");
+                OICFree(cd);
                 goto Error;
             }
         }
+        else {
+            OIC_LOG_V(ERROR, ES_PROV_TAG, "Password  is NOT proper");
+            goto Error;
+        }
 
         LogProvisioningResponse(input->values);
 
         input = input->next;
-
-        OICFree(tnn);
-        OICFree(cd);
     }
 
     SuccessCallback(clientResponse);
@@ -183,14 +191,9 @@ OCStackApplicationResult ProvisionEnrolleeResponse(void* /*ctx*/, OCDoHandle /*h
 
     Error:
     {
-        OICFree(tnn);
-        OICFree(cd);
-
         ErrorCallback(DEVICE_NOT_PROVISIONED);
-
         return OC_STACK_DELETE_TRANSACTION;
     }
-
 }
 
 OCStackResult StartProvisioningProcess(const EnrolleeNWProvInfo_t *netInfo,