some errors fix 74/27874/5
authorOleksandr Dmytrenko <o.dmytrenko@samsung.com>
Tue, 22 Jan 2019 13:42:28 +0000 (15:42 +0200)
committerAleksey Volkov <a.volkov@samsung.com>
Thu, 24 Jan 2019 09:17:59 +0000 (09:17 +0000)
crosses initialization and invalid conversion errors fix

Change-Id: I55cce4178f14eb1a7e5b45704650696d18b9ddec
Signed-off-by: Oleksandr Dmytrenko <o.dmytrenko@samsung.com>
resource/csdk/security/provisioning/src/ocprovisioningmanager.c
resource/csdk/security/provisioning/src/ownershiptransfermanager.c
resource/csdk/security/provisioning/src/oxmjustworks.c
resource/csdk/security/provisioning/src/oxmmanufacturercert.c
resource/csdk/security/provisioning/src/oxmrandompin.c
resource/csdk/security/provisioning/src/pmutility.c
resource/csdk/security/provisioning/src/secureresourceprovider.c

index 69d5067..d9966e5 100755 (executable)
@@ -627,7 +627,7 @@ OCStackResult OC_CALL OCUnlinkDevices(void* ctx,
                                       OCProvisionResultCB resultCallback)
 {
     OIC_LOG(INFO, TAG, "IN OCUnlinkDevices");
-    OCUuidList_t* idList = NULL;
+    OCUuidList_t *idList = NULL, *curDev = NULL;
     size_t numOfDev = 0;
 
     if (!pTargetDev1 || !pTargetDev2 || !pTargetDev1->doxm || !pTargetDev2->doxm)
@@ -661,7 +661,7 @@ OCStackResult OC_CALL OCUnlinkDevices(void* ctx,
     }
 
     // Check the linked devices contains the second device. If yes send credential DELETE request.
-    OCUuidList_t* curDev = idList;
+    curDev = idList;
     while (NULL != curDev)
     {
         if (memcmp(pTargetDev2->doxm->deviceID.id, curDev->dev.id, sizeof(curDev->dev.id)) == 0)
@@ -699,7 +699,7 @@ static OCStackResult RemoveDeviceInfoFromLocal(const OCProvisionDev_t* pTargetDe
         if (res != OC_STACK_RESOURCE_DELETED)
         {
             OIC_LOG(ERROR, TAG, "RemoveDeviceInfoFromLocal : Failed to remove credential.");
-            goto error;
+            return OC_STACK_ERROR;
         }
     }
     /**
@@ -730,7 +730,6 @@ static OCStackResult RemoveDeviceInfoFromLocal(const OCProvisionDev_t* pTargetDe
     OICFree(endpoint);
     OIC_LOG(DEBUG, TAG, "OUT RemoveDeviceInfoFromLocal");
 
-error:
     return res;
 }
 
@@ -826,6 +825,8 @@ OCStackResult OC_CALL OCRemoveDeviceWithUuid(void* ctx, unsigned short waitTimeF
     bool discoverdFlag = false;
     OCProvisionDev_t* pOwnedDevList = NULL;
     OCStackResult resReq = OC_STACK_CONTINUE;
+    OCUuidList_t* linkedDevices = NULL;
+    size_t numOfLinkedDevices = 0;
 
     if (!pTargetUuid || 0 == waitTimeForOwnedDeviceDiscovery)
     {
@@ -863,8 +864,6 @@ OCStackResult OC_CALL OCRemoveDeviceWithUuid(void* ctx, unsigned short waitTimeF
     }
     memcpy(pTargetDev->doxm->deviceID.id, pTargetUuid->id, sizeof(pTargetUuid->id));
 
-    OCUuidList_t* linkedDevices = NULL;
-    size_t numOfLinkedDevices = 0;
     res = PDMGetLinkedDevices(pTargetUuid, &linkedDevices, &numOfLinkedDevices);
     if(OC_STACK_OK != res)
     {
index 21dae06..aa1c368 100644 (file)
@@ -722,7 +722,7 @@ static CAResult_t OwnershipTransferSessionFailed(const CAEndpoint_t *endpoint,
         {
             if (WRONG_PIN_MAX_ATTEMP > otmCtx->attemptCnt)
             {
-                otmCtx->selectedDeviceInfo->connType &= ~CT_FLAG_SECURE;
+                otmCtx->selectedDeviceInfo->connType = (OCConnectivityType)(otmCtx->selectedDeviceInfo->connType & ~CT_FLAG_SECURE);
 
                 res = StartOwnershipTransfer(otmCtx, otmCtx->selectedDeviceInfo);
                 if (OC_STACK_OK != res)
@@ -763,6 +763,11 @@ CAResult_t DTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *in
     OIC_LOG_V(DEBUG, TAG, "In %s(endpoint = %p, info = %p)", __func__, endpoint, info);
 
     CAResult_t result = CA_STATUS_OK;
+    bool emptyOwnerUuid = false;
+    OicUuid_t emptyUuid = {.id={0}};
+    bool matching = false;
+    OicSecDoxm_t* newDevDoxm = NULL;
+    OTMContext_t* otmCtx = NULL;
 
     if (NULL == endpoint || NULL == info)
     {
@@ -772,14 +777,14 @@ CAResult_t DTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *in
     OIC_LOG_V(INFO, TAG, "Received status from remote device(%s:%d) : %d",
               endpoint->addr, endpoint->port, info->result);
 
-    OTMContext_t* otmCtx = GetOTMContext(endpoint->addr, endpoint->port);
+    otmCtx = GetOTMContext(endpoint->addr, endpoint->port);
     if (NULL == otmCtx)
     {
         OIC_LOG(ERROR, TAG, "OTM context not found!");
         goto exit;
     }
 
-    OicSecDoxm_t* newDevDoxm = otmCtx->selectedDeviceInfo->doxm;
+    newDevDoxm = otmCtx->selectedDeviceInfo->doxm;
     if (NULL == newDevDoxm)
     {
         OIC_LOG(ERROR, TAG, "New device doxm not found!");
@@ -787,7 +792,7 @@ CAResult_t DTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *in
     }
 
     //Make sure the address matches.
-    bool matching = (0 == strncmp(otmCtx->selectedDeviceInfo->endpoint.addr,
+    matching = (0 == strncmp(otmCtx->selectedDeviceInfo->endpoint.addr,
                                   endpoint->addr, sizeof(endpoint->addr)));
     matching = (matching && (getSecurePort(otmCtx->selectedDeviceInfo) == endpoint->port));
 
@@ -798,8 +803,7 @@ CAResult_t DTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *in
         goto exit;
     }
 
-    OicUuid_t emptyUuid = {.id={0}};
-    bool emptyOwnerUuid = (memcmp(&(newDevDoxm->owner), &emptyUuid, sizeof(OicUuid_t)) == 0);
+    emptyOwnerUuid = (memcmp(&(newDevDoxm->owner), &emptyUuid, sizeof(OicUuid_t)) == 0);
 
     //If temporal secure session established successfully
     if ((CA_STATUS_OK == info->result) && !newDevDoxm->owned && emptyOwnerUuid)
@@ -961,10 +965,11 @@ static OCStackApplicationResult OwnerTransferModeHandler(void *ctx, OCDoHandle U
 {
     OIC_LOG(DEBUG, TAG, "IN OwnerTransferModeHandler");
 
+    OTMContext_t* otmCtx = (OTMContext_t*)ctx;
+
     VERIFY_NOT_NULL(TAG, clientResponse, WARNING);
     VERIFY_NOT_NULL(TAG, ctx, WARNING);
 
-    OTMContext_t* otmCtx = (OTMContext_t*)ctx;
     otmCtx->ocDoHandle = NULL;
     (void)UNUSED;
     if (OC_STACK_RESOURCE_CHANGED == clientResponse->result)
@@ -1003,7 +1008,7 @@ static OCStackApplicationResult OwnerTransferModeHandler(void *ctx, OCDoHandle U
             }
 
             //This is a secure session.
-            otmCtx->selectedDeviceInfo->connType |= CT_FLAG_SECURE;
+            otmCtx->selectedDeviceInfo->connType = (OCConnectivityType)(otmCtx->selectedDeviceInfo->connType | CT_FLAG_SECURE);
 
             //Send request : GET /oic/sec/doxm. Then verify that the property values obtained this way
             //are the same as those already-stored in the otmCtx.
@@ -1042,10 +1047,11 @@ static OCStackApplicationResult ListMethodsHandler(void *ctx, OCDoHandle UNUSED,
 {
     OIC_LOG(DEBUG, TAG, "IN ListMethodsHandler");
 
+    OTMContext_t* otmCtx = (OTMContext_t*)ctx;
+
     VERIFY_NOT_NULL(TAG, clientResponse, WARNING);
     VERIFY_NOT_NULL(TAG, ctx, WARNING);
 
-    OTMContext_t* otmCtx = (OTMContext_t*)ctx;
     otmCtx->ocDoHandle = NULL;
     (void)UNUSED;
     if  (OC_STACK_OK == clientResponse->result)
@@ -1117,10 +1123,11 @@ exit:
 static OCStackApplicationResult DeviceUuidUpdateHandler(void *ctx, OCDoHandle handle,
                                 OCClientResponse *clientResponse)
 {
-    VERIFY_NOT_NULL(TAG, clientResponse, WARNING);
-    VERIFY_NOT_NULL(TAG, ctx, WARNING);
-
     OIC_LOG(DEBUG, TAG, "IN DeviceUuidUpdateHandler");
+
+    VERIFY_NOT_NULL_RETURN(TAG, ctx, WARNING, OC_STACK_DELETE_TRANSACTION);
+    VERIFY_NOT_NULL_RETURN(TAG, clientResponse, WARNING, OC_STACK_DELETE_TRANSACTION);
+
     OC_UNUSED(handle);
     OCStackResult res = OC_STACK_OK;
     OTMContext_t* otmCtx = (OTMContext_t*)ctx;
@@ -1130,7 +1137,7 @@ static OCStackApplicationResult DeviceUuidUpdateHandler(void *ctx, OCDoHandle ha
     {
         OIC_LOG_V(WARNING, TAG, "DeviceUuidUpdateHandler : Client response is incorrect : %d",
                 clientResponse->result);
-        goto exit;
+        return OC_STACK_DELETE_TRANSACTION;
     }
 
     OCProvisionDev_t* deviceInfo = otmCtx->selectedDeviceInfo;
@@ -1179,7 +1186,7 @@ static OCStackApplicationResult DeviceUuidUpdateHandler(void *ctx, OCDoHandle ha
     {
         OIC_LOG_V(ERROR, TAG, "SetupPDM error : %d", res);
         SetResult(otmCtx, res);
-        return res;
+        return (OCStackApplicationResult)res;
     }
 
     res = SaveOwnerPSK(otmCtx->selectedDeviceInfo);
@@ -1202,9 +1209,6 @@ static OCStackApplicationResult DeviceUuidUpdateHandler(void *ctx, OCDoHandle ha
 
     OIC_LOG(DEBUG, TAG, "OUT DeviceUuidUpdateHandler");
     return OC_STACK_KEEP_TRANSACTION;
-
-exit:
-    return  OC_STACK_DELETE_TRANSACTION;
 }
 
 /**
@@ -1219,10 +1223,11 @@ exit:
 static OCStackApplicationResult OwnerUuidUpdateHandler(void *ctx, OCDoHandle UNUSED,
                                 OCClientResponse *clientResponse)
 {
-    VERIFY_NOT_NULL(TAG, clientResponse, WARNING);
-    VERIFY_NOT_NULL(TAG, ctx, WARNING);
-
     OIC_LOG(DEBUG, TAG, "IN OwnerUuidUpdateHandler");
+
+    VERIFY_NOT_NULL_RETURN(TAG, ctx, WARNING, OC_STACK_DELETE_TRANSACTION);
+    VERIFY_NOT_NULL_RETURN(TAG, clientResponse, WARNING, OC_STACK_DELETE_TRANSACTION);
+
     (void)UNUSED;
     OCStackResult res = OC_STACK_OK;
     OTMContext_t* otmCtx = (OTMContext_t*)ctx;
@@ -1275,7 +1280,6 @@ static OCStackApplicationResult OwnerUuidUpdateHandler(void *ctx, OCDoHandle UNU
 
     OIC_LOG(DEBUG, TAG, "OUT OwnerUuidUpdateHandler");
 
-exit:
     return  OC_STACK_DELETE_TRANSACTION;
 }
 
@@ -1293,8 +1297,8 @@ static OCStackApplicationResult OperationModeUpdateHandler(void *ctx, OCDoHandle
 {
     OIC_LOG(DEBUG, TAG, "IN OperationModeUpdateHandler");
 
-    VERIFY_NOT_NULL(TAG, clientResponse, WARNING);
-    VERIFY_NOT_NULL(TAG, ctx, WARNING);
+    VERIFY_NOT_NULL_RETURN(TAG, ctx, WARNING, OC_STACK_DELETE_TRANSACTION);
+    VERIFY_NOT_NULL_RETURN(TAG, clientResponse, WARNING, OC_STACK_DELETE_TRANSACTION);
 
     OTMContext_t* otmCtx = (OTMContext_t*)ctx;
     otmCtx->ocDoHandle = NULL;
@@ -1317,7 +1321,6 @@ static OCStackApplicationResult OperationModeUpdateHandler(void *ctx, OCDoHandle
 
     OIC_LOG(DEBUG, TAG, "OUT OperationModeUpdateHandler");
 
-exit:
     return  OC_STACK_DELETE_TRANSACTION;
 }
 
@@ -1333,10 +1336,11 @@ exit:
 static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNUSED,
                                 OCClientResponse *clientResponse)
 {
-    VERIFY_NOT_NULL(TAG, clientResponse, WARNING);
-    VERIFY_NOT_NULL(TAG, ctx, WARNING);
-
     OIC_LOG(DEBUG, TAG, "IN OwnerCredentialHandler");
+
+    VERIFY_NOT_NULL_RETURN(TAG, ctx, WARNING, OC_STACK_DELETE_TRANSACTION);
+    VERIFY_NOT_NULL_RETURN(TAG, clientResponse, WARNING, OC_STACK_DELETE_TRANSACTION);
+
     (void)UNUSED;
     OCStackResult res = OC_STACK_OK;
     OTMContext_t* otmCtx = (OTMContext_t*)ctx;
@@ -1416,7 +1420,6 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
 
         OIC_LOG(DEBUG, TAG, "OUT OwnerCredentialHandler");
 
-    exit:
         return  OC_STACK_DELETE_TRANSACTION;
     }
 
@@ -1438,11 +1441,12 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
 
         OC_UNUSED(handle);
 
-        VERIFY_NOT_NULL(TAG, ctx, WARNING);
+        VERIFY_NOT_NULL_RETURN(TAG, ctx, WARNING, OC_STACK_DELETE_TRANSACTION);
+        VERIFY_NOT_NULL_RETURN(TAG, clientResponse, WARNING, OC_STACK_DELETE_TRANSACTION);
+
         OTMContext_t* otmCtx = (OTMContext_t*)ctx;
-        VERIFY_NOT_NULL(TAG, otmCtx->selectedDeviceInfo, WARNING);
         OCProvisionDev_t* selectedDeviceInfo = otmCtx->selectedDeviceInfo;
-        VERIFY_NOT_NULL(TAG, clientResponse, WARNING);
+        VERIFY_NOT_NULL_RETURN(TAG, selectedDeviceInfo, WARNING, OC_STACK_DELETE_TRANSACTION);
 
         otmCtx->ocDoHandle = NULL;
 
@@ -1478,7 +1482,7 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
             OIC_LOG_V(ERROR, TAG, "OwnerAclHandler : Unexpected result %d", res);
             SetResult(otmCtx, res);
         }
-    exit:
+
         OIC_LOG(DEBUG, TAG, "OUT OwnerAclHandler");
         return  OC_STACK_DELETE_TRANSACTION;
     }
@@ -1495,13 +1499,14 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
     static OCStackApplicationResult OwnershipInformationHandler(void *ctx, OCDoHandle UNUSED,
                                     OCClientResponse *clientResponse)
     {
-        VERIFY_NOT_NULL(TAG, clientResponse, WARNING);
-        VERIFY_NOT_NULL(TAG, ctx, WARNING);
-
         OIC_LOG(DEBUG, TAG, "IN OwnershipInformationHandler");
+
+        VERIFY_NOT_NULL_RETURN(TAG, ctx, WARNING, OC_STACK_DELETE_TRANSACTION);
+
         (void)UNUSED;
         OCStackResult res = OC_STACK_OK;
         OTMContext_t* otmCtx = (OTMContext_t*)ctx;
+        VERIFY_NOT_NULL_RETURN(TAG, otmCtx->selectedDeviceInfo, WARNING, OC_STACK_DELETE_TRANSACTION);
         otmCtx->ocDoHandle = NULL;
 
         if(OC_STACK_RESOURCE_CHANGED == clientResponse->result)
@@ -1527,9 +1532,7 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
         }
 
         OIC_LOG(DEBUG, TAG, "OUT OwnershipInformationHandler");
-
-    exit:
-        return  OC_STACK_DELETE_TRANSACTION;
+        return OC_STACK_DELETE_TRANSACTION;
     }
 
     /**
@@ -1546,10 +1549,10 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
     {
         OIC_LOG_V(INFO, TAG, "IN ProvisioningStatusHandler.");
 
-        VERIFY_NOT_NULL(TAG, clientResponse, ERROR);
-        VERIFY_NOT_NULL(TAG, ctx, ERROR);
+        VERIFY_NOT_NULL_RETURN(TAG, ctx, WARNING, OC_STACK_DELETE_TRANSACTION);
 
         OTMContext_t* otmCtx = (OTMContext_t*) ctx;
+        VERIFY_NOT_NULL_RETURN(TAG, otmCtx->selectedDeviceInfo, WARNING, OC_STACK_DELETE_TRANSACTION);
         otmCtx->ocDoHandle = NULL;
         (void)UNUSED;
         OCStackResult res = OC_STACK_OK;
@@ -1575,7 +1578,6 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
             SetResult(otmCtx, clientResponse->result);
         }
 
-    exit:
         OIC_LOG_V(INFO, TAG, "OUT ProvisioningStatusHandler.");
         return OC_STACK_DELETE_TRANSACTION;
     }
@@ -1594,10 +1596,10 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
     {
         OIC_LOG_V(INFO, TAG, "IN ReadyForNomalStatusHandler.");
 
-        VERIFY_NOT_NULL(TAG, clientResponse, ERROR);
-        VERIFY_NOT_NULL(TAG, ctx, ERROR);
+        VERIFY_NOT_NULL_RETURN(TAG, ctx, WARNING, OC_STACK_DELETE_TRANSACTION);
 
         OTMContext_t* otmCtx = (OTMContext_t*) ctx;
+        VERIFY_NOT_NULL_RETURN(TAG, otmCtx->selectedDeviceInfo, WARNING, OC_STACK_DELETE_TRANSACTION);
         otmCtx->ocDoHandle = NULL;
         (void)UNUSED;
 
@@ -1625,7 +1627,6 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
             SetResult(otmCtx, clientResponse->result);
         }
 
-    exit:
         OIC_LOG_V(INFO, TAG, "OUT ReadyForNomalStatusHandler.");
         return OC_STACK_DELETE_TRANSACTION;
     }
@@ -1644,10 +1645,10 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
     {
         OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);
 
-        VERIFY_NOT_NULL(TAG, clientResponse, WARNING);
-        VERIFY_NOT_NULL(TAG, ctx, WARNING);
+        VERIFY_NOT_NULL_RETURN(TAG, ctx, WARNING, OC_STACK_DELETE_TRANSACTION);
 
         OTMContext_t* otmCtx = (OTMContext_t*)ctx;
+        VERIFY_NOT_NULL_RETURN(TAG, otmCtx->selectedDeviceInfo, WARNING, OC_STACK_DELETE_TRANSACTION);
         otmCtx->ocDoHandle = NULL;
         (void)UNUSED;
 
@@ -1719,7 +1720,6 @@ static OCStackApplicationResult OwnerCredentialHandler(void *ctx, OCDoHandle UNU
         }
 
         OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__);
-    exit:
         return OC_STACK_DELETE_TRANSACTION;
     }
 
@@ -1730,11 +1730,8 @@ static OCStackResult PostOwnerCredential(OTMContext_t* otmCtx)
     OCHeaderOption *options = NULL;
     uint8_t numOptions = 0;
 
-    if (!otmCtx || !otmCtx->selectedDeviceInfo)
-    {
-        OIC_LOG(ERROR, TAG, "Invalid parameters");
-        return OC_STACK_INVALID_PARAM;
-    }
+    VERIFY_NOT_NULL_RETURN(TAG, otmCtx, ERROR, OC_STACK_INVALID_PARAM);
+    VERIFY_NOT_NULL_RETURN(TAG, otmCtx->selectedDeviceInfo, ERROR, OC_STACK_INVALID_PARAM);
 
     OCProvisionDev_t* deviceInfo = otmCtx->selectedDeviceInfo;
     char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
@@ -1757,6 +1754,7 @@ static OCStackResult PostOwnerCredential(OTMContext_t* otmCtx)
     }
 
     //Generate owner credential for new device
+    OicUuid_t credSubjectId = {.id={0}};
     secPayload->base.type = PAYLOAD_TYPE_SECURITY;
     const OicSecCred_t* ownerCredential = GetCredResourceData(&(deviceInfo->doxm->deviceID));
     if (NULL == ownerCredential)
@@ -1766,7 +1764,6 @@ static OCStackResult PostOwnerCredential(OTMContext_t* otmCtx)
         goto exit;
     }
 
-    OicUuid_t credSubjectId = {.id={0}};
     if (OC_STACK_OK == GetDoxmDeviceID(&credSubjectId))
     {
         OicSecCred_t newCredential;
@@ -2518,11 +2515,12 @@ static OCStackResult SetupPDM(const OCProvisionDev_t* selectedDevice)
 {
     OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);
 
+    VERIFY_NOT_NULL_RETURN(TAG, selectedDevice, ERROR, OC_STACK_INVALID_PARAM);
+    VERIFY_NOT_NULL_RETURN(TAG, selectedDevice->doxm, ERROR, OC_STACK_INVALID_PARAM);
+
     char* strUuid = NULL;
     OCStackResult res = OC_STACK_INVALID_PARAM;
-
-    VERIFY_NOT_NULL(TAG, selectedDevice, ERROR);
-    VERIFY_NOT_NULL(TAG, selectedDevice->doxm, ERROR);
+    bool isDuplicate = true;
 
     PdmDeviceState_t pdmState = PDM_DEVICE_UNKNOWN;
     res = PDMGetDeviceState(&selectedDevice->doxm->deviceID, &pdmState);
@@ -2569,7 +2567,6 @@ static OCStackResult SetupPDM(const OCProvisionDev_t* selectedDevice)
     }
 
     //Checking duplication of Device ID.
-    bool isDuplicate = true;
     res = PDMIsDuplicateDevice(&selectedDevice->doxm->deviceID, &isDuplicate);
     if (OC_STACK_OK != res)
     {
@@ -2624,12 +2621,14 @@ static OCStackResult StartOwnershipTransfer(void* ctx, OCProvisionDev_t* selecte
     OIC_LOG(INFO, TAG, "IN StartOwnershipTransfer");
     OCStackResult res = OC_STACK_INVALID_PARAM;
 
-    VERIFY_NOT_NULL(TAG, selectedDevice, ERROR);
-    VERIFY_NOT_NULL(TAG, selectedDevice->doxm, ERROR);
+    VERIFY_NOT_NULL_RETURN(TAG, ctx, ERROR, OC_STACK_INVALID_PARAM);
 
     OTMContext_t* otmCtx = (OTMContext_t*)ctx;
     otmCtx->selectedDeviceInfo = selectedDevice;
 
+    VERIFY_NOT_NULL_RETURN(TAG, selectedDevice, ERROR, OC_STACK_INVALID_PARAM);
+    VERIFY_NOT_NULL_RETURN(TAG, selectedDevice->doxm, ERROR, OC_STACK_INVALID_PARAM);
+
     //Select the OxM to performing ownership transfer
     res = OTMSelectOwnershipTransferMethod(selectedDevice->doxm->oxm,
                                           selectedDevice->doxm->oxmLen,
@@ -2669,7 +2668,6 @@ static OCStackResult StartOwnershipTransfer(void* ctx, OCProvisionDev_t* selecte
 
     OIC_LOG(INFO, TAG, "OUT StartOwnershipTransfer");
 
-exit:
     return res;
 }
 
@@ -2792,12 +2790,10 @@ OCStackResult PostProvisioningStatus(OTMContext_t* otmCtx)
 {
     OIC_LOG_V(INFO, TAG, "IN %s", __func__);
     OCStackResult res = OC_STACK_ERROR;
+    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
 
-    if(!otmCtx || !otmCtx->selectedDeviceInfo)
-    {
-        OIC_LOG(ERROR, TAG, "OTMContext is NULL");
-        return OC_STACK_INVALID_PARAM;
-    }
+    VERIFY_NOT_NULL_RETURN(TAG, otmCtx, ERROR, OC_STACK_INVALID_PARAM);
+    VERIFY_NOT_NULL_RETURN(TAG, otmCtx->selectedDeviceInfo, ERROR, OC_STACK_INVALID_PARAM);
 
     OCProvisionDev_t* deviceInfo = otmCtx->selectedDeviceInfo;
     // Change the TAKE_OWNER bit of TM to 0 (optional in Client Directed)
@@ -2869,7 +2865,6 @@ OCStackResult PostProvisioningStatus(OTMContext_t* otmCtx)
     OIC_LOG(DEBUG, TAG, "Created payload for chage to Provisiong state");
     OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
 
-    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
     assert(otmCtx->selectedDeviceInfo->connType & CT_FLAG_SECURE);
 
     if(!PMGenerateQuery(true,
@@ -2910,22 +2905,17 @@ OCStackResult PostNormalOperationStatus(OTMContext_t* otmCtx)
 {
     OIC_LOG(INFO, TAG, "IN PostNormalOperationStatus");
     OCStackResult res = OC_STACK_ERROR;
+    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
 
-    if(!otmCtx || !otmCtx->selectedDeviceInfo)
-    {
-        OIC_LOG(ERROR, TAG, "OTMContext is NULL");
-        return OC_STACK_INVALID_PARAM;
-    }
+    VERIFY_NOT_NULL_RETURN(TAG, otmCtx, ERROR, OC_STACK_INVALID_PARAM);
+    VERIFY_NOT_NULL_RETURN(TAG, otmCtx->selectedDeviceInfo, ERROR, OC_STACK_INVALID_PARAM);
 
     OCProvisionDev_t* deviceInfo = otmCtx->selectedDeviceInfo;
     otmCtx->selectedDeviceInfo->pstat->dos.state = DOS_RFNOP;
 
     OCSecurityPayload *secPayload = (OCSecurityPayload *)OICCalloc(1, sizeof(OCSecurityPayload));
-    if (NULL == secPayload)
-    {
-        OIC_LOG(ERROR, TAG, "Failed to memory allocation");
-        return OC_STACK_NO_MEMORY;
-    }
+    VERIFY_NOT_NULL_RETURN(TAG, secPayload, ERROR, OC_STACK_NO_MEMORY);
+
     secPayload->base.type = PAYLOAD_TYPE_SECURITY;
     OCHeaderOption *options = NULL;
     uint8_t numOptions = 0;
@@ -2968,7 +2958,6 @@ OCStackResult PostNormalOperationStatus(OTMContext_t* otmCtx)
     OIC_LOG(DEBUG, TAG, "Created payload for chage to Provisiong state");
     OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
 
-    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
     assert(otmCtx->selectedDeviceInfo->connType & CT_FLAG_SECURE);
 
     if(!PMGenerateQuery(true,
@@ -3105,8 +3094,8 @@ static OCStackApplicationResult RownerUuidHandler(void *ctx, OCDoHandle handle,
 {
     OIC_LOG_V(INFO, TAG, "%s IN", __func__);
 
-    VERIFY_NOT_NULL(TAG, clientResponse, ERROR);
-    VERIFY_NOT_NULL(TAG, ctx, ERROR);
+    VERIFY_NOT_NULL_RETURN(TAG, ctx, ERROR, OC_STACK_DELETE_TRANSACTION);
+    VERIFY_NOT_NULL_RETURN(TAG, clientResponse, ERROR, OC_STACK_DELETE_TRANSACTION);
 
     OTMContext_t* otmCtx = (OTMContext_t*) ctx;
     OC_UNUSED(handle);
@@ -3143,7 +3132,7 @@ static OCStackApplicationResult RownerUuidHandler(void *ctx, OCDoHandle handle,
             SetResult(otmCtx, OC_STACK_ERROR);
         }
     }
-exit:
+
     OIC_LOG_V(INFO, TAG, "%s OUT", __func__);
     return OC_STACK_DELETE_TRANSACTION;
 }
@@ -3151,23 +3140,18 @@ exit:
 OCStackResult PostRownerUuid(OTMContext_t* otmCtx)
 {
     OIC_LOG_V(INFO, TAG, "%s IN", __func__);
+
+    VERIFY_NOT_NULL_RETURN(TAG, otmCtx, ERROR, OC_STACK_INVALID_PARAM);
+    VERIFY_NOT_NULL_RETURN(TAG, otmCtx->selectedDeviceInfo, ERROR, OC_STACK_INVALID_PARAM);
+
     OCStackResult res = OC_STACK_ERROR;
     OCHeaderOption *options = NULL;
     uint8_t numOptions = 0;
-
-    if (!otmCtx || !otmCtx->selectedDeviceInfo)
-    {
-        OIC_LOG_V(ERROR, TAG, "%s: %s is NULL", __func__, !otmCtx ? "OTMContext" : "selectedDeviceInfo" );
-        return OC_STACK_INVALID_PARAM;
-    }
+    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
 
     OCProvisionDev_t* deviceInfo = otmCtx->selectedDeviceInfo;
     OCSecurityPayload *secPayload = (OCSecurityPayload *)OICCalloc(1, sizeof(OCSecurityPayload));
-    if (NULL == secPayload)
-    {
-        OIC_LOG_V(ERROR, TAG, "%s: Failed to memory allocation", __func__);
-        return OC_STACK_NO_MEMORY;
-    }
+    VERIFY_NOT_NULL_RETURN(TAG, secPayload, ERROR, OC_STACK_NO_MEMORY);
     secPayload->base.type = PAYLOAD_TYPE_SECURITY;
 
     bool propertiesToInclude[PSTAT_PROPERTY_COUNT];
@@ -3198,7 +3182,6 @@ OCStackResult PostRownerUuid(OTMContext_t* otmCtx)
     OIC_LOG(DEBUG, TAG, "Created payload for set rowner uuid");
     OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
 
-    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
     assert(deviceInfo->connType & CT_FLAG_SECURE);
 
     if (!PMGenerateQuery(true,
index dd9604a..f65674b 100644 (file)
@@ -109,7 +109,7 @@ OCStackResult CreateSecureSessionJustWorksCallback(OTMContext_t* otmCtx)
     }
     OIC_LOG(INFO, TAG, "Anonymous cipher suite Enabled.");
 
-    caresult  = CASelectCipherSuite(MBEDTLS_TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256, otmCtx->selectedDeviceInfo->endpoint.adapter);
+    caresult  = CASelectCipherSuite(MBEDTLS_TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256, (CATransportAdapter_t)otmCtx->selectedDeviceInfo->endpoint.adapter);
     if (CA_STATUS_OK != caresult)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to select TLS_ECDH_anon_WITH_AES_128_CBC_SHA256");
index f79e4f1..1ba8554 100644 (file)
@@ -154,7 +154,7 @@ OCStackResult CreateSecureSessionMCertificateCallback(OTMContext_t* otmCtx)
     OIC_LOG(INFO, TAG, "Anonymous cipher suite disabled.");
 
     caresult  = CASelectCipherSuite(MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8,
-                                    otmCtx->selectedDeviceInfo->endpoint.adapter);
+                                    (CATransportAdapter_t)otmCtx->selectedDeviceInfo->endpoint.adapter);
     if (CA_STATUS_OK != caresult)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to select MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8");
index 9c06bed..ca383de 100644 (file)
@@ -150,7 +150,7 @@ OCStackResult CreateSecureSessionRandomPinCallback(OTMContext_t* otmCtx)
     }
     OIC_LOG(INFO, TAG, "Anonymous cipher suite disabled.");
 
-    caresult  = CASelectCipherSuite(MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, otmCtx->selectedDeviceInfo->endpoint.adapter);
+    caresult  = CASelectCipherSuite(MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, (CATransportAdapter_t)otmCtx->selectedDeviceInfo->endpoint.adapter);
     if (CA_STATUS_OK != caresult)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to select TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256");
index 17b0f39..3aec5e5 100644 (file)
@@ -503,10 +503,11 @@ OCProvisionDev_t* PMCloneOCProvisionDevList(const OCProvisionDev_t* src)
         return NULL;
     }
 
+    OCProvisionDev_t* current = NULL;
     OCProvisionDev_t* newDev = PMCloneOCProvisionDev(src);
     VERIFY_NOT_NULL(TAG, newDev, ERROR);
 
-    OCProvisionDev_t* current = newDev;
+    current = newDev;
     for (OCProvisionDev_t* next = src->next; NULL != next; next = next->next)
     {
         current->next = PMCloneOCProvisionDev(next);
@@ -567,12 +568,12 @@ bool OC_CALL PMGenerateQuery(bool isSecure,
     }
 
     int snRet = 0;
-    char* prefix = (isSecure == true) ? COAPS_PREFIX : COAP_PREFIX;
+    char* prefix = (char *)((isSecure == true) ? COAPS_PREFIX : COAP_PREFIX);
 
     switch(connType & CT_MASK_ADAPTER)
     {
         case CT_ADAPTER_TCP:
-            prefix = (isSecure == true) ? COAPS_TCP_PREFIX : COAP_TCP_PREFIX;
+            prefix = (char*)((isSecure == true) ? COAPS_TCP_PREFIX : COAP_TCP_PREFIX);
             /* fall through */
         case CT_ADAPTER_IP:
             switch(connType & CT_MASK_FLAGS & ~CT_FLAG_SECURE)
@@ -1044,7 +1045,7 @@ OCStackResult PMSingleDeviceDiscovery(unsigned short waittime, const OicUuid_t*
     }
 
 
-    DiscoveryInfo *pDInfo = OICCalloc(1, sizeof(DiscoveryInfo));
+    DiscoveryInfo *pDInfo = (DiscoveryInfo *)OICCalloc(1, sizeof(DiscoveryInfo));
     if(NULL == pDInfo)
     {
         OIC_LOG(ERROR, TAG, "PMSingleDeviceDiscovery : Memory allocation failed.");
@@ -1140,7 +1141,7 @@ OCStackResult PMDeviceDiscovery(unsigned short waittime, bool isOwned, OCProvisi
     const char DOXM_OWNED_FALSE_MULTICAST_QUERY[] = "/oic/sec/doxm?Owned=FALSE";
     const char DOXM_OWNED_TRUE_MULTICAST_QUERY[] = "/oic/sec/doxm?Owned=TRUE";
 
-    DiscoveryInfo *pDInfo = OICCalloc(1, sizeof(DiscoveryInfo));
+    DiscoveryInfo *pDInfo = (DiscoveryInfo *)OICCalloc(1, sizeof(DiscoveryInfo));
     if(NULL == pDInfo)
     {
         OIC_LOG(ERROR, TAG, "PMDeviceDiscovery : Memory allocation failed.");
@@ -1242,7 +1243,7 @@ OCStackResult PMSingleDeviceDiscoveryInUnicast(unsigned short waittime, const Oi
         hostAddress = "";
     }
     snprintf(query, MAX_URI_LENGTH + MAX_QUERY_LENGTH + 1, "%s/oic/sec/doxm", hostAddress);
-    connType = connType & CT_MASK_ADAPTER;
+    connType = (OCConnectivityType)(connType & CT_MASK_ADAPTER);
 
     OCDoHandle handle = NULL;
     res = OCDoResource(&handle, OC_REST_DISCOVER, query, 0, 0,
index f4af64c..2e084be 100644 (file)
@@ -57,7 +57,7 @@
 
 #define TAG "OIC_SRPAPI"
 
-trustCertChainContext_t g_trustCertChainNotifier;
+static trustCertChainContext_t g_trustCertChainNotifier;
 
 /**
  * Structure to carry credential data to callback.
@@ -188,9 +188,10 @@ struct UnlinkData {
 };
 
 //Example of DELETE cred request -> coaps://0.0.0.0:5684/oic/sec/cred?sub=(BASE64 ENCODED UUID)
-const char * SRP_FORM_DELETE_CREDENTIAL = "coaps://[%s]:%d%s?%s=%s";
-const char * SRP_FORM_DELETE_CREDENTIAL_TCP = "coaps+tcp://[%s]:%d%s?%s=%s";
-
+static const char * SRP_FORM_DELETE_CREDENTIAL = "coaps://[%s]:%d%s?%s=%s";
+#ifdef __WITH_TLS__
+static const char * SRP_FORM_DELETE_CREDENTIAL_TCP = "coaps+tcp://[%s]:%d%s?%s=%s";
+#endif //__WITH_TLS__
 // Structure to carry remove APIs data to callback.
 typedef struct RemoveData RemoveData_t;
 struct RemoveData {
@@ -384,7 +385,7 @@ static OCStackApplicationResult provisionCredentialCB2(void *ctx, OCDoHandle UNU
     }
     OIC_LOG(INFO, TAG, "provisionCredentialCB2 received Null clientResponse");
     registerResultForCredProvisioning(credData, OC_STACK_ERROR, DEVICE_2_FINISHED);
-    ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
+    ((OCProvisionResultCB)(resultCallback))(credData->ctx,  credData->numOfResults,
                                             credData->resArr,
                                             true);
     OICFree(credData->resArr);
@@ -428,7 +429,7 @@ static OCStackApplicationResult provisionCredentialCB1(void *ctx, OCDoHandle UNU
             }
             if (OC_STACK_OK != res)
             {
-                registerResultForCredProvisioning(credData, res,2);
+                registerResultForCredProvisioning(credData, res, DEVICE_LOCAL_FINISHED);
                 ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
                                                         credData->resArr,
                                                         true);
@@ -498,7 +499,7 @@ static OCStackApplicationResult ProvisionCredentialDosCB2(void *ctx, OCDoHandle
             ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
                                                     credData->resArr,
                                                     false);
-            FreeData(ctx);
+            FreeData((Data_t *)ctx);
             return OC_STACK_DELETE_TRANSACTION;
         }
 
@@ -508,7 +509,7 @@ static OCStackApplicationResult ProvisionCredentialDosCB2(void *ctx, OCDoHandle
     ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
                                             credData->resArr,
                                             true);
-    FreeData(ctx);
+    FreeData((Data_t *)ctx);
     OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__);
     return OC_STACK_DELETE_TRANSACTION;
 }
@@ -560,11 +561,11 @@ static OCStackApplicationResult ProvisionCredentialDosCB1(void *ctx, OCDoHandle
             }
             if (OC_STACK_OK != res)
             {
-                registerResultForCredProvisioning(credData, res, 2);
+                registerResultForCredProvisioning(credData, res, DEVICE_LOCAL_FINISHED);
                 ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
                                                         credData->resArr,
                                                         true);
-                FreeData(ctx);
+                FreeData((Data_t *)ctx);
             }
         }
         else
@@ -573,7 +574,7 @@ static OCStackApplicationResult ProvisionCredentialDosCB1(void *ctx, OCDoHandle
             ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
                                                     credData->resArr,
                                                     true);
-            FreeData(ctx);
+            FreeData((Data_t *)ctx);
         }
     }
     else
@@ -583,7 +584,7 @@ static OCStackApplicationResult ProvisionCredentialDosCB1(void *ctx, OCDoHandle
         ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
                                                 credData->resArr,
                                                 true);
-        FreeData(ctx);
+        FreeData((Data_t *)ctx);
     }
     OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__);
     return OC_STACK_DELETE_TRANSACTION;
@@ -867,7 +868,7 @@ OCStackApplicationResult SetReadyForNormalOperationCB(void *ctx, OCDoHandle hand
         {
             RegisterProvResult(targetDev, resArr, numOfResults, clientResponse->result);
             resultCallback(dataCtx, *numOfResults, resArr, clientResponse->result != OC_STACK_RESOURCE_CHANGED);
-            FreeData(ctx);
+            FreeData((Data_t*)ctx);
         }
         else
         {
@@ -905,6 +906,14 @@ OCStackResult SetDOS(const Data_t *data, OicSecDeviceOnboardingState_t dos,
         return OC_STACK_INVALID_PARAM;
     }
 
+    OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
+    OCMethod method = OC_REST_POST;
+    OCDoHandle handle = NULL;
+    OCProvisionDev_t *targetDev = NULL;
+    bool propertiesToInclude[PSTAT_PROPERTY_COUNT] = {false};
+
+    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
+
     const OCProvisionDev_t *pTargetDev = NULL;
 
     switch (data->type)
@@ -926,7 +935,7 @@ OCStackResult SetDOS(const Data_t *data, OicSecDeviceOnboardingState_t dos,
         }
         case PSK_TYPE:
         {
-            CredentialData_t *credData = ((CredentialData_t *)data)->ctx;
+            CredentialData_t *credData = (CredentialData_t *)(data->ctx);
             pTargetDev = credData->deviceInfo[credData->currIndex];
             break;
         }
@@ -984,7 +993,6 @@ OCStackResult SetDOS(const Data_t *data, OicSecDeviceOnboardingState_t dos,
     // should be updated to use the Partial payload APIs for the SVRs, so they
     // do not include read-only Properties for the Server device current
     // state.
-    bool propertiesToInclude[PSTAT_PROPERTY_COUNT] = {false};
     propertiesToInclude[PSTAT_DOS] = true;
 
     if (OC_STACK_OK != PstatToCBORPayloadPartial(pstat, &(secPayload->securityData),
@@ -998,7 +1006,6 @@ OCStackResult SetDOS(const Data_t *data, OicSecDeviceOnboardingState_t dos,
     OIC_LOG(DEBUG, TAG, "Created payload for pstat set");
     OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
 
-    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
     if (!PMGenerateQuery(true,
                          pTargetDev->endpoint.addr,
                          pTargetDev->securePort,
@@ -1012,11 +1019,6 @@ OCStackResult SetDOS(const Data_t *data, OicSecDeviceOnboardingState_t dos,
     }
     OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
 
-    OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
-    OCMethod method = OC_REST_POST;
-    OCDoHandle handle = NULL;
-    OCProvisionDev_t *targetDev = NULL;
-
     targetDev = PMCloneOCProvisionDev(pTargetDev);
 
     if (NULL == targetDev)
@@ -1053,7 +1055,7 @@ OCStackApplicationResult ProvisionCB(void *ctx, OCDoHandle handle,
     {
         OIC_LOG_V(ERROR, TAG, "Responce result: %d", clientResponse->result);
     }
-    if (OC_STACK_OK != SetDOS(ctx, DOS_RFNOP, SetReadyForNormalOperationCB))
+    if (OC_STACK_OK != SetDOS((const Data_t*)ctx, DOS_RFNOP, SetReadyForNormalOperationCB))
     {
         OIC_LOG_V(ERROR, TAG, "OUT %s", __func__);
         return OC_STACK_DELETE_TRANSACTION;
@@ -1082,30 +1084,30 @@ static OCStackApplicationResult  ProvisionPskCB(void *ctx, OCDoHandle UNUSED,
             OCStackResult res = ProvisionCredentialsDos(ctx, cred, device, ProvisionCB);
             if (OC_STACK_OK != res)
             {
-                registerResultForCredProvisioning(credData, res, 2);
+                registerResultForCredProvisioning(credData, res, DEVICE_LOCAL_FINISHED);
                 ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
                                                         credData->resArr, true);
-                FreeData(ctx);
+                FreeData((Data_t*)ctx);
                 return OC_STACK_DELETE_TRANSACTION;
             }
         }
         else
         {
-            registerResultForCredProvisioning(credData, OC_STACK_ERROR, credData->currIndex);
+            registerResultForCredProvisioning(credData, OC_STACK_ERROR, (CredProvisioningResultCause_t)credData->currIndex);
             ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
                                                     credData->resArr,
                                                     true);
-            FreeData(ctx);
+            FreeData((Data_t*)ctx);
         }
     }
     else
     {
         OIC_LOG(INFO, TAG, "provisionCredentialCB received Null clientResponse for first device");
-        registerResultForCredProvisioning(credData, OC_STACK_ERROR, credData->currIndex);
+        registerResultForCredProvisioning(credData, OC_STACK_ERROR, (CredProvisioningResultCause_t)credData->currIndex);
         ((OCProvisionResultCB)(resultCallback))(credData->ctx, credData->numOfResults,
                                                 credData->resArr,
                                                 true);
-        FreeData(ctx);
+        FreeData((Data_t*)ctx);
         credData = NULL;
     }
     return OC_STACK_DELETE_TRANSACTION;
@@ -1174,7 +1176,7 @@ static OCStackApplicationResult ProvisionTrustChainCB(void *ctx, OCDoHandle UNUS
     if (NULL == ctx)
     {
         OIC_LOG(ERROR, TAG, "Context is NULL");
-        return OC_STACK_INVALID_PARAM;
+        return OC_STACK_DELETE_TRANSACTION;
     }
     if (OC_STACK_RESOURCE_CHANGED == clientResponse->result)
     {
@@ -1182,14 +1184,14 @@ static OCStackApplicationResult ProvisionTrustChainCB(void *ctx, OCDoHandle UNUS
         if (CHAIN_TYPE != data->type)
         {
             OIC_LOG(ERROR, TAG, "Invalid type");
-            return OC_STACK_INVALID_PARAM;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         TrustChainData_t *chainData = (TrustChainData_t *) (data->ctx);
         OicSecCred_t *trustCertChainCred = GetCredEntryByCredId(chainData->credId);
         if (NULL == trustCertChainCred)
         {
             OIC_LOG(ERROR, TAG, "Can not find matched Trust Cert. Chain.");
-            return OC_STACK_NO_RESOURCE;
+            return OC_STACK_DELETE_TRANSACTION;
         }
 
         OCSecurityPayload *secPayload = (OCSecurityPayload *)OICCalloc(1, sizeof(OCSecurityPayload));
@@ -1197,7 +1199,7 @@ static OCStackApplicationResult ProvisionTrustChainCB(void *ctx, OCDoHandle UNUS
         {
             DeleteCredList(trustCertChainCred);
             OIC_LOG(ERROR, TAG, "Failed to allocate memory");
-            return OC_STACK_NO_MEMORY;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         secPayload->base.type = PAYLOAD_TYPE_SECURITY;
         int secureFlag = 1; /* Don't send the private key to the device, if it happens to be present */
@@ -1210,7 +1212,7 @@ static OCStackApplicationResult ProvisionTrustChainCB(void *ctx, OCDoHandle UNUS
             DeleteCredList(trustCertChainCred);
             OCPayloadDestroy((OCPayload *)secPayload);
             OIC_LOG(ERROR, TAG, "Failed to CredToCBORPayloadPartial");
-            return OC_STACK_NO_MEMORY;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         DeleteCredList(trustCertChainCred);
         OIC_LOG(DEBUG, TAG, "Created payload for Cred:");
@@ -1225,7 +1227,7 @@ static OCStackApplicationResult ProvisionTrustChainCB(void *ctx, OCDoHandle UNUS
         {
             OIC_LOG(ERROR, TAG, "Failed to generate query");
             OCPayloadDestroy((OCPayload *)secPayload);
-            return OC_STACK_ERROR;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
 
@@ -1242,17 +1244,17 @@ static OCStackApplicationResult ProvisionTrustChainCB(void *ctx, OCDoHandle UNUS
         if (ret != OC_STACK_OK)
         {
             OIC_LOG_V(INFO, TAG, "OUT %s", __func__);
-            return ret;
+            return OC_STACK_DELETE_TRANSACTION;
         }
     }
     else
     {
         OIC_LOG_V(ERROR, TAG, "OUT %s", __func__);
-        return OC_STACK_ERROR;
+        return OC_STACK_DELETE_TRANSACTION;
     }
 
     OIC_LOG_V(INFO, TAG, "OUT %s", __func__);
-    return OC_STACK_OK;
+    return OC_STACK_DELETE_TRANSACTION;
 }
 
 /**
@@ -1266,7 +1268,7 @@ static OCStackApplicationResult ProvisionSecurityProfileInfoCB(void *ctx, OCDoHa
     if (NULL == ctx)
     {
         OIC_LOG(ERROR, TAG, "Context is NULL");
-        return OC_STACK_INVALID_PARAM;
+        return OC_STACK_DELETE_TRANSACTION;
     }
     if (OC_STACK_RESOURCE_CHANGED == clientResponse->result)
     {
@@ -1274,7 +1276,7 @@ static OCStackApplicationResult ProvisionSecurityProfileInfoCB(void *ctx, OCDoHa
         if (SP_TYPE != data->type)
         {
             OIC_LOG(ERROR, TAG, "Invalid type");
-            return OC_STACK_INVALID_PARAM;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         SpData_t *spData = (SpData_t *) (data->ctx);
 
@@ -1282,7 +1284,7 @@ static OCStackApplicationResult ProvisionSecurityProfileInfoCB(void *ctx, OCDoHa
         if (!secPayload)
         {
             OIC_LOG(ERROR, TAG, "Failed to allocate memory");
-            return OC_STACK_NO_MEMORY;
+            return OC_STACK_DELETE_TRANSACTION;
         }
 
         secPayload->base.type = PAYLOAD_TYPE_SECURITY;
@@ -1291,7 +1293,7 @@ static OCStackApplicationResult ProvisionSecurityProfileInfoCB(void *ctx, OCDoHa
         {
             OCPayloadDestroy((OCPayload *)secPayload);
             OIC_LOG(ERROR, TAG, "Failed to SpToCBORPayload");
-            return OC_STACK_NO_MEMORY;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         OIC_LOG(DEBUG, TAG, "Created payload for SP:");
         OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
@@ -1305,7 +1307,7 @@ static OCStackApplicationResult ProvisionSecurityProfileInfoCB(void *ctx, OCDoHa
         {
             OIC_LOG(ERROR, TAG, "Failed to generate query");
             OCPayloadDestroy((OCPayload *)secPayload);
-            return OC_STACK_ERROR;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
 
@@ -1322,17 +1324,17 @@ static OCStackApplicationResult ProvisionSecurityProfileInfoCB(void *ctx, OCDoHa
         if (ret != OC_STACK_OK)
         {
             OIC_LOG_V(INFO, TAG, "OUT %s", __func__);
-            return ret;
+            return OC_STACK_DELETE_TRANSACTION;
         }
     }
     else
     {
         OIC_LOG_V(ERROR, TAG, "OUT %s", __func__);
-        return OC_STACK_ERROR;
+        return OC_STACK_DELETE_TRANSACTION;
     }
 
     OIC_LOG_V(INFO, TAG, "OUT %s", __func__);
-    return OC_STACK_OK;
+    return OC_STACK_DELETE_TRANSACTION;
 }
 
 OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16_t credId,
@@ -1605,15 +1607,18 @@ static OCStackApplicationResult ProvisionCertificateCB(void *ctx, OCDoHandle han
     const OCProvisionDev_t *pDev = NULL;
     OicSecCred_t *cred = NULL;
     OCSecurityPayload *secPayload = NULL;
+    OCCallbackData cbData =  {.context = ctx, .cb = ProvisionCB, .cd = NULL};
+    OCDoHandle lHandle = NULL;
+    int secureFlag = 0;//don't send private data(key)
 
-    VERIFY_NOT_NULL_RETURN(TAG, ctx, ERROR,  OC_STACK_INVALID_PARAM);
-    VERIFY_NOT_NULL_RETURN(TAG, clientResponse, ERROR,  OC_STACK_INVALID_PARAM);
+    VERIFY_NOT_NULL_RETURN(TAG, ctx, ERROR,  OC_STACK_DELETE_TRANSACTION);
+    VERIFY_NOT_NULL_RETURN(TAG, clientResponse, ERROR,  OC_STACK_DELETE_TRANSACTION);
 
     VERIFY_SUCCESS_RETURN(TAG, (OC_STACK_RESOURCE_CHANGED == clientResponse->result), ERROR,
-        OC_STACK_INVALID_PARAM);
+        OC_STACK_DELETE_TRANSACTION);
 
     Data_t *data = (Data_t *) ctx;
-    VERIFY_SUCCESS_RETURN(TAG, (CERT_TYPE == data->type), ERROR, OC_STACK_INVALID_PARAM);
+    VERIFY_SUCCESS_RETURN(TAG, (CERT_TYPE == data->type), ERROR, OC_STACK_DELETE_TRANSACTION);
 
     CertData_t *certData = (CertData_t *) (data->ctx);
     VERIFY_NOT_NULL(TAG, certData, ERROR);
@@ -1626,7 +1631,6 @@ static OCStackApplicationResult ProvisionCertificateCB(void *ctx, OCDoHandle han
     VERIFY_NOT_NULL(TAG, secPayload, ERROR);
     secPayload->base.type = PAYLOAD_TYPE_SECURITY;
 
-    int secureFlag = 0;//don't send private data(key)
     bool propertiesToInclude[CRED_PROPERTY_COUNT];
     memset(propertiesToInclude, 0, sizeof(propertiesToInclude));
     propertiesToInclude[CRED_CREDS] = true;
@@ -1634,7 +1638,7 @@ static OCStackApplicationResult ProvisionCertificateCB(void *ctx, OCDoHandle han
                                              &secPayload->payloadSize, secureFlag, propertiesToInclude), ERROR);
     OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
 
-    query = OICCalloc(1, DEFAULT_URI_LENGTH);
+    query = (char*)OICCalloc(1, DEFAULT_URI_LENGTH);
     VERIFY_NOT_NULL(TAG, query, ERROR);
     VERIFY_SUCCESS(TAG, PMGenerateQuery(true,
                              pDev->endpoint.addr,
@@ -1642,9 +1646,6 @@ static OCStackApplicationResult ProvisionCertificateCB(void *ctx, OCDoHandle han
                              pDev->connType,
                              query, DEFAULT_URI_LENGTH, OIC_RSRC_CRED_URI), ERROR);
 
-    OCCallbackData cbData =  {.context = ctx, .cb = ProvisionCB, .cd = NULL};
-    OCDoHandle lHandle = NULL;
-
     ret = OCDoResource(&lHandle, OC_REST_POST, query,
                                 &pDev->endpoint, (OCPayload *)secPayload,
                                 pDev->connType, OC_HIGH_QOS, &cbData, NULL, 0);
@@ -1665,7 +1666,7 @@ exit:
 
     OIC_LOG_V(INFO, TAG, "OUT %s", __func__);
 
-    return ret;
+    return OC_STACK_DELETE_TRANSACTION;
 }
 
 OCStackResult SRPProvisionCertificate(void *ctx,
@@ -1681,6 +1682,8 @@ OCStackResult SRPProvisionCertificate(void *ctx,
 
     OCStackResult ret = OC_STACK_ERROR;
     Data_t *data = NULL;
+    OicSecCred_t *cred = NULL;
+    OicSecKey_t deviceCert = { 0 };
 
     OicUuid_t provTooldeviceID =   {{0,}};
     if (OC_STACK_OK != GetDoxmDeviceID(&provTooldeviceID))
@@ -1690,7 +1693,7 @@ OCStackResult SRPProvisionCertificate(void *ctx,
     }
 
     data = (Data_t *)OICCalloc(1, sizeof(Data_t));
-    VERIFY_NOT_NULL(TAG, data, ERROR);
+    VERIFY_NOT_NULL_RETURN(TAG, data, ERROR, OC_STACK_NO_MEMORY);
     data->type = CERT_TYPE;
 
     CertData_t *certData = (CertData_t *)OICCalloc(1, sizeof(CertData_t));
@@ -1705,12 +1708,11 @@ OCStackResult SRPProvisionCertificate(void *ctx,
     certData->resArr = (OCProvisionResult_t *)OICCalloc(1, sizeof(OCProvisionResult_t));
     VERIFY_NOT_NULL(TAG, certData->resArr, ERROR);
 
-    OicSecKey_t deviceCert = { 0 };
     deviceCert.data = (uint8_t*) pemCert;
     deviceCert.len = strlen(pemCert) + 1;
     deviceCert.encoding = OIC_ENCODING_PEM;
 
-    OicSecCred_t *cred = GenerateCredential(&pDev->doxm->deviceID, SIGNED_ASYMMETRIC_KEY,
+    cred = GenerateCredential(&pDev->doxm->deviceID, SIGNED_ASYMMETRIC_KEY,
         &deviceCert, NULL, NULL);
     VERIFY_NOT_NULL(TAG, cred, ERROR);
     certData->credInfo = cred;
@@ -2796,6 +2798,10 @@ static OCStackApplicationResult SRPResetDeviceCB(void *ctx, OCDoHandle UNUSED,
     // Delete Cred and ACL related to the target device.
     const OicSecCred_t *cred = NULL;
     OCProvisionDev_t * pTargetDev = (OCProvisionDev_t *)ctx;
+    CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER};
+    CAResult_t caResult = CA_STATUS_FAILED;
+    OCStackResult res = OC_STACK_OK;
+
     cred = GetCredResourceData(&pTargetDev->doxm->deviceID);
     if (cred == NULL)
     {
@@ -2803,7 +2809,7 @@ static OCStackApplicationResult SRPResetDeviceCB(void *ctx, OCDoHandle UNUSED,
         goto error;
     }
 
-    OCStackResult res = RemoveCredential(&cred->subject);
+    res = RemoveCredential(&cred->subject);
     if (res != OC_STACK_RESOURCE_DELETED && res != OC_STACK_NO_RESOURCE)
     {
         OIC_LOG(ERROR, TAG, "OCResetDevice : Failed to remove credential.");
@@ -2822,9 +2828,8 @@ static OCStackApplicationResult SRPResetDeviceCB(void *ctx, OCDoHandle UNUSED,
     }
 
     //Close the DTLS session of the reset device.
-    CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER};
     CopyDevAddrToEndpoint(&clientResponse->devAddr, &endpoint);
-    CAResult_t caResult = CAcloseSslSession(&endpoint);
+    caResult = CAcloseSslSession(&endpoint);
     if(CA_STATUS_OK != caResult)
     {
         OIC_LOG_V(WARNING, TAG, "OCResetDevice : Failed to close DTLS session : %d", caResult);
@@ -2930,6 +2935,9 @@ OCStackResult SRPRemoveDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDi
     OCProvisionDev_t* pOwnedDevList = NULL;
     OCProvisionDev_t* pLinkedDevList = NULL;
     RemoveData_t* removeData = NULL;
+    OCProvisionDev_t *curDev = NULL, *tmpDev = NULL;
+    OCStackResult totalRes = OC_STACK_ERROR;  /* variable for checking request is sent or not */
+    size_t numOfLinkedDev = 0;
 
     //1. Find all devices that has a credential of the revoked device
     OCUuidList_t* pLinkedUuidList = NULL;
@@ -2959,7 +2967,6 @@ OCStackResult SRPRemoveDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDi
 
     //3. Make a list of devices to send DELETE credential request
     //   by comparing owned devices from provisioning database with mutlicast discovery result.
-    size_t numOfLinkedDev = 0;
     res = GetListofDevToReqDeleteCred(pTargetDev, pOwnedDevList, pLinkedUuidList,
                                       &pLinkedDevList, &numOfLinkedDev);
     if (OC_STACK_OK != res)
@@ -3008,8 +3015,6 @@ OCStackResult SRPRemoveDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDi
     removeData->hasError = false;
 
     // 5. Send DELETE credential request to linked devices.
-    OCProvisionDev_t *curDev = NULL, *tmpDev = NULL;
-    OCStackResult totalRes = OC_STACK_ERROR;  /* variable for checking request is sent or not */
     LL_FOREACH_SAFE(pLinkedDevList, curDev, tmpDev)
     {
         res = SendDeleteCredentialRequest((void*)removeData, &SRPRemoveDeviceCB,
@@ -3082,6 +3087,8 @@ OCStackResult SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t*
     // Declare variables in here to handle error cases with goto statement.
     OCProvisionDev_t* pLinkedDevList = NULL;
     RemoveData_t* removeData = NULL;
+    OCProvisionDev_t *curDev = NULL, *tmpDev = NULL;
+    OCStackResult totalRes = OC_STACK_ERROR;  /* variable for checking request is sent or not */
 
     //1. Find all devices that has a credential of the revoked device
     OCUuidList_t* pLinkedUuidList = NULL;
@@ -3150,8 +3157,6 @@ OCStackResult SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t*
     removeData->hasError = false;
 
     // 5. Send DELETE credential request to linked devices.
-    OCProvisionDev_t *curDev = NULL, *tmpDev = NULL;
-    OCStackResult totalRes = OC_STACK_ERROR;  /* variable for checking request is sent or not */
     LL_FOREACH_SAFE(pLinkedDevList, curDev, tmpDev)
     {
         res = SendDeleteCredentialRequest((void*)removeData, &SRPRemoveDeviceCB,
@@ -3218,6 +3223,9 @@ OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDisc
     OCProvisionDev_t* pOwnedDevList = NULL;
     OCProvisionDev_t* pLinkedDevList = NULL;
     RemoveData_t* removeData = NULL;
+    OCProvisionDev_t *curDev = NULL, *tmpDev = NULL;
+    OCStackResult totalRes = OC_STACK_ERROR;  /* variable for checking request is sent or not */
+    size_t numOfLinkedDev = 0;
 
     //1. Find all devices that has a credential of the revoked device
     OCUuidList_t* pLinkedUuidList = NULL;
@@ -3247,7 +3255,6 @@ OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDisc
 
     //3. Make a list of devices to send DELETE credential request
     //   by comparing owned devices from provisioning database with mutlicast discovery result.
-    size_t numOfLinkedDev = 0;
     res = GetListofDevToReqDeleteCred(pTargetDev, pOwnedDevList, pLinkedUuidList,
                                       &pLinkedDevList, &numOfLinkedDev);
     if (OC_STACK_OK != res)
@@ -3296,8 +3303,6 @@ OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDisc
     removeData->hasError = false;
 
     // 5. Send DELETE credential request to linked devices.
-    OCProvisionDev_t *curDev = NULL, *tmpDev = NULL;
-    OCStackResult totalRes = OC_STACK_ERROR;  /* variable for checking request is sent or not */
     LL_FOREACH_SAFE(pLinkedDevList, curDev, tmpDev)
     {
         res = SendDeleteACLRequest((void*)removeData, &SRPSyncDeviceACLCB,
@@ -3377,6 +3382,12 @@ OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
         return OC_STACK_NO_MEMORY;
     }
 
+    OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
+    OCMethod method = OC_REST_POST;
+    OCDoHandle handle = NULL;
+    OCProvisionDev_t *targetDev = NULL;
+    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
+
     pstat->dos.state = DOS_RESET; // TODO IOT-2052 in OCF 1.0 this is the only
                                   // value that needs to be set to cause RESET
     pstat->cm = RESET;
@@ -3421,7 +3432,6 @@ OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
     OIC_LOG(DEBUG, TAG, "Created payload for pstat set");
     OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
 
-    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
     if (!PMGenerateQuery(true,
                 pTargetDev->endpoint.addr,
                 pTargetDev->securePort,
@@ -3435,10 +3445,7 @@ OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
     }
     OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
 
-    OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
-    OCMethod method = OC_REST_POST;
-    OCDoHandle handle = NULL;
-    OCProvisionDev_t * targetDev = PMCloneOCProvisionDev(pTargetDev);
+    targetDev = PMCloneOCProvisionDev(pTargetDev);
     if (NULL == targetDev)
     {
         OIC_LOG(ERROR, TAG, "target dev is null");
@@ -4333,7 +4340,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
     if (NULL == ctx || NULL == clientResponse)
     {
         OIC_LOG_V(ERROR, TAG, " ctx: %p, clientResponse: %p", ctx, clientResponse);
-        return OC_STACK_INVALID_PARAM;
+        return OC_STACK_DELETE_TRANSACTION;
     }
     (void) UNUSED;
     if (OC_STACK_RESOURCE_CHANGED == clientResponse->result)
@@ -4342,7 +4349,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
         if (ACL_TYPE != data->type)
         {
             OIC_LOG(ERROR, TAG, "Invalid type");
-            return OC_STACK_INVALID_PARAM;
+            return OC_STACK_DELETE_TRANSACTION;
         }
 
         ACLData_t *aclData = (ACLData_t *) (data->ctx);
@@ -4360,7 +4367,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
                 uri = OIC_RSRC_ACL2_URI;
                 break;
             default:
-                return OC_STACK_INVALID_PARAM;
+                return OC_STACK_DELETE_TRANSACTION;
         }
 
         // if rowneruuid is empty, set it to device ID
@@ -4378,7 +4385,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
             {
                 OIC_LOG(ERROR, TAG, "Failed to set Rowner to PT's deviceID\
                     becuase it failed to retrieve Doxm DeviceID");
-                return OC_STACK_ERROR;
+                return OC_STACK_DELETE_TRANSACTION;
             }
         }
 
@@ -4387,7 +4394,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
         {
             OIC_LOG(ERROR, TAG, "Failed to allocate memory");
             OIC_LOG_V(ERROR, TAG, "OUT %s", __func__);
-            return OC_STACK_NO_MEMORY;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         secPayload->base.type = PAYLOAD_TYPE_SECURITY;
         bool propertiesToInclude[ACL_PROPERTY_COUNT];
@@ -4399,7 +4406,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
             OCPayloadDestroy((OCPayload *)secPayload);
             OIC_LOG(ERROR, TAG, "Failed to AclToCBORPayloadPartial");
             OIC_LOG_V(ERROR, TAG, "OUT %s", __func__);
-            return OC_STACK_NO_MEMORY;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         OIC_LOG(DEBUG, TAG, "Created payload for ACL:");
         OIC_LOG_BUFFER(DEBUG, TAG, secPayload->securityData, secPayload->payloadSize);
@@ -4412,7 +4419,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
                              query, sizeof(query), uri))
         {
             OIC_LOG(ERROR, TAG, "DeviceDiscoveryHandler : Failed to generate query");
-            return OC_STACK_ERROR;
+            return OC_STACK_DELETE_TRANSACTION;
         }
         OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
 
@@ -4429,15 +4436,15 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
         if (ret != OC_STACK_OK)
         {
             OIC_LOG_V(ERROR, TAG, "OUT %s", __func__);
-            return OC_STACK_ERROR;
+            return OC_STACK_DELETE_TRANSACTION;
         }
     }
     else
     {
         OIC_LOG_V(ERROR, TAG, "OUT %s", __func__);
-        return OC_STACK_ERROR;
+        return OC_STACK_DELETE_TRANSACTION;
     }
     OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__);
-    return OC_STACK_OK;
+    return OC_STACK_DELETE_TRANSACTION;
 }