Skip to content

Commit

Permalink
Partial nasa#42, naming convention pass thru cf_clist.h
Browse files Browse the repository at this point in the history
Update names of all identifiers in cf_clist.h to follow naming
conventions from CFE.
  • Loading branch information
jphickey committed Dec 9, 2021
1 parent f804be9 commit 38403d0
Show file tree
Hide file tree
Showing 16 changed files with 582 additions and 576 deletions.
24 changes: 12 additions & 12 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static CF_Transaction_t *CF_CFDP_FindUnusedTransaction(CF_Channel_t *c)
int q_index; /* initialized below in if */
const int chan_index = (c - CF_AppData.engine.channels);

clist_node n = c->qs[CF_QueueIdx_FREE];
CF_CListNode_t *n = c->qs[CF_QueueIdx_FREE];
CF_Transaction_t *t = container_of(n, CF_Transaction_t, cl_node);

CF_CList_Remove_Ex(c, CF_QueueIdx_FREE, &t->cl_node);
Expand Down Expand Up @@ -298,7 +298,7 @@ static void CF_CFDP_FreeTransaction(CF_Transaction_t *t)
** \endreturns
**
*************************************************************************/
static int CF_CFDP_FindTransactionBySequenceNumber_(clist_node n, trans_seq_arg_t *context)
static int CF_CFDP_FindTransactionBySequenceNumber_(CF_CListNode_t *n, trans_seq_arg_t *context)
{
CF_Transaction_t *t = container_of(n, CF_Transaction_t, cl_node);
int ret = 0;
Expand Down Expand Up @@ -336,14 +336,14 @@ CF_Transaction_t *CF_CFDP_FindTransactionBySequenceNumber(CF_Channel_t *c,
*
* Let's put CF_QueueIdx_RX up front, because most RX packets will be file data PDUs */
trans_seq_arg_t ctx = {transaction_sequence_number, src_eid, NULL};
clist_node ptrs[NUM_CLISTS] = {c->qs[CF_QueueIdx_RX], c->qs[CF_QueueIdx_PEND], c->qs[CF_QueueIdx_TXA],
c->qs[CF_QueueIdx_TXW]};
CF_CListNode_t *ptrs[NUM_CLISTS] = {c->qs[CF_QueueIdx_RX], c->qs[CF_QueueIdx_PEND], c->qs[CF_QueueIdx_TXA],
c->qs[CF_QueueIdx_TXW]};
int i;
CF_Transaction_t *ret = NULL;

for (i = 0; i < NUM_CLISTS; ++i)
{
CF_CList_Traverse(ptrs[i], (clist_fn_t)CF_CFDP_FindTransactionBySequenceNumber_, &ctx);
CF_CList_Traverse(ptrs[i], (CF_CListFn_t)CF_CFDP_FindTransactionBySequenceNumber_, &ctx);
if (ctx.t)
{
ret = ctx.t;
Expand Down Expand Up @@ -1488,7 +1488,7 @@ static void CF_CFDP_ReceiveMessage(CF_Channel_t *c)
** \endreturns
**
*************************************************************************/
static int CF_CFDP_CycleTx_(clist_node node, void *context)
static int CF_CFDP_CycleTx_(CF_CListNode_t *node, void *context)
{
CF_CFDP_CycleTx_args_t *args = (CF_CFDP_CycleTx_args_t *)context;
CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node);
Expand Down Expand Up @@ -1577,9 +1577,9 @@ static void CF_CFDP_CycleTx(CF_Channel_t *c)
** \endreturns
**
*************************************************************************/
static int CF_CFDP_DoTick(clist_node node, void *context)
static int CF_CFDP_DoTick(CF_CListNode_t *node, void *context)
{
int ret = CLIST_CONT; /* CLIST_CONT means don't tick one, keep looking for cur */
int ret = CF_CLIST_CONT; /* CF_CLIST_CONT means don't tick one, keep looking for cur */
tick_args_t *args = (tick_args_t *)context;
CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node);
if (!args->c->cur || (args->c->cur == t))
Expand All @@ -1596,7 +1596,7 @@ static int CF_CFDP_DoTick(clist_node node, void *context)
* so there is no need to check it here */
if (args->c->cur)
{
ret = CLIST_EXIT;
ret = CF_CLIST_EXIT;
args->early_exit = 1;
}
}
Expand Down Expand Up @@ -2234,14 +2234,14 @@ void CF_CFDP_CancelTransaction(CF_Transaction_t *t)
** \retcode Always 0 indicate list traversal should not exit early. \endcode
** \endreturns
*************************************************************************/
static int CF_CFDP_CloseFiles(clist_node n, void *context)
static int CF_CFDP_CloseFiles(CF_CListNode_t *n, void *context)
{
CF_Transaction_t *t = container_of(n, CF_Transaction_t, cl_node);
if (OS_ObjectIdDefined(t->fd))
{
CF_WrappedClose(t->fd);
}
return CLIST_CONT;
return CF_CLIST_CONT;
}

/************************************************************************/
Expand All @@ -2260,7 +2260,7 @@ void CF_CFDP_DisableEngine(void)
{
CF_Channel_t *c = CF_AppData.engine.channels + i;
/* first, close all active files */
clist_node ptrs[] = {c->qs[CF_QueueIdx_RX], c->qs[CF_QueueIdx_TXA], c->qs[CF_QueueIdx_TXW]};
CF_CListNode_t *ptrs[] = {c->qs[CF_QueueIdx_RX], c->qs[CF_QueueIdx_TXA], c->qs[CF_QueueIdx_TXW]};
for (j = 0; j < sizeof(ptrs) / sizeof(*ptrs); ++j)
CF_CList_Traverse(ptrs[j], CF_CFDP_CloseFiles, NULL);

Expand Down
10 changes: 5 additions & 5 deletions fsw/src/cf_cfdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ typedef enum
typedef struct CF_History
{
CF_TxnFilenames_t fnames;
clist_node_t cl_node;
CF_CListNode_t cl_node;
CF_Direction_t dir;
CF_CFDP_ConditionCode_t cc;
CF_EntityId_t src_eid; /* src_eid is always the source eid */
Expand All @@ -109,7 +109,7 @@ typedef struct CF_History
typedef struct CF_ChunkWrapper
{
CF_ChunkList_t chunks;
clist_node_t cl_node;
CF_CListNode_t cl_node;
} CF_ChunkWrapper_t;

typedef struct CF_Playback
Expand Down Expand Up @@ -236,7 +236,7 @@ typedef struct CF_Transaction
uint8 chan_num; /* if ever more than one engine, this may need to change to pointer */
uint8 priority;

clist_node_t cl_node;
CF_CListNode_t cl_node;

CF_Playback_t *p; /* NULL if transaction does not belong to a playback */

Expand Down Expand Up @@ -280,8 +280,8 @@ typedef enum

typedef struct CF_Channel
{
clist_node qs[CF_QueueIdx_NUM];
clist_node cs[CF_Direction_NUM];
CF_CListNode_t *qs[CF_QueueIdx_NUM];
CF_CListNode_t *cs[CF_Direction_NUM];

CFE_SB_PipeId_t pipe;

Expand Down
34 changes: 17 additions & 17 deletions fsw/src/cf_clist.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
** node must not be NULL.
**
*************************************************************************/
void CF_CList_InitNode(clist_node node)
void CF_CList_InitNode(CF_CListNode_t *node)
{
node->next = node;
node->prev = node;
Expand All @@ -53,7 +53,7 @@ void CF_CList_InitNode(clist_node node)
** head must not be NULL. node must not be NULL.
**
*************************************************************************/
void CF_CList_InsertFront(clist_node *head, clist_node node)
void CF_CList_InsertFront(CF_CListNode_t **head, CF_CListNode_t *node)
{
CF_Assert(head);
CF_Assert(node);
Expand All @@ -62,7 +62,7 @@ void CF_CList_InsertFront(clist_node *head, clist_node node)

if (*head)
{
clist_node_t *last = (*head)->prev;
CF_CListNode_t *last = (*head)->prev;

node->next = *head;
node->prev = last;
Expand All @@ -80,7 +80,7 @@ void CF_CList_InsertFront(clist_node *head, clist_node node)
** head must not be NULL. node must not be NULL.
**
*************************************************************************/
void CF_CList_InsertBack(clist_node *head, clist_node node)
void CF_CList_InsertBack(CF_CListNode_t **head, CF_CListNode_t *node)
{
CF_Assert(head);
CF_Assert(node);
Expand All @@ -93,7 +93,7 @@ void CF_CList_InsertBack(clist_node *head, clist_node node)
}
else
{
clist_node_t *last = (*head)->prev;
CF_CListNode_t *last = (*head)->prev;

node->next = *head;
(*head)->prev = node;
Expand All @@ -113,9 +113,9 @@ void CF_CList_InsertBack(clist_node *head, clist_node node)
** \endreturns
**
*************************************************************************/
clist_node CF_CList_Pop(clist_node *head)
CF_CListNode_t *CF_CList_Pop(CF_CListNode_t **head)
{
clist_node ret;
CF_CListNode_t *ret;

CF_Assert(head);

Expand All @@ -135,7 +135,7 @@ clist_node CF_CList_Pop(clist_node *head)
** head must not be NULL. node must not be NULL.
**
*************************************************************************/
void CF_CList_Remove(clist_node *head, clist_node node)
void CF_CList_Remove(CF_CListNode_t **head, CF_CListNode_t *node)
{
CF_Assert(head);
CF_Assert(node);
Expand Down Expand Up @@ -171,7 +171,7 @@ void CF_CList_Remove(clist_node *head, clist_node node)
** head must not be NULL. node must not be NULL.
**
*************************************************************************/
void CF_CList_InsertAfter(clist_node *head, clist_node start, clist_node after)
void CF_CList_InsertAfter(CF_CListNode_t **head, CF_CListNode_t *start, CF_CListNode_t *after)
{
/* calling insert_after with nothing to insert after (no head) makes no sense */
CF_Assert(head);
Expand All @@ -193,11 +193,11 @@ void CF_CList_InsertAfter(clist_node *head, clist_node start, clist_node after)
** start may be NULL. fn must be a valid function. context may be NULL.
**
*************************************************************************/
void CF_CList_Traverse(clist_node start, clist_fn_t fn, void *context)
void CF_CList_Traverse(CF_CListNode_t *start, CF_CListFn_t fn, void *context)
{
clist_node n = start;
clist_node nn;
int last = 0;
CF_CListNode_t *n = start;
CF_CListNode_t *nn;
int last = 0;

if (n)
{
Expand Down Expand Up @@ -235,13 +235,13 @@ err_out:;
** end may be NULL. fn must be a valid function. context may be NULL.
**
*************************************************************************/
void CF_CList_Traverse_R(clist_node end, clist_fn_t fn, void *context)
void CF_CList_Traverse_R(CF_CListNode_t *end, CF_CListFn_t fn, void *context)
{
if (end)
{
clist_node n = end->prev;
clist_node nn;
int last = 0;
CF_CListNode_t *n = end->prev;
CF_CListNode_t *nn;
int last = 0;

if (n)
{
Expand Down
41 changes: 20 additions & 21 deletions fsw/src/cf_clist.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,43 @@
**
*************************************************************************/

#ifndef __CF_CLIST_H_
#define __CF_CLIST_H_
#ifndef CF_CLIST_H
#define CF_CLIST_H

#include <stddef.h>

#define CLIST_CONT 0
#define CLIST_EXIT 1
#define CF_CLIST_CONT 0
#define CF_CLIST_EXIT 1

/* circular linked list */

struct clist_node_t;
typedef struct clist_node_t
struct CF_CListNode
{
struct clist_node_t *next;
struct clist_node_t *prev;
} clist_node_t;
struct CF_CListNode *next;
struct CF_CListNode *prev;
};

typedef struct clist_node_t *clist_node;
typedef struct CF_CListNode CF_CListNode_t;

/* good a place as any to put container_of for CF */
#define container_of(ptr, type, member) ((type *)((char *)(ptr) - (char *)offsetof(type, member)))

void CF_CList_InitNode(clist_node node);
void CF_CList_InitNode(CF_CListNode_t *node);

/* in the functions, head is the list head */
void CF_CList_InsertFront(clist_node *head, clist_node node);
void CF_CList_InsertBack(clist_node *head, clist_node node);
void CF_CList_Remove(clist_node *head, clist_node node);
clist_node CF_CList_Pop(clist_node *head);
void CF_CList_InsertAfter(clist_node *head, clist_node start, clist_node after);
void CF_CList_InsertFront(CF_CListNode_t **head, CF_CListNode_t *node);
void CF_CList_InsertBack(CF_CListNode_t **head, CF_CListNode_t *node);
void CF_CList_Remove(CF_CListNode_t **head, CF_CListNode_t *node);
CF_CListNode_t *CF_CList_Pop(CF_CListNode_t **head);
void CF_CList_InsertAfter(CF_CListNode_t **head, CF_CListNode_t *start, CF_CListNode_t *after);

/* NOTE: if clist_fn_t returns non-zero, the list traversal stops */
typedef int (*clist_fn_t)(clist_node node, void *context);
/* NOTE: if CF_CListFn_t returns non-zero, the list traversal stops */
typedef int (*CF_CListFn_t)(CF_CListNode_t *node, void *context);

/* NOTE on traversal: it's ok to delete the current node, but do not delete
* other nodes in the same list!! */
void CF_CList_Traverse(clist_node start, clist_fn_t fn, void *context);
void CF_CList_Traverse(CF_CListNode_t *start, CF_CListFn_t fn, void *context);
/* NOTE: traverse_R will work backwards from the parameter's prev, and end on param */
void CF_CList_Traverse_R(clist_node end, clist_fn_t fn, void *context);
void CF_CList_Traverse_R(CF_CListNode_t *end, CF_CListFn_t fn, void *context);

#endif /* !__CF_CLIST_H_ */
#endif /* !CF_CLIST_H */
10 changes: 5 additions & 5 deletions fsw/src/cf_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,11 +666,11 @@ static void CF_CmdDisablePolldir(CFE_SB_Buffer_t *msg)
** n must not be NULL. c must not be NULL.
**
*************************************************************************/
static int CF_PurgeHistory(clist_node n, CF_Channel_t *c)
static int CF_PurgeHistory(CF_CListNode_t *n, CF_Channel_t *c)
{
CF_History_t *h = container_of(n, CF_History_t, cl_node);
CF_CFDP_ResetHistory(c, h); /* ok to reset transaction since it's in PEND it hasn't started yet */
return CLIST_CONT;
return CF_CLIST_CONT;
}

/************************************************************************/
Expand All @@ -680,11 +680,11 @@ static int CF_PurgeHistory(clist_node n, CF_Channel_t *c)
** n must not be NULL.
**
*************************************************************************/
static int CF_PurgeTransaction(clist_node n, void *ignored)
static int CF_PurgeTransaction(CF_CListNode_t *n, void *ignored)
{
CF_Transaction_t *t = container_of(n, CF_Transaction_t, cl_node);
CF_CFDP_ResetTransaction(t, 0);
return CLIST_CONT;
return CF_CLIST_CONT;
}

/************************************************************************/
Expand Down Expand Up @@ -740,7 +740,7 @@ static int CF_DoPurgeQueue(uint8 chan_num, cf_cmd_unionargs_t *cmd)

if (hist)
{
CF_CList_Traverse(c->qs[CF_QueueIdx_HIST], (clist_fn_t)CF_PurgeHistory, c);
CF_CList_Traverse(c->qs[CF_QueueIdx_HIST], (CF_CListFn_t)CF_PurgeHistory, c);
}

return ret;
Expand Down
Loading

0 comments on commit 38403d0

Please sign in to comment.