Skip to content

Commit

Permalink
Partial nasa#42, Naming convention pass thru cf_timer.h and cf_utils.h
Browse files Browse the repository at this point in the history
Updates names of all identifiers in cf_timer.h and cf_utils.h to follow naming
conventions from CFE.
  • Loading branch information
jphickey committed Dec 9, 2021
1 parent 0af0cbb commit 96a118d
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 94 deletions.
4 changes: 2 additions & 2 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ static void CF_CFDP_CycleTx(CF_Channel_t *c)
/* didn't find anything on TXA to run, so pop one off Q_PEND and try again.
* Keep going until CF_QueueIdx_PEND is empty or something is run */
CF_Transaction_t *t = container_of(c->qs[CF_QueueIdx_PEND], CF_Transaction_t, cl_node);
cf_move_transaction(t, CF_QueueIdx_TXA);
CF_MoveTransaction(t, CF_QueueIdx_TXA);
/* args is ok, still { c, 0 } */
entry_jump:
CF_CList_Traverse(c->qs[CF_QueueIdx_TXA], CF_CFDP_CycleTx_, &args);
Expand Down Expand Up @@ -2095,7 +2095,7 @@ void CF_CFDP_ResetTransaction(CF_Transaction_t *t, int keep_history)
CF_Channel_t *c = &CF_AppData.engine.channels[t->chan_num];
CF_Assert(t->chan_num < CF_NUM_CHANNELS);

cf_dequeue_transaction(t);
CF_DequeueTransaction(t);

