Skip to content

Commit

Permalink
Fix nasa#430, correct type mismatches
Browse files Browse the repository at this point in the history
Correction for various type mismatches across CF.
Notably, many iterators do not use the CFE_Status_t return
type, it should be a custom enum.
  • Loading branch information
jphickey committed Jan 10, 2024
1 parent a1ca9c5 commit ace7b1a
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 272 deletions.
20 changes: 10 additions & 10 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,15 +1054,15 @@ CFE_Status_t CF_CFDP_InitEngine(void)
* See description in cf_cfdp.h for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_Status_t CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context)
CF_CListTraverse_Status_t CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context)
{
CF_CFDP_CycleTx_args_t *args = (CF_CFDP_CycleTx_args_t *)context;
CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node);
CFE_Status_t ret = 1; /* default option is exit traversal */
CF_CFDP_CycleTx_args_t * args = (CF_CFDP_CycleTx_args_t *)context;
CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node);
CF_CListTraverse_Status_t ret = CF_CLIST_EXIT; /* default option is exit traversal */

if (txn->flags.com.suspended)
{
ret = 0; /* suspended, so move on to next */
ret = CF_CLIST_CONT; /* suspended, so move on to next */
}
else
{
Expand Down Expand Up @@ -1133,11 +1133,11 @@ void CF_CFDP_CycleTx(CF_Channel_t *chan)
* See description in cf_cfdp.h for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_Status_t CF_CFDP_DoTick(CF_CListNode_t *node, void *context)
CF_CListTraverse_Status_t CF_CFDP_DoTick(CF_CListNode_t *node, void *context)
{
CFE_Status_t ret = CF_CLIST_CONT; /* CF_CLIST_CONT means don't tick one, keep looking for cur */
CF_CFDP_Tick_args_t *args = (CF_CFDP_Tick_args_t *)context;
CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node);
CF_CListTraverse_Status_t ret = CF_CLIST_CONT; /* CF_CLIST_CONT means don't tick one, keep looking for cur */
CF_CFDP_Tick_args_t * args = (CF_CFDP_Tick_args_t *)context;
CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node);
if (!args->chan->cur || (args->chan->cur == txn))
{
/* found where we left off, so clear that and move on */
Expand Down Expand Up @@ -1787,7 +1787,7 @@ void CF_CFDP_CancelTransaction(CF_Transaction_t *txn)
* See description in cf_cfdp.h for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_Status_t CF_CFDP_CloseFiles(CF_CListNode_t *node, void *context)
CF_CListTraverse_Status_t CF_CFDP_CloseFiles(CF_CListNode_t *node, void *context)
{
CF_Transaction_t *txn = container_of(node, CF_Transaction_t, cl_node);
if (OS_ObjectIdDefined(txn->fd))
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/cf_cfdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph);
* @returns integer traversal code
* @retval Always CF_LIST_CONT indicate list traversal should not exit early.
*/
CFE_Status_t CF_CFDP_CloseFiles(CF_CListNode_t *node, void *context);
CF_CListTraverse_Status_t CF_CFDP_CloseFiles(CF_CListNode_t *node, void *context);

/************************************************************************/
/** @brief Cycle the current active tx or make a new one active.
Expand Down Expand Up @@ -640,7 +640,7 @@ void CF_CFDP_CycleTx(CF_Channel_t *chan);
* @retval CF_CLIST_EXIT when it's found, which terminates list traversal
* @retval CF_CLIST_CONT when it's isn't found, which causes list traversal to continue
*/
CFE_Status_t CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context);
CF_CListTraverse_Status_t CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context);

/************************************************************************/
/** @brief Call R and then S tick functions for all active transactions.
Expand Down Expand Up @@ -701,6 +701,6 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan);
* @retval CF_CLIST_EXIT when it's found, which terminates list traversal
* @retval CF_CLIST_CONT when it's isn't found, which causes list traversal to continue
*/
CFE_Status_t CF_CFDP_DoTick(CF_CListNode_t *node, void *context);
CF_CListTraverse_Status_t CF_CFDP_DoTick(CF_CListNode_t *node, void *context);

#endif /* !CF_CFDP_H */
4 changes: 2 additions & 2 deletions fsw/src/cf_clist.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void CF_CList_Traverse(CF_CListNode_t *start, CF_CListFn_t fn, void *context)
{
last = 1;
}
if (fn(node, context))
if (!CF_CListTraverse_Status_IS_CONTINUE(fn(node, context)))
{
break;
}
Expand Down Expand Up @@ -246,7 +246,7 @@ void CF_CList_Traverse_R(CF_CListNode_t *end, CF_CListFn_t fn, void *context)
last = 1;
}

if (fn(node, context))
if (!CF_CListTraverse_Status_IS_CONTINUE(fn(node, context)))
{
break;
}
Expand Down
21 changes: 18 additions & 3 deletions fsw/src/cf_clist.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,24 @@
#define CF_CLIST_H

#include <stddef.h>
#include <stdbool.h>

#define CF_CLIST_CONT (0) /**< \brief Constant indicating to continue traversal */
#define CF_CLIST_EXIT (1) /**< \brief Constant indicating to stop traversal */
typedef enum
{
CF_CListTraverse_Status_CONTINUE = 0,
CF_CListTraverse_Status_EXIT = 1
} CF_CListTraverse_Status_t;

#define CF_CLIST_CONT CF_CListTraverse_Status_CONTINUE /**< \brief Constant indicating to continue traversal */
#define CF_CLIST_EXIT CF_CListTraverse_Status_EXIT /**< \brief Constant indicating to stop traversal */

/**
* Checks if the list traversal should continue
*/
static inline bool CF_CListTraverse_Status_IS_CONTINUE(CF_CListTraverse_Status_t stat)
{
return (stat == CF_CListTraverse_Status_CONTINUE);
}

/**
* @brief Node link structure
Expand Down Expand Up @@ -63,7 +78,7 @@ typedef struct CF_CListNode CF_CListNode_t;
* @retval #CF_CLIST_CONT Indicates to continue traversing the list
* @retval #CF_CLIST_EXIT Indicates to stop traversing the list
*/
typedef int (*CF_CListFn_t)(CF_CListNode_t *node, void *context);
typedef CF_CListTraverse_Status_t (*CF_CListFn_t)(CF_CListNode_t *node, void *context);

/************************************************************************/
/** @brief Initialize a clist node.
Expand Down
Loading

0 comments on commit ace7b1a

Please sign in to comment.