Skip to content

Commit

Permalink
Fix #384, Update status variables (0, -1) to their defined macros
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed May 19, 2023
1 parent 4e97d3b commit 79f7e4e
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CodeQl Analysis
on:
push:
pull_request:


jobs:
codeql:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ jobs:
format-check:
name: Run format check
uses: nasa/cFS/.github/workflows/format-check.yml@main

2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
name: Run cppcheck
uses: nasa/cFS/.github/workflows/static-analysis.yml@main
with:
strict-dir-list: './fsw'
strict-dir-list: './fsw'
2 changes: 1 addition & 1 deletion fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ void CF_CFDP_ResetTransaction(CF_Transaction_t *t, int keep_history)
{
char * filename;
char destination[OS_MAX_PATH_LEN];
int32 status = -1;
osal_status_t status = OS_ERROR;
CF_Channel_t *c = &CF_AppData.engine.channels[t->chan_num];
CF_Assert(t->chan_num < CF_NUM_CHANNELS);

Expand Down
10 changes: 5 additions & 5 deletions fsw/src/cf_cfdp_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void CF_CFDP_R1_SubstateRecvEof(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
if (ret == CFE_SUCCESS)
{
/* Verify CRC */
if (CF_CFDP_R_CheckCrc(t, crc) == 0)
if (CF_CFDP_R_CheckCrc(t, crc) == CFE_SUCCESS)
{
/* successfully processed the file */
t->keep = 1; /* save the file */
Expand Down Expand Up @@ -381,12 +381,12 @@ void CF_CFDP_R1_SubstateRecvFileData(CF_Transaction_t *t, CF_Logical_PduBuffer_t

/* got file data PDU? */
ret = CF_CFDP_RecvFd(t, ph);
if (ret == 0)
if (ret == CFE_SUCCESS)
{
ret = CF_CFDP_R_ProcessFd(t, ph);
}

if (ret == 0)
if (ret == CFE_SUCCESS)
{
/* class 1 digests CRC */
CF_CRC_Digest(&t->crc, ph->int_header.fd.data_ptr, ph->int_header.fd.data_len);
Expand Down Expand Up @@ -414,12 +414,12 @@ void CF_CFDP_R2_SubstateRecvFileData(CF_Transaction_t *t, CF_Logical_PduBuffer_t

/* got file data PDU? */
ret = CF_CFDP_RecvFd(t, ph);
if (ret == 0)
if (ret == CFE_SUCCESS)
{
ret = CF_CFDP_R_ProcessFd(t, ph);
}

if (ret == 0)
if (ret == CFE_SUCCESS)
{
/* class 2 does CRC at FIN, but track gaps */
CF_ChunkListAdd(&t->chunks->chunks, fd->offset, fd->data_len);
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 @@ -497,7 +497,7 @@ void CF_CFDP_S2_Nak(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
/* this function is only invoked for NAK PDU types */
nak = &ph->int_header.nak;

if (CF_CFDP_RecvNak(t, ph) == 0 && nak->segment_list.num_segments > 0)
if (CF_CFDP_RecvNak(t, ph) == CFE_SUCCESS && nak->segment_list.num_segments > 0)
{
for (counter = 0; counter < nak->segment_list.num_segments; ++counter)
{
Expand Down
9 changes: 4 additions & 5 deletions fsw/src/cf_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ CFE_Status_t CF_CmdValidateMaxOutgoing(uint32 val, uint8 chan_num)
void CF_CmdGetSetParam(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num)
{
CF_ConfigTable_t *config;
int acc;
CFE_Status_t status = CF_ERROR;
bool valid_set;
struct
{
Expand All @@ -946,7 +946,6 @@ void CF_CmdGetSetParam(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value,
int (*fn)(uint32, uint8 chan_num);
} item;

acc = -1; /* -1 means to reject */
valid_set = false;
config = CF_AppData.config_table;
memset(&item, 0, sizeof(item));
Expand Down Expand Up @@ -1030,7 +1029,7 @@ void CF_CmdGetSetParam(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value,

if (valid_set)
{
acc = 0;
status = CFE_SUCCESS;

CFE_EVS_SendEvent(CF_EID_INF_CMD_GETSET1, CFE_EVS_EventType_INFORMATION,
"CF: setting parameter id %d to %lu", param_id, (unsigned long)value);
Expand All @@ -1053,7 +1052,7 @@ void CF_CmdGetSetParam(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value,
}
else
{
acc = 0;
status = CFE_SUCCESS;

/* Read value depending on its size */
if (item.size == sizeof(uint32))
Expand All @@ -1074,7 +1073,7 @@ void CF_CmdGetSetParam(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value,
(unsigned long)value);
}

if (acc == 0)
if (status == CFE_SUCCESS)
{
++CF_AppData.HkPacket.CommandCounter;
}
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ CFE_Status_t CF_CmdValidateChunkSize(uint32 val, uint8 chan_num);
* @retval CF_ERROR if failed (val is not allowed)
*
*/
int CF_CmdValidateMaxOutgoing(uint32 val, uint8 chan_num);
CFE_Status_t CF_CmdValidateMaxOutgoing(uint32 val, uint8 chan_num);

/************************************************************************/
/** @brief Perform a configuration get/set operation.
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ CFE_Status_t CF_TraverseAllTransactions(CF_Channel_t *c, CF_TraverseAllTransacti
*
* @returns Number of transactions traversed
*/
int CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, void *context);
CFE_Status_t CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, void *context);

/************************************************************************/
/** @brief List traversal function performs operation on every active transaction.
Expand Down
Loading

0 comments on commit 79f7e4e

Please sign in to comment.