if (OS_ObjectIdDefined(t->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 @@ -130,7 +130,7 @@ typedef struct CF_Playback
typedef struct CF_Poll
{
CF_Playback_t pb;
cf_timer_t interval_timer;
CF_Timer_t interval_timer;
bool timer_set;
} CF_Poll_t;

Expand Down Expand Up @@ -223,8 +223,8 @@ typedef struct CF_Transaction

CF_History_t *history; /* weird, but this also holds active filenames and possibly other info */
CF_ChunkWrapper_t *chunks; /* for gap tracking, only used on class 2 */
cf_timer_t inactivity_timer; /* set to the overall inactivity timer of a remote */
cf_timer_t ack_timer; /* called ack_timer, but is also nak_timer */
CF_Timer_t inactivity_timer; /* set to the overall inactivity timer of a remote */
CF_Timer_t ack_timer; /* called ack_timer, but is also nak_timer */

uint32 fsize; /* lseek() should be 64-bit on 64-bit system, but osal limits to 32-bit */
uint32 foffs; /* offset into file for next read */
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_cfdp_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static void CF_CFDP_S2_SubstateSendEof(CF_Transaction_t *t)
/* no longer need to send file data PDU except in the case of NAK response */

/* move this transaction off Q_PEND */
cf_dequeue_transaction(t);
CF_DequeueTransaction(t);
CF_InsertSortPrio(t, CF_QueueIdx_TXW);
}

Expand Down
8 changes: 4 additions & 4 deletions fsw/src/cf_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
** \endreturns
**
*************************************************************************/
static inline uint32 CF_Timer_Sec2Ticks(cf_timer_sec_t sec)
static inline uint32 CF_Timer_Sec2Ticks(CF_Timer_Seconds_t sec)
{
return sec * CF_AppData.config_table->ticks_per_second;
}
Expand All @@ -60,7 +60,7 @@ static inline uint32 CF_Timer_Sec2Ticks(cf_timer_sec_t sec)
** t must not be NULL.
**
*************************************************************************/
void CF_Timer_InitRelSec(cf_timer_t *t, uint32 rel_sec)
void CF_Timer_InitRelSec(CF_Timer_t *t, uint32 rel_sec)
{
t->tick = CF_Timer_Sec2Ticks(rel_sec);
}
Expand All @@ -76,7 +76,7 @@ void CF_Timer_InitRelSec(cf_timer_t *t, uint32 rel_sec)
** \endreturns
**
*************************************************************************/
int CF_Timer_Expired(const cf_timer_t *t)
int CF_Timer_Expired(const CF_Timer_t *t)
{
return !t->tick;
}
Expand All @@ -88,7 +88,7 @@ int CF_Timer_Expired(const cf_timer_t *t)
** t must not be NULL.
**
*************************************************************************/
void CF_Timer_Tick(cf_timer_t *t)
void CF_Timer_Tick(CF_Timer_t *t)
{
CF_Assert(t->tick);
--t->tick;
Expand Down
24 changes: 12 additions & 12 deletions fsw/src/cf_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@
**
*************************************************************************/

#ifndef CF_TIMER__H
#define CF_TIMER__H
#ifndef CF_TIMER_H
#define CF_TIMER_H

#include "cfe.h"

/* NOTE: We expect ticks to be 100/sec, so using uint32 for sec could have a bounds condition
* with uint32. But, we don't expect to use more than 400,000,000 seconds for any reason so
* let's just live with it. */
typedef uint32 CF_Timer_Tick_t;
typedef uint32 cf_timer_sec_t;
typedef uint32 CF_Timer_Ticks_t;
typedef uint32 CF_Timer_Seconds_t;

typedef struct
typedef struct CF_Timer
{
CF_Timer_Tick_t tick; /* expires when reaches 0 */
} cf_timer_t;
CF_Timer_Ticks_t tick; /* expires when reaches 0 */
} CF_Timer_t;

/* initialize a timer
*
* If the abs_sec value is greater than current time, then the timer will
* be immediately expired. */
extern void CF_Timer_InitRelSec(cf_timer_t *c, cf_timer_sec_t rel_sec);
extern void CF_Timer_InitRelSec(CF_Timer_t *c, CF_Timer_Seconds_t rel_sec);

extern void cf_timer_update_timebase(void);
extern void CF_Timer_UpdateTimebase(void);

/* returns 1 if expired */
extern int CF_Timer_Expired(const cf_timer_t *t);
extern int CF_Timer_Expired(const CF_Timer_t *t);

extern void CF_Timer_Tick(cf_timer_t *t);
extern void CF_Timer_Tick(CF_Timer_t *t);

#endif /* !CF_TIMER__H */
#endif /* !CF_TIMER_H */
10 changes: 5 additions & 5 deletions fsw/src/cf_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
**
*************************************************************************/

#ifndef __CF_UTILS_H_
#define __CF_UTILS_H_
#ifndef CF_UTILS_H
#define CF_UTILS_H

#include "cf_cfdp.h"
#include "cf_assert.h"
Expand All @@ -39,15 +39,15 @@
* otherwise if the structure is zero'd out the queue
* will become corrupted due to other nodes on the queue
* pointing to an invalid node */
static inline void cf_dequeue_transaction(CF_Transaction_t *t)
static inline void CF_DequeueTransaction(CF_Transaction_t *t)
{
CF_Assert(t && (t->chan_num < CF_NUM_CHANNELS));
CF_CList_Remove(&CF_AppData.engine.channels[t->chan_num].qs[t->flags.com.q_index], &t->cl_node);
CF_Assert(CF_AppData.hk.channel_hk[t->chan_num].q_size[t->flags.com.q_index]); /* sanity check */
--CF_AppData.hk.channel_hk[t->chan_num].q_size[t->flags.com.q_index];
}

static inline void cf_move_transaction(CF_Transaction_t *t, CF_QueueIdx_t q)
static inline void CF_MoveTransaction(CF_Transaction_t *t, CF_QueueIdx_t q)
{
CF_Assert(t && (t->chan_num < CF_NUM_CHANNELS));
CF_CList_Remove(&CF_AppData.engine.channels[t->chan_num].qs[t->flags.com.q_index], &t->cl_node);
Expand Down Expand Up @@ -94,4 +94,4 @@ extern int32 CF_WrappedRead(osal_id_t fd, void *buf, size_t read_size);
extern int32 CF_WrappedWrite(osal_id_t fd, const void *buf, size_t write_size);
extern int32 CF_WrappedLseek(osal_id_t fd, off_t offset, int mode);

#endif /* !__CF_UTILS_H_ */
#endif /* !CF_UTILS_H */
40 changes: 20 additions & 20 deletions unit-test/cf_cfdp_s_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void Test_CF_CFDP_S1_SubstateSendEof_Call_CF_CFDP_S_Reset_With_t_When_CFDP_S_Sen

/*******************************************************************************
**
** CF_CFDP_S2_SubstateSendEof tests (small) - full coverage - [unstubbables: cf_dequeue_transaction]
** CF_CFDP_S2_SubstateSendEof tests (small) - full coverage - [unstubbables: CF_DequeueTransaction]
**
*******************************************************************************/

Expand All @@ -295,7 +295,7 @@ void Test_CF_CFDP_S2_SubstateSendEof_TriggerTickProcessing(void)

UT_SetDataBuffer(UT_KEY(CF_InsertSortPrio), &context_CF_InsertSortPrio, sizeof(context_CF_InsertSortPrio), false);

/* Arrange unstubbable: cf_dequeue_transaction */
/* Arrange unstubbable: CF_DequeueTransaction */
uint16 initial_q_size_q_index = Any_uint16_GreaterThan(0);
CF_CList_Remove_context_t context_CF_CList_Remove;

Expand All @@ -319,7 +319,7 @@ void Test_CF_CFDP_S2_SubstateSendEof_TriggerTickProcessing(void)
UtAssert_True(context_CF_InsertSortPrio.q == CF_QueueIdx_TXW,
"CF_InsertSortPrio received q %u and should be %u (CF_QueueIdx_TXW)", context_CF_InsertSortPrio.q,
CF_QueueIdx_TXW);
/* Assert for cf_dequeue_transaction */
/* Assert for CF_DequeueTransaction */
UtAssert_STUB_COUNT(CF_CList_Remove, 1);
UtAssert_ADDRESS_EQ(context_CF_CList_Remove.head,
&CF_AppData.engine.channels[arg_t->chan_num].qs[arg_t->flags.com.q_index]);
Expand Down Expand Up @@ -3395,7 +3395,7 @@ void Test_CF_CFDP_S_Tick_CallTo_CF_TimerExpired_Returns_1_ThenSendsEventAndCalls
CF_Transaction_t *arg_t = &dummy_t;
int *arg_cont = NULL;
uint16 initial_inactivity_timer = Any_uint16();
cf_timer_t *context_CF_Timer_Expired;
CF_Timer_t *context_CF_Timer_Expired;
const char *expected_Spec = "CF S2(%u:%u): inactivity timer expired";
CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent;

Expand Down Expand Up @@ -3460,8 +3460,8 @@ void Test_CF_CFDP_S_Tick_ArmedTimerExpiredAnd_sub_state_EqTo_SEND_WAIT_FOR_EOF_A
uint16 initial_inactivity_timer = Any_uint16();
uint16 initial_fault_ack_limit = Any_uint16();
uint8 dummy_ack_limit = Any_uint8();
cf_timer_t *context_CF_Timer_Expired[2];
cf_timer_t *context_CF_Timer_Tick;
CF_Timer_t *context_CF_Timer_Expired[2];
CF_Timer_t *context_CF_Timer_Tick;
const char *expected_Spec = "CF S2(%u:%u), ack limit reached, no eof-ack";

arg_t->history = &dummy_history;
Expand Down Expand Up @@ -3541,8 +3541,8 @@ void Test_CF_CFDP_S_Tick_ArmedTimerExpiredAnd_sub_state_EqTo_SEND_WAIT_FOR_EOF_A
uint16 initial_inactivity_timer = Any_uint16();
uint16 initial_fault_ack_limit = Any_uint16();
uint8 dummy_ack_limit = Any_uint8();
cf_timer_t *context_CF_Timer_Expired[2];
cf_timer_t *context_CF_Timer_Tick;
CF_Timer_t *context_CF_Timer_Expired[2];
CF_Timer_t *context_CF_Timer_Tick;

arg_t->history = &dummy_history;
arg_t->chan_num = Any_cf_chan_num();
Expand Down Expand Up @@ -3611,8 +3611,8 @@ void Test_CF_CFDP_S_Tick_ArmedTimerExpiredAnd_sub_state_EqTo_SEND_WAIT_FOR_EOF_A
uint16 initial_inactivity_timer = Any_uint16();
uint16 initial_fault_ack_limit = Any_uint16();
uint8 dummy_ack_limit = Any_uint8();
cf_timer_t *context_CF_Timer_Expired[2];
cf_timer_t *context_CF_Timer_Tick;
CF_Timer_t *context_CF_Timer_Expired[2];
CF_Timer_t *context_CF_Timer_Tick;

arg_t->history = &dummy_history;
arg_t->chan_num = Any_cf_chan_num();
Expand Down Expand Up @@ -3691,8 +3691,8 @@ void Test_CF_CFDP_S_Tick_ArmedTimerExpiredAnd_sub_state_EqTo_SEND_WAIT_FOR_EOF_A
uint16 initial_inactivity_timer = Any_uint16();
uint16 initial_fault_ack_limit = Any_uint16();
uint8 dummy_ack_limit = Any_uint8();
cf_timer_t *context_CF_Timer_Expired[2];
cf_timer_t *context_CF_Timer_Tick;
CF_Timer_t *context_CF_Timer_Expired[2];
CF_Timer_t *context_CF_Timer_Tick;
CF_Transaction_t *context_CF_CFDP_ArmAckTimer;

arg_t->history = &dummy_history;
Expand Down Expand Up @@ -3765,8 +3765,8 @@ void Test_CF_CFDP_S_Tick_ArmedTimerExpired_sub_state_NotEqTo_SEND_WAIT_FOR_EOF_A
uint8 exceptions[2] = {
CF_TxSubState_WAIT_FOR_EOF_ACK,
CF_TxSubState_SEND_FIN_ACK}; // CF_TxSubState_SEND_FIN_ACK only excepted for separate behavior 'if' block
cf_timer_t *context_CF_Timer_Expired[2];
cf_timer_t *context_CF_Timer_Tick;
CF_Timer_t *context_CF_Timer_Expired[2];
CF_Timer_t *context_CF_Timer_Tick;

arg_t->chan_num = Any_cf_chan_num();
arg_t->state = CF_TxnState_S2;
Expand Down Expand Up @@ -3813,8 +3813,8 @@ void Test_CF_CFDP_S_Tick_ArmedTimerNotExpiredCall_CF_Timer_Tick(void)
int *arg_cont = NULL;
uint16 initial_inactivity_timer = Any_uint16();
uint16 initial_fault_ack_limit = Any_uint16();
cf_timer_t *context_CF_Timer_Expired[2];
cf_timer_t *context_CF_Timer_Tick[2];
CF_Timer_t *context_CF_Timer_Expired[2];
CF_Timer_t *context_CF_Timer_Tick[2];

arg_t->chan_num = Any_cf_chan_num();
arg_t->state = CF_TxnState_S2;
Expand Down Expand Up @@ -3862,8 +3862,8 @@ void Test_CF_CFDP_S_Tick_TimerNotArmedDoNotArmAckTimerOrDoTick(void)
int *arg_cont = NULL;
uint16 initial_inactivity_timer = Any_uint16();
uint16 initial_fault_ack_limit = Any_uint16();
cf_timer_t *context_CF_Timer_Expired;
cf_timer_t *context_CF_Timer_Tick;
CF_Timer_t *context_CF_Timer_Expired;
CF_Timer_t *context_CF_Timer_Tick;

arg_t->chan_num = Any_cf_chan_num();
arg_t->state = CF_TxnState_S2;
Expand Down Expand Up @@ -3909,8 +3909,8 @@ void Test_CF_CFDP_S_Tick_When_sub_state_IsEqTo_SEND_SEND_FIN_ACK_Call_CF_CFDP_S_
int *arg_cont = NULL;
uint16 initial_inactivity_timer = Any_uint16();
uint16 initial_fault_ack_limit = Any_uint16();
cf_timer_t *context_CF_Timer_Expired;
cf_timer_t *context_CF_Timer_Tick;
CF_Timer_t *context_CF_Timer_Expired;
CF_Timer_t *context_CF_Timer_Tick;

arg_t->history = &dummy_history;
arg_t->chan_num = Any_cf_chan_num();
Expand Down
Loading

0 comments on commit 96a118d

Please sign in to comment.