From 427567ecdeb450cd8244d1c2ca8ab210a72a7d01 Mon Sep 17 00:00:00 2001 From: Ossama Othman Date: Wed, 24 Jun 2015 11:12:03 -0700 Subject: [PATCH] Corrected error return value when parsing fragmentation header. CAParseHeader() on error returned CA_STATUS_INVALID_PARAM, a CAResult_t value, instead of a value that matches uint32_t return type. Return zero on error instead. Updated documentation accordingly. Change-Id: I3dee0e2b562a272c5d41963e0049618d7bacd69e Signed-off-by: Ossama Othman Reviewed-on: https://gerrit.iotivity.org/gerrit/1419 Tested-by: jenkins-iotivity Reviewed-by: Erich Keane --- resource/csdk/connectivity/inc/cafragmentation.h | 38 ++++++++++++++-------- .../src/adapter_util/cafragmentation.c | 2 +- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/resource/csdk/connectivity/inc/cafragmentation.h b/resource/csdk/connectivity/inc/cafragmentation.h index 6c5d98b..a092d0b 100644 --- a/resource/csdk/connectivity/inc/cafragmentation.h +++ b/resource/csdk/connectivity/inc/cafragmentation.h @@ -137,29 +137,39 @@ extern "C" /** * @fn CAGenerateHeader -* @brief This function is used to generate the CA specific header to maintain the fragmentation -* logic. The header structure explained above will be formed and returned to the caller. +* @brief This function is used to generate the CA specific header to +* maintain the fragmentation logic. The header structure +* explained above will be formed and returned to the caller. * -* @param[in] data Pointer to the character data which needs to be printed. -* @param[in] length The total legth of the data which will be represented from 5th -16th bits -* in the header. +* @param[in,out] header Pointer to the octet array that will contain +* the generated header. +* @param[in] length The total length of the data. The length will +* be embedded in bits 5-16 of the header, +* meaning the maximum overall length of the +* data to be fragmented can be no more than 4096 +* (2^12). * -* @return CA_STATUS_OK on success. One of theCA_STATUS_FAILED or other error values on error. -* @retval CA_STATUS_OK Successful -* @retval CA_STATUS_INVALID_PARAM Invalid input arguments -* @retval CA_STATUS_FAILED Operation failed +* @return @c CA_STATUS_OK on success. One of the @c CA_STATUS_FAILED or +* other error values on error. +* @retval @c CA_STATUS_OK Successful +* @retval @c CA_STATUS_INVALID_PARAM Invalid input arguments +* @retval @c CA_STATUS_FAILED Operation failed */ CAResult_t CAGenerateHeader(char *header, uint32_t length); /** * @fn CAParseHeader -* @brief This function is used to parse the header in the receiver end. This function will -* provide the information of the total length of the data which has been fragmented. +* @brief This function is used to parse the header in the receiver +* end. This function will provide the information of the total +* length of the data which has been fragmented. * -* @param[in] header Pointer to the character data which contains the header information. -* Note that pointer should point to two bytes of data header -* which needs to be parsed. +* @param[in] header Pointer to the octet array data which contains the +* header information. Note that pointer should +* point to two bytes of data header which needs to +* be parsed. * +* @return Overall length of the data to be reassembled, or 0 on +* failure. */ uint32_t CAParseHeader(const char *header); diff --git a/resource/csdk/connectivity/src/adapter_util/cafragmentation.c b/resource/csdk/connectivity/src/adapter_util/cafragmentation.c index fc39b96..eacbbec 100644 --- a/resource/csdk/connectivity/src/adapter_util/cafragmentation.c +++ b/resource/csdk/connectivity/src/adapter_util/cafragmentation.c @@ -58,7 +58,7 @@ uint32_t CAParseHeader(const char *header) { OIC_LOG(DEBUG, CA_FRAGMENTATION_TAG, "IN"); - VERIFY_NON_NULL(header, CA_FRAGMENTATION_TAG, "header is NULL"); + VERIFY_NON_NULL_RET(header, CA_FRAGMENTATION_TAG, "header is NULL", 0); uint32_t dataLen = ((header[0] & 0x0F) << 8) | (header[1] & 0xFF); -- 2.7.4