Commit dacfbe41 authored by leechul's avatar leechul Committed by Randeep

[IOT-1045] Remove the CborEncoder initialization in security modules to remove compile error.

Related JIRA ticket : https://jira.iotivity.org/browse/IOT-1045

I've modified on the basis of the following :
  1) Does not initialize CborEncoder in all other modules except security modules.
  2) Current initialization can make compile error in some other environment.
     Actually, I can't reproduce this errors in my environment.

[Patch 1] : Intial upload.
[Patch 2] : Update commit message.

Change-Id: I98ff0b7db802605a54f357064fad13e7b3888a4c
Signed-off-by: default avatarleechul <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7371Reviewed-by: default avatarKyungsun Cho <goodsun.cho@samsung.com>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
Tested-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
parent f615e038
......@@ -141,10 +141,10 @@ OCStackResult AclToCBORPayload(const OicSecAcl_t *secAcl, uint8_t **payload, siz
OCStackResult ret = OC_STACK_ERROR;
CborError cborEncoderResult = CborNoError;
OicSecAcl_t *acl = (OicSecAcl_t *)secAcl;
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder aclMap = { {.ptr = NULL }, .end = 0 };
CborEncoder aclListMap = { {.ptr = NULL }, .end = 0 };
CborEncoder acesArray = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
CborEncoder aclMap;
CborEncoder aclListMap;
CborEncoder acesArray;
uint8_t *outPayload = NULL;
size_t cborLen = *size;
*size = 0;
......@@ -181,7 +181,7 @@ OCStackResult AclToCBORPayload(const OicSecAcl_t *secAcl, uint8_t **payload, siz
while (acl)
{
CborEncoder oicSecAclMap = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder oicSecAclMap;
// ACL Map size - Number of mandatory items
uint8_t aclMapSize = ACL_ACES_MAP_SIZE;
size_t inLen = 0;
......@@ -223,7 +223,7 @@ OCStackResult AclToCBORPayload(const OicSecAcl_t *secAcl, uint8_t **payload, siz
// Resources
{
CborEncoder resources = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder resources;
cborEncoderResult = cbor_encode_text_string(&oicSecAclMap, OIC_JSON_RESOURCES_NAME,
strlen(OIC_JSON_RESOURCES_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Resource Name Tag.");
......@@ -234,7 +234,7 @@ OCStackResult AclToCBORPayload(const OicSecAcl_t *secAcl, uint8_t **payload, siz
for (size_t i = 0; i < acl->resourcesLen; i++)
{
CborEncoder rMap = { {.ptr = NULL }, .end = 0 };
CborEncoder rMap;
cborEncoderResult = cbor_encoder_create_map(&resources, &rMap, ACL_RESOURCE_MAP_SIZE);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding Resource Map.");
......
......@@ -100,12 +100,12 @@ OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amaclS, uint8_t **cborPayl
*cborSize = 0;
*cborPayload = NULL;
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder amaclMap = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
CborEncoder amaclMap;
int64_t cborEncoderResult = CborNoError;
CborEncoder rsrcMap = { {.ptr = NULL }, .end = 0 };
CborEncoder rlistArray = { {.ptr = NULL }, .end = 0 };
CborEncoder amss = { {.ptr = NULL }, .end = 0 };
CborEncoder rsrcMap;
CborEncoder rlistArray;
CborEncoder amss;
char *stRowner = NULL;
const OicSecAmacl_t *amacl = amaclS;
......@@ -138,7 +138,7 @@ OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amaclS, uint8_t **cborPayl
for (size_t i = 0; i < amacl->resourcesLen; i++)
{
// TODO : Need to create rMap structure based on RAML spec.
CborEncoder rMap = { {.ptr = NULL }, .end = 0 };
CborEncoder rMap;
cborEncoderResult = cbor_encoder_create_map(&rlistArray, &rMap, AMACL_RLIST_MAP_SIZE);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RLIST Map.");
......
......@@ -139,9 +139,9 @@ OCStackResult CredToCBORPayload(const OicSecCred_t *credS, uint8_t **cborPayload
*cborSize = 0;
*cborPayload = NULL;
const OicSecCred_t *cred = credS;
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder credArray = { {.ptr = NULL }, .end = 0 };
CborEncoder credRootMap = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
CborEncoder credArray;
CborEncoder credRootMap;
if (0 == cborLen)
{
......@@ -167,7 +167,7 @@ OCStackResult CredToCBORPayload(const OicSecCred_t *credS, uint8_t **cborPayload
while (cred)
{
CborEncoder credMap = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder credMap;
size_t mapSize = CRED_MAP_SIZE;
char *subject = NULL;
if (cred->period)
......@@ -215,7 +215,7 @@ OCStackResult CredToCBORPayload(const OicSecCred_t *credS, uint8_t **cborPayload
//PublicData -- Not Mandatory
if (SIGNED_ASYMMETRIC_KEY == cred->credType && cred->publicData.data)
{
CborEncoder publicMap = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder publicMap;
const size_t publicMapSize = 2;
cborEncoderResult = cbor_encode_text_string(&credMap, OIC_JSON_PUBLICDATA_NAME,
......@@ -247,7 +247,7 @@ OCStackResult CredToCBORPayload(const OicSecCred_t *credS, uint8_t **cborPayload
//PrivateData -- Not Mandatory
if(cred->privateData.data)
{
CborEncoder privateMap = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder privateMap;
const size_t privateMapSize = 2;
cborEncoderResult = cbor_encode_text_string(&credMap, OIC_JSON_PRIVATEDATA_NAME,
......
......@@ -92,8 +92,8 @@ OCStackResult CrlToCBORPayload(const OicSecCrl_t *crl, uint8_t **payload, size_t
OCStackResult ret = OC_STACK_ERROR;
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder crlMap = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
CborEncoder crlMap;
CborError cborEncoderResult = CborNoError;
......
......@@ -116,8 +116,8 @@ OCStackResult DoxmToCBORPayload(const OicSecDoxm_t *doxm, uint8_t **payload, siz
OCStackResult ret = OC_STACK_ERROR;
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder doxmMap = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
CborEncoder doxmMap;
char* strUuid = NULL;
int64_t cborEncoderResult = CborNoError;
......@@ -141,7 +141,7 @@ OCStackResult DoxmToCBORPayload(const OicSecDoxm_t *doxm, uint8_t **payload, siz
//OxmType -- Not Mandatory
if (doxm->oxmTypeLen > 0)
{
CborEncoder oxmType = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder oxmType;
cborEncoderResult = cbor_encode_text_string(&doxmMap, OIC_JSON_OXM_TYPE_NAME,
strlen(OIC_JSON_OXM_TYPE_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding oxmType Tag.");
......@@ -161,7 +161,7 @@ OCStackResult DoxmToCBORPayload(const OicSecDoxm_t *doxm, uint8_t **payload, siz
//Oxm -- Not Mandatory
if (doxm->oxmLen > 0)
{
CborEncoder oxm = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder oxm;
cborEncoderResult = cbor_encode_text_string(&doxmMap, OIC_JSON_OXMS_NAME,
strlen(OIC_JSON_OXMS_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding oxmName Tag.");
......
......@@ -193,8 +193,8 @@ OCStackResult DpairingToCBORPayload(const OicSecDpairing_t *dpair, uint8_t **pay
OCStackResult ret = OC_STACK_ERROR;
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder dpairMap = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
CborEncoder dpairMap;
int64_t cborEncoderResult = CborNoError;
uint8_t mapSize = DPAIR_MAP_SIZE;
......
......@@ -168,8 +168,8 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
*payload = NULL;
OCStackResult ret = OC_STACK_ERROR;
CborEncoder encoder = { {.ptr = NULL}, .end = 0};
CborEncoder pconfMap = { {.ptr = NULL}, .end = 0};
CborEncoder encoder;
CborEncoder pconfMap;
int64_t cborEncoderResult = CborNoError;
uint8_t mapSize = PCONF_MAP_SIZE;
......@@ -204,7 +204,7 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
//PRM type -- Not Mandatory
if(pconf->prmLen > 0)
{
CborEncoder prm = { {.ptr = NULL }, .end = 0 };
CborEncoder prm;
cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_PRM_NAME,
strlen(OIC_JSON_PRM_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Convert Pconf PRM NAME");
......@@ -231,7 +231,7 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
if (pconf->pdacls)
{
OicSecPdAcl_t *pdacl = pconf->pdacls;
CborEncoder pdAclArray = {{.ptr = NULL }, .end = 0 };
CborEncoder pdAclArray;
cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_PDACL_NAME,
strlen(OIC_JSON_PDACL_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to create OIC_JSON_PDACL_NAME");
......@@ -241,7 +241,7 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
while(pdacl)
{
CborEncoder pdAclMap = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder pdAclMap;
// PDACL Map size - Number of mandatory items
uint8_t aclMapSize = 2;
......@@ -262,14 +262,14 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
strlen(OIC_JSON_RESOURCES_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode resource result");
CborEncoder resources = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder resources;
cborEncoderResult = cbor_encoder_create_array(&pdAclMap, &resources,
pdacl->resourcesLen);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to create resource array");
for (size_t i = 0; i < pdacl->resourcesLen; i++)
{
CborEncoder rMap = { {.ptr = NULL }, .end = 0 };
CborEncoder rMap;
cborEncoderResult = cbor_encoder_create_map(&resources, &rMap,
PCONF_RESOURCE_MAP_SIZE);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding Resource Map.");
......@@ -325,7 +325,7 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
// Period -- Not Mandatory
if (pdacl->periods)
{
CborEncoder period = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder period;
cborEncoderResult = cbor_encode_text_string(&pdAclMap, OIC_JSON_PERIODS_NAME,
strlen(OIC_JSON_PERIODS_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode period value");
......@@ -346,7 +346,7 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
// Period -- Not Mandatory
if(0 != pdacl->prdRecrLen && pdacl->recurrences)
{
CborEncoder recurrences = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder recurrences;
cborEncoderResult = cbor_encode_text_string(&pdAclMap, OIC_JSON_RECURRENCES_NAME,
strlen(OIC_JSON_RECURRENCES_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult,"Failed to encode recurrences");
......@@ -377,7 +377,7 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
//There may not be paired devices if it did not pairing before
if (pconf->pddevs && 0 < pconf->pddevLen)
{
CborEncoder pddev = { {.ptr = NULL }, .end = 0, .added = 0, .flags = 0 };
CborEncoder pddev;
cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_PDDEV_LIST_NAME,
strlen(OIC_JSON_PDDEV_LIST_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode pddev");
......
......@@ -94,8 +94,8 @@ OCStackResult PstatToCBORPayload(const OicSecPstat_t *pstat, uint8_t **payload,
OCStackResult ret = OC_STACK_ERROR;
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder pstatMap = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
CborEncoder pstatMap;
char* strUuid = NULL;
int64_t cborEncoderResult = CborNoError;
......
......@@ -94,8 +94,8 @@ OCStackResult SVCToCBORPayload(const OicSecSvc_t *svc, uint8_t **cborPayload,
int64_t cborEncoderResult = CborNoError;
OCStackResult ret = OC_STACK_ERROR;
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder svcArray = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
CborEncoder svcArray;
uint8_t *outPayload = (uint8_t *)OICCalloc(1, cborLen);
VERIFY_NON_NULL(TAG, outPayload, ERROR);
......@@ -108,8 +108,8 @@ OCStackResult SVCToCBORPayload(const OicSecSvc_t *svc, uint8_t **cborPayload,
while (svc)
{
CborEncoder svcMap = {{.ptr = NULL }, .end = 0 };
CborEncoder owners = {{.ptr = NULL }, .end = 0 };
CborEncoder svcMap;
CborEncoder owners;
cborEncoderResult = cbor_encoder_create_map(&svcArray, &svcMap, SVC_MAP_SIZE);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Create SVC Map.");
......
......@@ -89,8 +89,8 @@ OCStackResult VerToCBORPayload(const OicSecVer_t *ver, uint8_t **payload, size_t
OCStackResult ret = OC_STACK_ERROR;
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder verMap = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
CborEncoder verMap;
int64_t cborEncoderResult = CborNoError;
uint8_t mapSize = VER_MAP_SIZE;
......
......@@ -215,7 +215,7 @@ static void ConvertJsonToCBOR(const char *jsonFileName, const char *cborFileName
DeleteCredList(cred);
}
CborEncoder encoder = { {.ptr = NULL }, .end = 0 };
CborEncoder encoder;
size_t cborSize = aclCborSize + pstatCborSize + doxmCborSize + svcCborSize + credCborSize + amaclCborSize;
printf("Total Cbor Size : %zd\n", cborSize);
......@@ -223,7 +223,7 @@ static void ConvertJsonToCBOR(const char *jsonFileName, const char *cborFileName
uint8_t *outPayload = (uint8_t *)OICCalloc(1, cborSize);
VERIFY_NON_NULL(TAG, outPayload, ERROR);
cbor_encoder_init(&encoder, outPayload, cborSize, 0);
CborEncoder map = { {.ptr = NULL }, .end = 0 };
CborEncoder map;
CborError cborEncoderResult = cbor_encoder_create_map(&encoder, &map, CborIndefiniteLength);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Creating Main Map.");
if (aclCborSize > 0)
......
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