Corrected error return value when parsing fragmentation header.
authorOssama Othman <ossama.othman@intel.com>
Wed, 24 Jun 2015 18:12:03 +0000 (11:12 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 25 Jun 2015 16:36:25 +0000 (16:36 +0000)
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 <ossama.othman@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1419
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/inc/cafragmentation.h
resource/csdk/connectivity/src/adapter_util/cafragmentation.c

index 6c5d98b..a092d0b 100644 (file)
@@ -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);
 
index fc39b96..eacbbec 100644 (file)
@@ -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);