Commit 70747fd2 authored by Jihun Ha's avatar Jihun Ha Committed by Uze Choi

Fix a wrong usage of return value of getMediatorDevId API

Instead of OCUUIdentity *, a value of std::string should be returned.
Additionally, removed a defect point in returning a value after OICFree

Change-Id: Ibcd204b14ea6f488f689ff0ff61da9b618124a4d
Signed-off-by: default avatarJihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17085Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent bc88acf8
......@@ -624,37 +624,34 @@ namespace OIC
return ESResult::ES_OK;
}
OCUUIdentity* EnrolleeSecurity::getMediatorDevID()
std::string EnrolleeSecurity::getMediatorDevID()
{
OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "getMediatorDevID IN");
OCUUIdentity* mediatorDevId = (OCUUIdentity* )OICMalloc(sizeof(OCUUIdentity));
if(!mediatorDevId)
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "provisionOwnership: OICMalloc error return");
return NULL;
return {};
}
if(OC::OCPlatform::getDeviceId(mediatorDevId) != OC_STACK_OK)
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "getDeviceId is failed.");
OICFree(mediatorDevId);
return NULL;
return {};
}
char uuidString[UUID_STRING_SIZE];
if(OCConvertUuidToString(mediatorDevId->id, uuidString))
{
m_mediatorID = uuidString;
OIC_LOG_V(DEBUG, ENROLEE_SECURITY_TAG, "Mediator UUID : %s", uuidString);
OICFree(mediatorDevId);
return std::string(uuidString);
}
else
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "OCConvertUuidToString is failed.");
OICFree(mediatorDevId);
return NULL;
}
return mediatorDevId;
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "OCConvertUuidToString is failed.");
OICFree(mediatorDevId);
return {};
}
ESResult EnrolleeSecurity::provisionOwnership(SecurityProvStatusCbWithOption callback)
......@@ -665,12 +662,16 @@ namespace OIC
ESOwnershipTransferData ownershipTransferData;
OCUUIdentity* mediatorDevId = getMediatorDevID();
if(!mediatorDevId)
std::string mediatorDevIdStr = getMediatorDevID();
if(mediatorDevIdStr.empty())
{
OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "getMediatorDevID is failed.");
return res;
}
else
{
m_mediatorID = mediatorDevIdStr;
}
res = discoverTargetSecureResource();
......
......@@ -100,7 +100,7 @@ namespace OIC
std::string& uuidString);
std::string getResourceDeviceAddress(const std::string& host);
bool isOwnerIDMatched(std::shared_ptr< OC::OCSecureResource > foundDevice);
OCUUIdentity* getMediatorDevID();
std::string getMediatorDevID();
#if defined(__WITH_DTLS__) && defined(__WITH_TLS__)
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment