From 8c919169ba2f8abf0e2e36ee31bed3982124bef7 Mon Sep 17 00:00:00 2001 From: Jongmin Choi Date: Thu, 10 Nov 2016 17:46:05 +0900 Subject: [PATCH] [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: Jongmin Choi Reviewed-on: https://gerrit.iotivity.org/gerrit/14179 Tested-by: jenkins-iotivity Reviewed-by: Jongsung Lee Reviewed-by: Randeep Singh (cherry picked from commit 9a31ef80095f6382985404ba0a6c71437c9d8c43) Reviewed-on: https://gerrit.iotivity.org/gerrit/14203 --- resource/csdk/security/src/aclresource.c | 4 ++-- resource/csdk/security/src/amaclresource.c | 4 ++-- resource/csdk/security/src/credresource.c | 4 ++-- resource/csdk/security/src/crlresource.c | 4 ++-- resource/csdk/security/src/doxmresource.c | 4 ++-- resource/csdk/security/src/dpairingresource.c | 4 ++-- resource/csdk/security/src/pconfresource.c | 4 ++-- resource/csdk/security/src/psinterface.c | 8 ++++---- resource/csdk/security/src/pstatresource.c | 4 ++-- resource/csdk/security/src/svcresource.c | 4 ++-- resource/csdk/security/src/verresource.c | 4 ++-- resource/csdk/security/tool/json2cbor.c | 2 +- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/resource/csdk/security/src/aclresource.c b/resource/csdk/security/src/aclresource.c index a94f750..10ea792 100644 --- a/resource/csdk/security/src/aclresource.c +++ b/resource/csdk/security/src/aclresource.c @@ -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; diff --git a/resource/csdk/security/src/amaclresource.c b/resource/csdk/security/src/amaclresource.c index d7bdb2f..319193c 100644 --- a/resource/csdk/security/src/amaclresource.c +++ b/resource/csdk/security/src/amaclresource.c @@ -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) diff --git a/resource/csdk/security/src/credresource.c b/resource/csdk/security/src/credresource.c index 7363323..84a90c5 100644 --- a/resource/csdk/security/src/credresource.c +++ b/resource/csdk/security/src/credresource.c @@ -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; diff --git a/resource/csdk/security/src/crlresource.c b/resource/csdk/security/src/crlresource.c index f2469ea..9e12aac 100644 --- a/resource/csdk/security/src/crlresource.c +++ b/resource/csdk/security/src/crlresource.c @@ -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); } diff --git a/resource/csdk/security/src/doxmresource.c b/resource/csdk/security/src/doxmresource.c index 9fb2844..819a6b9 100644 --- a/resource/csdk/security/src/doxmresource.c +++ b/resource/csdk/security/src/doxmresource.c @@ -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); diff --git a/resource/csdk/security/src/dpairingresource.c b/resource/csdk/security/src/dpairingresource.c index f46b2ed..94801cb 100644 --- a/resource/csdk/security/src/dpairingresource.c +++ b/resource/csdk/security/src/dpairingresource.c @@ -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; diff --git a/resource/csdk/security/src/pconfresource.c b/resource/csdk/security/src/pconfresource.c index 61f27e6..ab89e3c 100644 --- a/resource/csdk/security/src/pconfresource.c +++ b/resource/csdk/security/src/pconfresource.c @@ -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; diff --git a/resource/csdk/security/src/psinterface.c b/resource/csdk/security/src/psinterface.c index 4d2ea94..9eed75c 100644 --- a/resource/csdk/security/src/psinterface.c +++ b/resource/csdk/security/src/psinterface.c @@ -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); diff --git a/resource/csdk/security/src/pstatresource.c b/resource/csdk/security/src/pstatresource.c index 8813297..360eb65 100644 --- a/resource/csdk/security/src/pstatresource.c +++ b/resource/csdk/security/src/pstatresource.c @@ -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) diff --git a/resource/csdk/security/src/svcresource.c b/resource/csdk/security/src/svcresource.c index 4151f0c..3472d79 100644 --- a/resource/csdk/security/src/svcresource.c +++ b/resource/csdk/security/src/svcresource.c @@ -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; diff --git a/resource/csdk/security/src/verresource.c b/resource/csdk/security/src/verresource.c index 8241a03..a4478e9 100644 --- a/resource/csdk/security/src/verresource.c +++ b/resource/csdk/security/src/verresource.c @@ -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); diff --git a/resource/csdk/security/tool/json2cbor.c b/resource/csdk/security/tool/json2cbor.c index 34de8d9..09024f8 100644 --- a/resource/csdk/security/tool/json2cbor.c +++ b/resource/csdk/security/tool/json2cbor.c @@ -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"); -- 2.7.4