Commit 8c919169 authored by Jongmin Choi's avatar Jongmin Choi Committed by Randeep

[CONPRO-311] Fix due to TinyCBOR v0.4 Release

The anonymous union member of struct CborEncoder is no longer anonymous.
References to the union member are replaced by API added for them

Patch #1: Initial upload

Change-Id: Ie47779bee68cfae4fa578ae39ae087ea23b905df
Signed-off-by: default avatarJongmin Choi <jminl.choi@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14179Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarJongsung Lee <js126.lee@samsung.com>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
(cherry picked from commit 9a31ef80)
Reviewed-on: https://gerrit.iotivity.org/gerrit/14203
parent 3bdc276f
......@@ -641,7 +641,7 @@ OCStackResult AclToCBORPayload(const OicSecAcl_t *secAcl, uint8_t **payload, siz
if (CborNoError == cborEncoderResult)
{
OIC_LOG(DEBUG, TAG, "AclToCBORPayload Successed");
*size = encoder.ptr - outPayload;
*size = cbor_encoder_get_buffer_size(&encoder, outPayload);
*payload = outPayload;
ret = OC_STACK_OK;
}
......@@ -653,7 +653,7 @@ exit:
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
cborEncoderResult = CborNoError;
ret = AclToCBORPayload(secAcl, payload, &cborLen);
*size = cborLen;
......
......@@ -204,7 +204,7 @@ OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amaclS, uint8_t **cborPayl
if (CborNoError == cborEncoderResult)
{
*cborPayload = outPayload;
*cborSize = encoder.ptr - outPayload;
*cborSize = cbor_encoder_get_buffer_size(&encoder, outPayload);
ret = OC_STACK_OK;
}
......@@ -215,7 +215,7 @@ exit:
OICFree(outPayload);
outPayload = NULL;
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
cborEncoderResult = CborNoError;
ret = AmaclToCBORPayload(amaclS, cborPayload, &cborLen);
if (OC_STACK_OK == ret)
......
......@@ -690,7 +690,7 @@ OCStackResult CredToCBORPayload(const OicSecCred_t *credS, uint8_t **cborPayload
{
OIC_LOG(DEBUG, TAG, "CredToCBORPayload Successed");
*cborPayload = outPayload;
*cborSize = encoder.ptr - outPayload;
*cborSize = cbor_encoder_get_buffer_size(&encoder, outPayload);
ret = OC_STACK_OK;
}
OIC_LOG(DEBUG, TAG, "CredToCBORPayload OUT");
......@@ -701,7 +701,7 @@ exit:
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
cborEncoderResult = CborNoError;
ret = CredToCBORPayload(credS, cborPayload, &cborLen, secureFlag);
*cborSize = cborLen;
......
......@@ -357,7 +357,7 @@ OCStackResult CrlToCBORPayload(const OicSecCrl_t *crl, uint8_t **payload, size_t
cborEncoderResult = cbor_encoder_close_container(&encoder, &crlMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add close Crl map");
*size = encoder.ptr - outPayload;
*size = cbor_encoder_get_buffer_size(&encoder, outPayload);
*payload = outPayload;
ret = OC_STACK_OK;
......@@ -367,7 +367,7 @@ exit:
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
cborEncoderResult = CborNoError;
ret = CrlToCBORPayload(crl, payload, &cborLen, lastUpdate);
}
......
......@@ -345,7 +345,7 @@ OCStackResult DoxmToCBORPayload(const OicSecDoxm_t *doxm, uint8_t **payload, siz
if (CborNoError == cborEncoderResult)
{
*size = encoder.ptr - outPayload;
*size = cbor_encoder_get_buffer_size(&encoder, outPayload);
*payload = outPayload;
ret = OC_STACK_OK;
}
......@@ -356,7 +356,7 @@ exit:
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
OIC_LOG_V(DEBUG, TAG, "Doxm reallocation size : %zd.", cborLen);
cborEncoderResult = CborNoError;
ret = DoxmToCBORPayload(doxm, payload, &cborLen, rwOnly);
......
......@@ -243,7 +243,7 @@ OCStackResult DpairingToCBORPayload(const OicSecDpairing_t *dpair, uint8_t **pay
if (CborNoError == cborEncoderResult)
{
*size = encoder.ptr - outPayload;
*size = cbor_encoder_get_buffer_size(&encoder, outPayload);
*payload = outPayload;
ret = OC_STACK_OK;
}
......@@ -254,7 +254,7 @@ exit:
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
cborEncoderResult = CborNoError;
ret = DpairingToCBORPayload(dpair, payload, &cborLen);
*size = cborLen;
......
......@@ -426,7 +426,7 @@ OCStackResult PconfToCBORPayload(const OicSecPconf_t *pconf,uint8_t **payload,si
cborEncoderResult = cbor_encoder_close_container(&encoder, &pconfMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to close pconfMap");
*size = encoder.ptr - outPayload;
*size = cbor_encoder_get_buffer_size(&encoder, outPayload);
*payload = outPayload;
ret = OC_STACK_OK;
exit:
......@@ -435,7 +435,7 @@ exit:
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
cborEncoderResult = CborNoError;
ret = PconfToCBORPayload(pconf, payload, &cborLen);
*size = cborLen;
......
......@@ -360,7 +360,7 @@ OCStackResult UpdateSecureResourceInPS(const char *rsrcName, const uint8_t *psPa
cborEncoderResult |= cbor_encoder_close_container(&encoder, &secRsrc);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Array.");
outSize = encoder.ptr - outPayload;
outSize = cbor_encoder_get_buffer_size(&encoder, outPayload);
}
}
else if (psPayload && psSize)
......@@ -383,7 +383,7 @@ OCStackResult UpdateSecureResourceInPS(const char *rsrcName, const uint8_t *psPa
cborEncoderResult |= cbor_encoder_close_container(&encoder, &secRsrc);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Array.");
outSize = encoder.ptr - outPayload;
outSize = cbor_encoder_get_buffer_size(&encoder, outPayload);
}
if (outPayload && outSize)
......@@ -537,7 +537,7 @@ OCStackResult ResetSecureResourceInPS(void)
cborEncoderResult |= cbor_encoder_close_container(&encoder, &secRsrc);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Array.");
outSize = encoder.ptr - outPayload;
outSize = cbor_encoder_get_buffer_size(&encoder, outPayload);
}
if (outPayload && outSize)
......@@ -698,7 +698,7 @@ OCStackResult CreateResetProfile(void)
cborEncoderResult |= cbor_encoder_close_container(&encoder, &secRsrc);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Array.");
resetPfCborLen = encoder.ptr - resetPfCbor;
resetPfCborLen = cbor_encoder_get_buffer_size(&encoder, resetPfCbor);
}
UpdateSecureResourceInPS(OIC_JSON_RESET_PF_NAME, resetPfCbor, resetPfCborLen);
......
......@@ -215,7 +215,7 @@ OCStackResult PstatToCBORPayload(const OicSecPstat_t *pstat, uint8_t **payload,
if (CborNoError == cborEncoderResult)
{
*size = encoder.ptr - outPayload;
*size = cbor_encoder_get_buffer_size(&encoder, outPayload);
*payload = outPayload;
ret = OC_STACK_OK;
}
......@@ -225,7 +225,7 @@ exit:
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
cborEncoderResult = CborNoError;
ret = PstatToCBORPayload(pstat, payload, &cborLen, writableOnly);
if (OC_STACK_OK == ret)
......
......@@ -158,7 +158,7 @@ OCStackResult SVCToCBORPayload(const OicSecSvc_t *svc, uint8_t **cborPayload,
if (CborNoError == cborEncoderResult)
{
*cborPayload = outPayload;
*cborSize = encoder.ptr - outPayload;
*cborSize = cbor_encoder_get_buffer_size(&encoder, outPayload);
ret = OC_STACK_OK;
}
......@@ -169,7 +169,7 @@ exit:
OICFree(outPayload);
outPayload = NULL;
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
cborEncoderResult = CborNoError;
ret = SVCToCBORPayload(svc, cborPayload, &cborLen);
*cborSize = cborLen;
......
......@@ -130,7 +130,7 @@ OCStackResult VerToCBORPayload(const OicSecVer_t *ver, uint8_t **payload, size_t
if (CborNoError == cborEncoderResult)
{
*size = encoder.ptr - outPayload;
*size = cbor_encoder_get_buffer_size(&encoder, outPayload);
*payload = outPayload;
ret = OC_STACK_OK;
}
......@@ -141,7 +141,7 @@ exit:
// reallocate and try again!
OICFree(outPayload);
// Since the allocated initial memory failed, double the memory.
cborLen += encoder.ptr - encoder.end;
cborLen += cbor_encoder_get_buffer_size(&encoder, encoder.end);
OIC_LOG_V(DEBUG, TAG, "Ver reallocation size : %zd.", cborLen);
cborEncoderResult = CborNoError;
ret = VerToCBORPayload(ver, payload, &cborLen);
......
......@@ -277,7 +277,7 @@ static void ConvertJsonToCBOR(const char *jsonFileName, const char *cborFileName
cborEncoderResult = cbor_encoder_close_container(&encoder, &map);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Container.");
size_t s = encoder.ptr - outPayload;
size_t s = cbor_encoder_get_buffer_size(&encoder, outPayload);
OIC_LOG_V(DEBUG, TAG, "Payload size %zu", s);
fp1 = fopen(cborFileName, "w");
......
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