Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 4ef9460
Author: Avi <thnkslprpt@gmail.com>
Date:   Fri Mar 10 10:10:40 2023 +1000

    Formatting

commit e18bde9
Merge: 8fb8d9c cb2977c
Author: Avi <thnkslprpt@gmail.com>
Date:   Fri Mar 10 08:41:21 2023 +1000

    Merge branch 'main' into fix-105-remove-dummy-from-variable-names

commit cb2977c
Merge: 4ce1aa9 3444ff4
Author: dzbaker <dylan.z.baker@nasa.gov>
Date:   Thu Mar 9 15:23:53 2023 -0500

    Merge pull request nasa#366 from thnkslprpt/fix-365-remove-extraneous-assignments

    Fix nasa#365, Remove extraneous assignments to CFE_SUCCESS

commit 4ce1aa9
Merge: c44e372 dec4440
Author: dzbaker <dylan.z.baker@nasa.gov>
Date:   Thu Mar 9 15:20:08 2023 -0500

    Merge pull request nasa#333 from thnkslprpt/fix-109-variable-declarations

    Fix nasa#109, Move variables declared mid-function to the top

commit 8fb8d9c
Author: Avi <thnkslprpt@gmail.com>
Date:   Thu Feb 23 12:45:59 2023 +1000

    Fix nasa#105, Remove 'dummy' from variable names

commit 3444ff4
Author: Avi <thnkslprpt@gmail.com>
Date:   Thu Feb 16 10:39:06 2023 +1000

    Fix nasa#365, Remove extraneous assignments to CFE_SUCCESS

commit dec4440
Author: Avi Weiss <thnkslprpt@gmail.com>
Date:   Mon Dec 26 16:23:48 2022 +1100

    Fix nasa#109, Move variables declared mid-function to the top

    commit 4e1bb97
    Author: Avi Weiss <thnkslprpt@gmail.com>
    Date:   Mon Dec 26 16:14:26 2022 +1100

        Typo from merge from main

    commit 57ab176
    Merge: e151abd 8368adc
    Author: Avi <thnkslprpt@gmail.com>
    Date:   Mon Dec 26 15:16:21 2022 +1100

        Merge branch 'main' into fix-109-variable-declarations

    commit e151abd
    Author: Avi <thnkslprpt@gmail.com>
    Date:   Thu Oct 13 18:34:51 2022 +1000

        Fix nasa#109, Move variables declared mid-function to the top
  • Loading branch information
thnkslprpt committed Mar 10, 2023
1 parent c44e372 commit c23dcd5
Show file tree
Hide file tree
Showing 14 changed files with 788 additions and 841 deletions.
4 changes: 2 additions & 2 deletions fsw/src/cf_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int32 CF_ValidateConfigTable(void *tbl_ptr)
*-----------------------------------------------------------------*/
int32 CF_TableInit(void)
{
int32 status = CFE_SUCCESS;
int32 status;

status = CFE_TBL_Register(&CF_AppData.config_handle, CF_CONFIG_TABLE_NAME, sizeof(CF_ConfigTable_t),
CFE_TBL_OPT_SNGL_BUFFER | CFE_TBL_OPT_LOAD_DUMP, CF_ValidateConfigTable);
Expand Down Expand Up @@ -205,7 +205,7 @@ int32 CF_TableInit(void)
*-----------------------------------------------------------------*/
int32 CF_Init(void)
{
int32 status = CFE_SUCCESS;
int32 status;
static const CFE_SB_MsgId_Atom_t MID_VALUES[] = {CF_CMD_MID, CF_SEND_HK_MID, CF_WAKE_UP_MID};
uint32 i;

Expand Down
47 changes: 27 additions & 20 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,12 +952,15 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
int32 CF_CFDP_InitEngine(void)
{
/* initialize all transaction nodes */
int i;
int j;
int chunk_mem_offset = 0;
CF_History_t * h;
CF_Transaction_t * t = CF_AppData.engine.transactions;
CF_ChunkWrapper_t *c = CF_AppData.engine.chunks;
int32 ret = CFE_SUCCESS;
int chunk_mem_offset = 0;
int i;
int j;
int k;
char nbuf[64];

static const int CF_DIR_MAX_CHUNKS[CF_Direction_NUM][CF_NUM_CHANNELS] = {CF_CHANNEL_NUM_RX_CHUNKS_PER_TRANSACTION,
CF_CHANNEL_NUM_TX_CHUNKS_PER_TRANSACTION};
Expand All @@ -966,7 +969,6 @@ int32 CF_CFDP_InitEngine(void)

for (i = 0; i < CF_NUM_CHANNELS; ++i)
{
char nbuf[64];
snprintf(nbuf, sizeof(nbuf) - 1, "%s%d", CF_CHANNEL_PIPE_PREFIX, i);
ret = CFE_SB_CreatePipe(&CF_AppData.engine.channels[i].pipe, CF_AppData.config_table->chan[i].pipe_depth_input,
nbuf);
Expand Down Expand Up @@ -1022,8 +1024,6 @@ int32 CF_CFDP_InitEngine(void)

for (j = 0; j < CF_NUM_TRANSACTIONS_PER_CHANNEL; ++j, ++t)
{
int k;

t->chan_num = i;
CF_FreeTransaction(t);

Expand All @@ -1039,7 +1039,7 @@ int32 CF_CFDP_InitEngine(void)

for (j = 0; j < CF_NUM_HISTORIES_PER_CHANNEL; ++j)
{
CF_History_t *h = &CF_AppData.engine.histories[(i * CF_NUM_HISTORIES_PER_CHANNEL) + j];
h = &CF_AppData.engine.histories[(i * CF_NUM_HISTORIES_PER_CHANNEL) + j];
CF_CList_InitNode(&h->cl_node);
CF_CList_InsertBack_Ex(&CF_AppData.engine.channels[i], CF_QueueIdx_HIST_FREE, &h->cl_node);
}
Expand Down Expand Up @@ -1325,7 +1325,7 @@ static int32 CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *p, const char *src_file
CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority,
CF_EntityId_t dest_id)
{
int32 ret = CFE_SUCCESS;
int32 ret;

/* make sure the directory can be open */
ret = OS_DirectoryOpen(&p->dir_id, src_filename);
Expand Down Expand Up @@ -1395,14 +1395,14 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *c, CF_Playback_t *p)
{
CF_Transaction_t *pt;
os_dirent_t dirent;
int32 status;

/* either there's no transaction (first one) or the last one was finished, so check for a new one */

memset(&dirent, 0, sizeof(dirent));

while (p->diropen && (p->num_ts < CF_NUM_TRANSACTIONS_PER_PLAYBACK))
{
int32 status;

CFE_ES_PerfLogEntry(CF_PERF_ID_DIRREAD);
status = OS_DirectoryRead(p->dir_id, &dirent);
CFE_ES_PerfLogExit(CF_PERF_ID_DIRREAD);
Expand Down Expand Up @@ -1500,15 +1500,21 @@ static void CF_CFDP_ProcessPlaybackDirectories(CF_Channel_t *c)
*-----------------------------------------------------------------*/
void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c)
{
int i;
CF_Poll_t * p;
CF_ChannelConfig_t *cc;
CF_PollDir_t * pd;
int i;
int chan_index;
int count_check;
int ret;

for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i)
{
CF_Poll_t * p = &c->poll[i];
int chan_index = (c - CF_AppData.engine.channels);
CF_ChannelConfig_t *cc = &CF_AppData.config_table->chan[chan_index];
CF_PollDir_t * pd = &cc->polldir[i];
int count_check = 0;
p = &c->poll[i];
chan_index = (c - CF_AppData.engine.channels);
cc = &CF_AppData.config_table->chan[chan_index];
pd = &cc->polldir[i];
count_check = 0;

if (pd->enabled && pd->interval_sec)
{
Expand All @@ -1524,8 +1530,8 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c)
else if (CF_Timer_Expired(&p->interval_timer))
{
/* the timer has expired */
int ret = CF_CFDP_PlaybackDir_Initiate(&p->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0,
chan_index, pd->priority, pd->dest_eid);
ret = CF_CFDP_PlaybackDir_Initiate(&p->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, chan_index,
pd->priority, pd->dest_eid);
if (!ret)
{
p->timer_set = 0;
Expand Down Expand Up @@ -1562,13 +1568,14 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c)
*-----------------------------------------------------------------*/
void CF_CFDP_CycleEngine(void)
{
int i;
CF_Channel_t *c;
int i;

if (CF_AppData.engine.enabled)
{
for (i = 0; i < CF_NUM_CHANNELS; ++i)
{
CF_Channel_t *c = &CF_AppData.engine.channels[i];
c = &CF_AppData.engine.channels[i];
CF_AppData.engine.outgoing_counter = 0;

/* consume all received messages, even if channel is frozen */
Expand Down
28 changes: 15 additions & 13 deletions fsw/src/cf_cfdp_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ int CF_CFDP_R_CheckCrc(CF_Transaction_t *t, uint32 expected_crc)
*-----------------------------------------------------------------*/
void CF_CFDP_R2_Complete(CF_Transaction_t *t, int ok_to_send_nak)
{
int send_nak = 0;
int send_fin = 0;
uint32 ret;
int send_nak = 0;
int send_fin = 0;
/* checking if r2 is complete. Check nak list, and send NAK if appropriate */
/* if all data is present, then there will be no gaps in the chunk */

Expand All @@ -129,7 +130,7 @@ void CF_CFDP_R2_Complete(CF_Transaction_t *t, int ok_to_send_nak)
else
{
/* only look for 1 gap, since the goal here is just to know that there are gaps */
uint32 ret = CF_ChunkList_ComputeGaps(&t->chunks->chunks, 1, t->fsize, 0, NULL, NULL);
ret = CF_ChunkList_ComputeGaps(&t->chunks->chunks, 1, t->fsize, 0, NULL, NULL);

if (ret)
{
Expand Down Expand Up @@ -487,8 +488,8 @@ int CF_CFDP_R_SubstateSendNak(CF_Transaction_t *t)
CF_AppData.config_table->local_eid, 1, t->history->seq_num, 1);
CF_Logical_PduNak_t *nak;
CF_SendRet_t sret;

int ret = -1;
uint32 cret;
int ret = -1;

if (ph)
{
Expand All @@ -498,7 +499,6 @@ int CF_CFDP_R_SubstateSendNak(CF_Transaction_t *t)
{
/* we have metadata, so send valid nak */
CF_GapComputeArgs_t args = {t, nak};
uint32 cret;

nak->scope_start = 0;
cret = CF_ChunkList_ComputeGaps(&t->chunks->chunks,
Expand Down Expand Up @@ -777,7 +777,10 @@ void CF_CFDP_R2_Recv_fin_ack(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
*-----------------------------------------------------------------*/
void CF_CFDP_R2_RecvMd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
{
bool success = true;
char fname[CF_FILENAME_MAX_LEN];
int status;
int32 ret;
bool success = true;

/* it isn't an error to get another MD pdu, right? */
if (!t->flags.rx.md_recv)
Expand All @@ -786,8 +789,6 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
/* parse the md pdu. this will overwrite the transaction's history, which contains our filename. so let's
* save the filename in a local buffer so it can be used with OS_mv upon successful parsing of
* the md pdu */
char fname[CF_FILENAME_MAX_LEN];
int status;

strcpy(
fname,
Expand Down Expand Up @@ -835,7 +836,7 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
}
else
{
int32 ret =
ret =
CF_WrappedOpenCreate(&t->fd, t->history->fnames.dst_filename, OS_FILE_FLAG_NONE, OS_READ_WRITE);
if (ret < 0)
{
Expand Down Expand Up @@ -959,7 +960,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *t, int *cont /* unused */)
* the logic by state so that it isn't a bunch of if statements for different flags
*/

bool success = true;
CF_SendRet_t sret;
bool success = true;

/* at each tick, various timers used by R are checked */
/* first, check inactivity timer */
Expand All @@ -983,8 +985,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *t, int *cont /* unused */)
/* rx maintenance: possibly process send_eof_ack, send_nak or send_fin */
if (t->flags.rx.send_ack)
{
CF_SendRet_t sret = CF_CFDP_SendAck(t, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF,
t->state_data.r.r2.eof_cc, t->history->peer_eid, t->history->seq_num);
sret = CF_CFDP_SendAck(t, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF, t->state_data.r.r2.eof_cc,
t->history->peer_eid, t->history->seq_num);
CF_Assert(sret != CF_SendRet_ERROR);

/* if CF_SendRet_SUCCESS, then move on in the state machine. CF_CFDP_SendAck does not return
Expand Down
15 changes: 8 additions & 7 deletions fsw/src/cf_cfdp_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,12 @@ void CF_CFDP_S_SubstateSendFileData(CF_Transaction_t *t)
int CF_CFDP_S_CheckAndRespondNak(CF_Transaction_t *t)
{
const CF_Chunk_t *c;
CF_SendRet_t sret;
int ret = 0;

if (t->flags.tx.md_need_send)
{
CF_SendRet_t sret = CF_CFDP_SendMd(t);
sret = CF_CFDP_SendMd(t);
if (sret == CF_SendRet_ERROR)
{
ret = -1; /* error occurred */
Expand Down Expand Up @@ -341,14 +342,13 @@ void CF_CFDP_S2_SubstateSendFileData(CF_Transaction_t *t)
*-----------------------------------------------------------------*/
void CF_CFDP_S_SubstateSendMetadata(CF_Transaction_t *t)
{
bool success = true;
int status = 0;
CF_SendRet_t sret;
int32 ret;
int status = 0;
bool success = true;

if (!OS_ObjectIdDefined(t->fd))
{
int32 ret;

if (OS_FileOpenCheck(t->history->fnames.src_filename) == OS_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_ALREADY_OPEN, CFE_EVS_EventType_ERROR,
Expand Down Expand Up @@ -699,7 +699,8 @@ void CF_CFDP_S_Tick(CF_Transaction_t *t, int *cont /* unused */)
/* Steven is not real happy with this function. There should be a better way to separate out
* the logic by state so that it isn't a bunch of if statements for different flags
*/
bool early_exit = false;
CF_SendRet_t sret;
bool early_exit = false;

/* at each tick, various timers used by S are checked */
/* first, check inactivity timer */
Expand Down Expand Up @@ -743,7 +744,7 @@ void CF_CFDP_S_Tick(CF_Transaction_t *t, int *cont /* unused */)
}
else
{
CF_SendRet_t sret = CF_CFDP_S_SendEof(t);
sret = CF_CFDP_S_SendEof(t);
if (sret == CF_SendRet_NO_MSG)
{
early_exit = true;
Expand Down
3 changes: 1 addition & 2 deletions fsw/src/cf_cfdp_sbintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *c)
CFE_MSG_Type_t msg_type = CFE_MSG_Type_Invalid;

CF_Logical_PduBuffer_t *ph;
CF_Transaction_t t_finack;

for (; count < CF_AppData.config_table->chan[chan_num].rx_max_messages_per_wakeup; ++count)
{
Expand Down Expand Up @@ -243,8 +244,6 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *c)
{
if (!CF_CFDP_RecvFin(t, ph))
{
CF_Transaction_t t_finack;

memset(&t_finack, 0, sizeof(t_finack));
CF_CFDP_InitTxnTxFile(&t_finack, CF_CFDP_CLASS_2, 1, chan_num,
0); /* populate transaction with needed fields for CF_CFDP_SendAck() */
Expand Down
14 changes: 9 additions & 5 deletions fsw/src/cf_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,22 @@ CF_ChunkIdx_t CF_Chunks_FindSmallestSize(const CF_ChunkList_t *chunks)
*-----------------------------------------------------------------*/
void CF_Chunks_Insert(CF_ChunkList_t *chunks, CF_ChunkIdx_t i, const CF_Chunk_t *chunk)
{
int n = CF_Chunks_CombineNext(chunks, i, chunk);
CF_ChunkIdx_t smallest_i;
CF_Chunk_t * smallest_c;
int n = CF_Chunks_CombineNext(chunks, i, chunk);
int combined;

if (n)
{
int combined = CF_Chunks_CombinePrevious(chunks, i, &chunks->chunks[i]);
combined = CF_Chunks_CombinePrevious(chunks, i, &chunks->chunks[i]);
if (combined)
{
CF_Chunks_EraseChunk(chunks, i);
}
}
else
{
int combined = CF_Chunks_CombinePrevious(chunks, i, chunk);
combined = CF_Chunks_CombinePrevious(chunks, i, chunk);
if (!combined)
{
if (chunks->count < chunks->max_chunks)
Expand All @@ -255,8 +259,8 @@ void CF_Chunks_Insert(CF_ChunkList_t *chunks, CF_ChunkIdx_t i, const CF_Chunk_t
}
else
{
CF_ChunkIdx_t smallest_i = CF_Chunks_FindSmallestSize(chunks);
CF_Chunk_t * smallest_c = &chunks->chunks[smallest_i];
smallest_i = CF_Chunks_FindSmallestSize(chunks);
smallest_c = &chunks->chunks[smallest_i];
if (smallest_c->size < chunk->size)
{
CF_Chunks_EraseChunk(chunks, smallest_i);
Expand Down
8 changes: 6 additions & 2 deletions fsw/src/cf_clist.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ void CF_CList_InitNode(CF_CListNode_t *node)
*-----------------------------------------------------------------*/
void CF_CList_InsertFront(CF_CListNode_t **head, CF_CListNode_t *node)
{
CF_CListNode_t *last;

CF_Assert(head);
CF_Assert(node);
CF_Assert(node->next == node);
CF_Assert(node->prev == node);

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

node->next = *head;
node->prev = last;
Expand All @@ -79,6 +81,8 @@ void CF_CList_InsertFront(CF_CListNode_t **head, CF_CListNode_t *node)
*-----------------------------------------------------------------*/
void CF_CList_InsertBack(CF_CListNode_t **head, CF_CListNode_t *node)
{
CF_CListNode_t *last;

CF_Assert(head);
CF_Assert(node);
CF_Assert(node->next == node);
Expand All @@ -90,7 +94,7 @@ void CF_CList_InsertBack(CF_CListNode_t **head, CF_CListNode_t *node)
}
else
{
CF_CListNode_t *last = (*head)->prev;
last = (*head)->prev;

node->next = *head;
(*head)->prev = node;
Expand Down
Loading

0 comments on commit c23dcd5

Please sign in to comment.