Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #430, correct type mismatches #431

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
* 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)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
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 @@
* 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)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
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 @@
* 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 @@
{
last = 1;
}
if (fn(node, context))
if (!CF_CListTraverse_Status_IS_CONTINUE(fn(node, context)))

Check notice

Code scanning / CodeQL

Use of non-constant function pointer Note

This call does not go through a const function pointer.

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning

This Boolean expression is not side-effect free.
{
break;
}
Expand Down Expand Up @@ -246,7 +246,7 @@
last = 1;
}

if (fn(node, context))
if (!CF_CListTraverse_Status_IS_CONTINUE(fn(node, context)))

Check notice

Code scanning / CodeQL

Use of non-constant function pointer Note

This call does not go through a const function pointer.

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning

This Boolean expression is not side-effect free.
{
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 @@
* @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);

Check notice

Code scanning / CodeQL

Hidden pointer indirection Note

The typedef CF_CListFn_t hides pointer indirection.

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