From 0ac6e800383dcbb2c327bb255f03fc6561c2d547 Mon Sep 17 00:00:00 2001 From: Yonggoo Kang Date: Wed, 30 Mar 2016 15:40:11 +0900 Subject: [PATCH] Update pstat's device id in case of default Change-Id: Ia7b7b24bbf39a42a761d9a872a62909b78064cae Signed-off-by: Yonggoo Kang Reviewed-on: https://gerrit.iotivity.org/gerrit/7459 Tested-by: jenkins-iotivity Reviewed-by: Kyungsun Cho Reviewed-by: Chul Lee Reviewed-by: Randeep Singh --- resource/csdk/security/src/pstatresource.c | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/resource/csdk/security/src/pstatresource.c b/resource/csdk/security/src/pstatresource.c index 25f143c77..5af8afddc 100644 --- a/resource/csdk/security/src/pstatresource.c +++ b/resource/csdk/security/src/pstatresource.c @@ -491,6 +491,7 @@ OCStackResult InitPstatResource() // Read Pstat resource from PS uint8_t *data = NULL; size_t size = 0; + OicUuid_t emptyUuid = {.id={0}}; ret = GetSecureVirtualDatabaseFromPS(OIC_JSON_PSTAT_NAME, &data, &size); // If database read failed if (OC_STACK_OK != ret) @@ -499,21 +500,9 @@ OCStackResult InitPstatResource() } if (data) { - OicUuid_t emptyUuid = {.id={0}}; - // Read ACL resource from PS ret = CBORPayloadToPstat(data, size, &gPstat); OICFree(data); - - //In case of PStat's device id is empty, fill the device id as doxm's device id. - if(memcmp(&gPstat->deviceID, &emptyUuid, sizeof(OicUuid_t)) == 0) - { - OicUuid_t doxmUuid = {.id={0}}; - if(OC_STACK_OK == GetDoxmDeviceID(&doxmUuid)) - { - memcpy(&gPstat->deviceID, &doxmUuid, sizeof(OicUuid_t)); - } - } } /* * If SVR database in persistent storage got corrupted or @@ -526,6 +515,16 @@ OCStackResult InitPstatResource() } VERIFY_NON_NULL(TAG, gPstat, FATAL); + //In case of Pstat's device id is empty, fill the device id as doxm's device id. + if(0 == memcmp(&gPstat->deviceID, &emptyUuid, sizeof(OicUuid_t))) + { + OicUuid_t doxmUuid = {.id={0}}; + if(OC_STACK_OK == GetDoxmDeviceID(&doxmUuid)) + { + memcpy(&gPstat->deviceID, &doxmUuid, sizeof(OicUuid_t)); + } + } + // Instantiate 'oic.sec.pstat' ret = CreatePstatResource(); -- 2.34.1