Skip to content

Commit

Permalink
early_exit
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Jul 12, 2024
1 parent 7639e40 commit 9a68476
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 118 deletions.
28 changes: 14 additions & 14 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void CF_CFDP_DecodeStart(CF_DecoderState_t *pdec, const void *msgbuf, CF_Logical
void CF_CFDP_ArmAckTimer(CF_Transaction_t *txn)
{
CF_Timer_InitRelSec(&txn->ack_timer, CF_AppData.config_table->chan[txn->chan_num].ack_timer_s);
txn->flags.com.ack_timer_armed = 1;
txn->flags.com.ack_timer_armed = true;
}

/*----------------------------------------------------------------
Expand Down Expand Up @@ -252,7 +252,7 @@ CF_Logical_PduBuffer_t *CF_CFDP_ConstructPduHeader(const CF_Transaction_t *txn,

hdr->version = 1;
hdr->pdu_type = (directive_code == 0); /* set to '1' for file data PDU, '0' for a directive PDU */
hdr->direction = (towards_sender != 0); /* set to '1' for toward sender, '0' for toward receiver */
hdr->direction = (towards_sender != false); /* set to '1' for toward sender, '0' for toward receiver */
hdr->txm_mode = (CF_CFDP_GetClass(txn) == CF_CFDP_CLASS_1); /* set to '1' for class 1 data, '0' for class 2 */

/* choose the larger of the two EIDs to determine size */
Expand Down Expand Up @@ -896,7 +896,7 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
{
/* NOTE: whether or not class 1 or 2, get a free chunks. It's cheap, and simplifies cleanup path */
txn->state = ph->pdu_header.txm_mode ? CF_TxnState_R1 : CF_TxnState_R2;
txn->flags.rx.md_recv = 1;
txn->flags.rx.md_recv = true;
CF_CFDP_R_Init(txn); /* initialize R */
}
else
Expand All @@ -918,7 +918,7 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
if (txn->state == CF_TxnState_IDLE)
{
/* state was not changed, so free the transaction */
CF_CFDP_ResetTransaction(txn, 0);
CF_CFDP_ResetTransaction(txn, false);
}
}

Expand Down Expand Up @@ -1137,7 +1137,7 @@ CF_CListTraverse_Status_t CF_CFDP_DoTick(CF_CListNode_t *node, void *context)
if (args->chan->cur)
{
ret = CF_CLIST_EXIT;
args->early_exit = 1;
args->early_exit = true;
}
}

Expand Down Expand Up @@ -1289,7 +1289,7 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, const char *dst_filename,
CF_CFDP_TxFile_Initiate(txn, cfdp_class, keep, chan_num, priority, dest_id);

++chan->num_cmd_tx;
txn->flags.tx.cmd_tx = 1;
txn->flags.tx.cmd_tx = true;
}

return ret;
Expand All @@ -1316,8 +1316,8 @@ static CFE_Status_t CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *pb, const char *
}
else
{
pb->diropen = 1;
pb->busy = 1;
pb->diropen = true;
pb->busy = true;
pb->keep = keep;
pb->priority = priority;
pb->dest_id = dest_id;
Expand Down Expand Up @@ -1417,15 +1417,15 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *chan, CF_Playback_t *pb)
{
/* PFTO: can we figure out the difference between "end of dir" and an error? */
OS_DirectoryClose(pb->dir_id);
pb->diropen = 0;
pb->diropen = false;
}
}

if (!pb->diropen && !pb->num_ts)
{
/* the directory has been exhausted, and there are no more active transactions
* for this playback -- so mark it as not busy */
pb->busy = 0;
pb->busy = false;
}
}

Expand Down Expand Up @@ -1503,7 +1503,7 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan)
{
/* timer was not set, so set it now */
CF_Timer_InitRelSec(&poll->interval_timer, pd->interval_sec);
poll->timer_set = 1;
poll->timer_set = true;
}
else if (CF_Timer_Expired(&poll->interval_timer))
{
Expand All @@ -1512,7 +1512,7 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan)
chan_index, pd->priority, pd->dest_eid);
if (!ret)
{
poll->timer_set = 0;
poll->timer_set = false;
}
else
{
Expand Down Expand Up @@ -1586,7 +1586,7 @@ void CF_CFDP_CycleEngine(void)
* See description in cf_cfdp.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, int keep_history)
void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, bool keep_history)
{
char * filename;
char destination[OS_MAX_PATH_LEN];
Expand Down Expand Up @@ -1759,7 +1759,7 @@ void CF_CFDP_CancelTransaction(CF_Transaction_t *txn)
void (*fns[2])(CF_Transaction_t * txn) = {CF_CFDP_R_Cancel, CF_CFDP_S_Cancel};
if (!txn->flags.com.canceled)
{
txn->flags.com.canceled = 1;
txn->flags.com.canceled = true;
CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_CANCEL_REQUEST_RECEIVED);
fns[!!CF_CFDP_IsSender(txn)](txn);
}
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/cf_cfdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef struct CF_CFDP_Tick_args
{
CF_Channel_t *chan; /**< \brief channel structure */
void (*fn)(CF_Transaction_t *, int *); /**< \brief function pointer */
int early_exit; /**< \brief early exit result */
bool early_exit; /**< \brief early exit result */
int cont; /**< \brief if 1, then re-traverse the list */
} CF_CFDP_Tick_args_t;

Expand Down Expand Up @@ -91,7 +91,7 @@ void CF_CFDP_DecodeStart(CF_DecoderState_t *pdec, const void *msgbuf, CF_Logical
* @param txn Pointer to the transaction object
* @param keep_history Whether the transaction info should be preserved in history
*/
void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, int keep_history);
void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, bool keep_history);

/************************************************************************/
/** @brief Helper function to store transaction status code only
Expand Down
50 changes: 25 additions & 25 deletions fsw/src/cf_cfdp_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
void CF_CFDP_R2_SetFinTxnStatus(CF_Transaction_t *txn, CF_TxnStatus_t txn_stat)
{
CF_CFDP_SetTxnStatus(txn, txn_stat);
txn->flags.rx.send_fin = 1;
txn->flags.rx.send_fin = true;
}

/*----------------------------------------------------------------
Expand All @@ -58,7 +58,7 @@ void CF_CFDP_R2_SetFinTxnStatus(CF_Transaction_t *txn, CF_TxnStatus_t txn_stat)
*-----------------------------------------------------------------*/
void CF_CFDP_R1_Reset(CF_Transaction_t *txn)
{
CF_CFDP_ResetTransaction(txn, 1);
CF_CFDP_ResetTransaction(txn, true);
}

/*----------------------------------------------------------------
Expand All @@ -78,7 +78,7 @@ void CF_CFDP_R2_Reset(CF_Transaction_t *txn)
else
{
/* not waiting for FIN ACK, so trigger send FIN */
txn->flags.rx.send_fin = 1;
txn->flags.rx.send_fin = true;
}
}

Expand All @@ -100,7 +100,7 @@ CFE_Status_t CF_CFDP_R_CheckCrc(CF_Transaction_t *txn, uint32 expected_crc)
(unsigned long)txn->history->seq_num, (unsigned long)txn->crc.result,
(unsigned long)expected_crc);
++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.crc_mismatch;
ret = 1;
ret = CF_ERROR;
}

return ret;
Expand All @@ -115,8 +115,8 @@ CFE_Status_t CF_CFDP_R_CheckCrc(CF_Transaction_t *txn, uint32 expected_crc)
void CF_CFDP_R2_Complete(CF_Transaction_t *txn, int ok_to_send_nak)
{
uint32 ret;
int send_nak = 0;
int send_fin = 0;
int send_nak = false;
int send_fin = false;
/* 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 @@ -125,7 +125,7 @@ void CF_CFDP_R2_Complete(CF_Transaction_t *txn, int ok_to_send_nak)
/* first, check if md is received. If not, send specialized NAK */
if (!txn->flags.rx.md_recv)
{
send_nak = 1;
send_nak = true;
}
else
{
Expand All @@ -135,12 +135,12 @@ void CF_CFDP_R2_Complete(CF_Transaction_t *txn, int ok_to_send_nak)
if (ret)
{
/* there is at least 1 gap, so send a NAK */
send_nak = 1;
send_nak = true;
}
else if (txn->flags.rx.eof_recv)
{
/* the EOF was received, and there are no NAKs -- process completion in send FIN state */
send_fin = 1;
send_fin = true;
}
}

Expand All @@ -155,21 +155,21 @@ void CF_CFDP_R2_Complete(CF_Transaction_t *txn, int ok_to_send_nak)
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_NAK_LIMIT, CFE_EVS_EventType_ERROR,
"CF R%d(%lu:%lu): NAK limited reach", (txn->state == CF_TxnState_R2),
(unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num);
send_fin = 1;
send_fin = true;
++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.nak_limit;
/* don't use CF_CFDP_R2_SetFinTxnStatus because many places in this function set send_fin */
CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_NAK_LIMIT_REACHED);
txn->state_data.receive.r2.acknak_count = 0; /* reset for fin/ack */
}
else
{
txn->flags.rx.send_nak = 1;
txn->flags.rx.send_nak = true;
}
}

if (send_fin)
{
txn->flags.rx.complete = 1; /* latch completeness, since send_fin is cleared later */
txn->flags.rx.complete = true; /* latch completeness, since send_fin is cleared later */

/* the transaction is now considered complete, but this will not overwrite an
* error status code if there was one set */
Expand Down Expand Up @@ -333,15 +333,15 @@ void CF_CFDP_R2_SubstateRecvEof(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *p
{
eof = &ph->int_header.eof;

txn->flags.rx.eof_recv = 1;
txn->flags.rx.eof_recv = true;

/* need to remember the EOF CRC for later */
txn->state_data.receive.r2.eof_crc = eof->crc;
txn->state_data.receive.r2.eof_size = eof->size;

/* always ACK the EOF, even if we're not done */
txn->state_data.receive.r2.eof_cc = eof->cc;
txn->flags.rx.send_ack = 1; /* defer sending ACK to tick handling */
txn->flags.rx.send_ack = true; /* defer sending ACK to tick handling */

/* only check for complete if EOF with no errors */
if (txn->state_data.receive.r2.eof_cc == CF_CFDP_ConditionCode_NO_ERROR)
Expand Down Expand Up @@ -511,15 +511,15 @@ CFE_Status_t CF_CFDP_R_SubstateSendNak(CF_Transaction_t *txn)
if (!cret)
{
/* no gaps left, so go ahead and check for completion */
txn->flags.rx.complete = 1; /* we know md was received, and there's no gaps -- it's complete */
txn->flags.rx.complete = true; /* we know md was received, and there's no gaps -- it's complete */
ret = CFE_SUCCESS;
}
else
{
/* gaps are present, so let's send the NAK PDU */
nak->scope_end = 0;
sret = CF_CFDP_SendNak(txn, ph);
txn->flags.rx.fd_nak_sent = 1; /* latch that at least one NAK has been sent requesting filedata */
txn->flags.rx.fd_nak_sent = true; /* latch that at least one NAK has been sent requesting filedata */
CF_Assert(sret != CF_SEND_PDU_ERROR); /* NOTE: this CF_Assert is here because CF_CFDP_SendNak()
does not return CF_SEND_PDU_ERROR, so if it's ever added to
that function we need to test handling it here */
Expand Down Expand Up @@ -689,7 +689,7 @@ CFE_Status_t CF_CFDP_R2_CalcCrcChunk(CF_Transaction_t *txn)
if (success && txn->state_data.receive.r2.rx_crc_calc_bytes == txn->fsize)
{
/* all bytes calculated, so now check */
if (!CF_CFDP_R_CheckCrc(txn, txn->state_data.receive.r2.eof_crc))
if (CF_CFDP_R_CheckCrc(txn, txn->state_data.receive.r2.eof_crc) == CFE_SUCCESS)
{
/* CRC matched! We are happy */
txn->keep = 1; /* save the file */
Expand All @@ -703,7 +703,7 @@ CFE_Status_t CF_CFDP_R2_CalcCrcChunk(CF_Transaction_t *txn)
CF_CFDP_R2_SetFinTxnStatus(txn, CF_TxnStatus_FILE_CHECKSUM_FAILURE);
}

txn->flags.com.crc_calc = 1;
txn->flags.com.crc_calc = true;

ret = CFE_SUCCESS;
}
Expand Down Expand Up @@ -855,7 +855,7 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
if (success)
{
txn->state_data.receive.cached_pos = 0; /* reset psn due to open */
txn->flags.rx.md_recv = 1;
txn->flags.rx.md_recv = true;
txn->state_data.receive.r2.acknak_count = 0; /* in case part of NAK */
CF_CFDP_R2_Complete(txn, 1); /* check for completion now that md is received */
}
Expand Down Expand Up @@ -927,7 +927,7 @@ void CF_CFDP_R_Cancel(CF_Transaction_t *txn)
/* for cancel, only need to send FIN if R2 */
if ((txn->state == CF_TxnState_R2) && (txn->state_data.receive.sub_state < CF_RxSubState_WAIT_FOR_FIN_ACK))
{
txn->flags.rx.send_fin = 1;
txn->flags.rx.send_fin = true;
}
else
{
Expand Down Expand Up @@ -975,7 +975,7 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */)
CF_CFDP_R_SendInactivityEvent(txn);

CF_CFDP_R2_SetFinTxnStatus(txn, CF_TxnStatus_INACTIVITY_DETECTED);
txn->flags.rx.inactivity_fired = 1;
txn->flags.rx.inactivity_fired = true;
}
else
{
Expand All @@ -994,21 +994,21 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */)
* CF_SEND_PDU_ERROR */
if (sret != CF_SEND_PDU_NO_BUF_AVAIL_ERROR)
{
txn->flags.rx.send_ack = 0;
txn->flags.rx.send_ack = false;
}
}
else if (txn->flags.rx.send_nak)
{
if (!CF_CFDP_R_SubstateSendNak(txn))
{
txn->flags.rx.send_nak = 0; /* will re-enter on error */
txn->flags.rx.send_nak = false; /* will re-enter on error */
}
}
else if (txn->flags.rx.send_fin)
{
if (!CF_CFDP_R2_SubstateSendFin(txn))
{
txn->flags.rx.send_fin = 0; /* will re-enter on error */
txn->flags.rx.send_fin = false; /* will re-enter on error */
}
}
else
Expand Down Expand Up @@ -1044,7 +1044,7 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */)
}
else
{
txn->flags.rx.send_fin = 1;
txn->flags.rx.send_fin = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_cfdp_r.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void CF_CFDP_R2_Reset(CF_Transaction_t *txn);
* txn must not be NULL.
*
*
* @retval CFE_SUCCESS on CRC match, otherwise error.
* @retval CFE_SUCCESS on CRC match, otherwise CF_ERROR.
*
*
* @param txn Pointer to the transaction object
Expand Down
Loading

0 comments on commit 9a68476

Please sign in to comment.