sframe_decoder_add_funcdesc () was added for SFRAME_VERSION_1. This has
since been obsoleted by introduction of SFRAME_VERSION_2 and its
corresponding sframe_decoder_add_funcdesc_v2 API.
sframe_decoder_add_funcdesc () will soon be removed. Refactor the
functionality to keep it in an internal-only API:
sframe_encoder_add_funcdesc_internal (). Ensure it returns the error
code for the caller to take necessary action or pass to user.
This change is preparatory in nature. Refactoring this out now helps
ensure any SFrame V3 related changes are applied to the
sframe_encoder_add_funcdesc_internal () API.
libsframe/
* sframe.c (sframe_encoder_add_funcdesc): Rename to
sframe_encoder_add_funcdesc_internal.
(sframe_encoder_add_funcdesc_v2): Use the new internal API.
---
libsframe/sframe.c | 44 +++++++++++++++++++++++++++++---------------
1 file changed, 29 insertions(+), 15 deletions(-)
@@ -1783,24 +1783,21 @@ bad:
}
/* Add a new SFrame function descriptor entry with START_ADDR, FUNC_SIZE and
- FUNC_INFO to the encoder context ECTX. */
+ FUNC_INFO to the encoder context ECTX. Caller must make sure that ECTX
+ exists. */
-int
-sframe_encoder_add_funcdesc (sframe_encoder_ctx *ectx,
- int32_t start_addr,
- uint32_t func_size,
- unsigned char func_info,
- uint32_t num_fres ATTRIBUTE_UNUSED)
+static int
+sframe_encoder_add_funcdesc_internal (sframe_encoder_ctx *ectx,
+ int32_t start_addr,
+ uint32_t func_size,
+ unsigned char func_info,
+ uint32_t num_fres ATTRIBUTE_UNUSED)
{
sframe_header *ehp;
sf_fde_tbl *fd_info;
size_t fd_tbl_sz;
int err = 0;
- /* FIXME book-keep num_fres for error checking. */
- if (ectx == NULL)
- return sframe_set_errno (&err, SFRAME_ERR_INVAL);
-
fd_info = ectx->sfe_funcdesc;
ehp = sframe_encoder_get_header (ectx);
@@ -1857,7 +1854,24 @@ bad:
free (fd_info);
ectx->sfe_funcdesc = NULL;
ehp->sfh_num_fdes = 0;
- return -1;
+ return err;
+}
+
+/* Add a new SFrame function descriptor entry with START_ADDR, FUNC_SIZE and
+ FUNC_INFO to the encoder context ECTX. */
+
+int
+sframe_encoder_add_funcdesc (sframe_encoder_ctx *ectx,
+ int32_t start_addr,
+ uint32_t func_size,
+ unsigned char func_info,
+ uint32_t num_fres)
+{
+ if (ectx == NULL)
+ return SFRAME_ERR_INVAL;
+
+ return sframe_encoder_add_funcdesc_internal (ectx, start_addr, func_size,
+ func_info, num_fres);
}
/* Add a new SFrame function descriptor entry with START_ADDR, FUNC_SIZE,
@@ -1878,10 +1892,10 @@ sframe_encoder_add_funcdesc_v2 (sframe_encoder_ctx *ectx,
if (ectx == NULL || sframe_encoder_get_version (ectx) == SFRAME_VERSION_1)
return sframe_set_errno (&err, SFRAME_ERR_INVAL);
- err = sframe_encoder_add_funcdesc (ectx, start_addr, func_size, func_info,
- num_fres);
+ err = sframe_encoder_add_funcdesc_internal (ectx, start_addr, func_size,
+ func_info, num_fres);
if (err)
- return SFRAME_ERR;
+ return err;
fd_info = ectx->sfe_funcdesc;
fd_info->entry[fd_info->count-1].func_rep_size = rep_block_size;