Skip to content

Commit

Permalink
Fix nasa#12, Resolve strict cppcheck style warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed May 9, 2022
1 parent 408ff72 commit de32e04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 36 deletions.
21 changes: 3 additions & 18 deletions fsw/src/md_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,9 @@ void MD_ProcessStartCmd(const CFE_SB_Buffer_t *BufPtr)
int32 NumTblInMask = 0; /* Purely as info for event message */
uint16 TableId = 0;
uint16 TableIndex = 0;
MD_CmdStartStop_t *Start = NULL;
MD_CmdStartStop_t *Start = (MD_CmdStartStop_t *)BufPtr;
bool AnyTablesInMask = false;

/*
** Cast message to StartStop Command.
*/
Start = (MD_CmdStartStop_t *)BufPtr;

/* Preview tables specified by command: */
/* Check that there's at least one valid table specified. */
for (TableId = 1; TableId <= MD_NUM_DWELL_TABLES; TableId++)
Expand Down Expand Up @@ -138,16 +133,11 @@ void MD_ProcessStopCmd(const CFE_SB_Buffer_t *BufPtr)
int32 ErrorCount = 0;
int32 Status = CFE_SUCCESS;
int32 NumTblInMask = 0; /* Purely as info for event message */
MD_CmdStartStop_t *Stop = NULL;
MD_CmdStartStop_t *Stop = (MD_CmdStartStop_t *)BufPtr;
uint16 TableId = 0;
uint16 TableIndex = 0;
bool AnyTablesInMask = false;

/*
** Cast message to StartStop Command.
*/
Stop = (MD_CmdStartStop_t *)BufPtr;

for (TableId = 1; TableId <= MD_NUM_DWELL_TABLES; TableId++)
{
if (MD_TableIsInMask(TableId, Stop->TableMask))
Expand Down Expand Up @@ -418,15 +408,10 @@ void MD_ProcessJamCmd(const CFE_SB_Buffer_t *BufPtr)
void MD_ProcessSignatureCmd(const CFE_SB_Buffer_t *BufPtr)
{
int32 Status = CFE_SUCCESS;
MD_CmdSetSignature_t *SignatureCmd = NULL;
MD_CmdSetSignature_t *SignatureCmd = (MD_CmdSetSignature_t *)BufPtr;
uint16 TblId = 0;
uint16 StringLength;

/*
** Cast message to Signature Command.
*/
SignatureCmd = (MD_CmdSetSignature_t *)BufPtr;

TblId = SignatureCmd->TableId;

/*
Expand Down
13 changes: 5 additions & 8 deletions fsw/src/md_dwell_pkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,11 @@ void MD_DwellLoop(void)

int32 MD_GetDwellData(uint16 TblIndex, uint16 EntryIndex)
{
uint8 NumBytes = 0; /* Num of bytes to read */
uint32 MemReadVal = 0; /* 1-, 2-, or 4-byte value */
MD_DwellPacketControl_t *TblPtr = NULL; /* Points to table struct */
cpuaddr DwellAddress; /* dwell address */
int32 Status = CFE_SUCCESS;

/* Initialize pointer to current table */
TblPtr = (MD_DwellPacketControl_t *)&MD_AppData.MD_DwellTables[TblIndex];
uint8 NumBytes = 0; /* Num of bytes to read */
uint32 MemReadVal = 0; /* 1-, 2-, or 4-byte value */
MD_DwellPacketControl_t *TblPtr = &MD_AppData.MD_DwellTables[TblIndex];
int32 Status = CFE_SUCCESS;
cpuaddr DwellAddress; /* dwell address */

/* How many bytes to read?*/
NumBytes = TblPtr->Entry[EntryIndex].Length;
Expand Down
17 changes: 7 additions & 10 deletions fsw/src/md_dwell_tbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,10 @@ void MD_CopyUpdatedTbl(MD_DwellTableLoad_t *MD_LoadTablePtr, uint8 TblIndex)
uint8 EntryIndex;
cpuaddr ResolvedAddr = 0;
MD_TableLoadEntry_t * ThisLoadEntry = NULL;
MD_DwellPacketControl_t *LocalControlStruct = NULL;
MD_DwellPacketControl_t *LocalControlStruct = &MD_AppData.MD_DwellTables[TblIndex];

/* Null check on MD_LoadTablePtr not necessary - table passed validation */

/* Assign pointer to internal control structure. */
LocalControlStruct = &MD_AppData.MD_DwellTables[TblIndex];

/* Copy 'Enabled' field from load structure to internal control structure. */
LocalControlStruct->Enabled = MD_LoadTablePtr->Enabled;

Expand Down Expand Up @@ -351,9 +348,9 @@ void MD_CopyUpdatedTbl(MD_DwellTableLoad_t *MD_LoadTablePtr, uint8 TblIndex)
/******************************************************************************/
int32 MD_UpdateTableEnabledField(uint16 TableIndex, uint16 FieldValue)
{
int32 Status = CFE_SUCCESS;
int32 GetAddressResult = CFE_SUCCESS;
MD_DwellTableLoad_t *MD_LoadTablePtr = NULL;
int32 Status = CFE_SUCCESS;
MD_DwellTableLoad_t *MD_LoadTablePtr = NULL;
int32 GetAddressResult;

GetAddressResult = CFE_TBL_GetAddress((void *)&MD_LoadTablePtr, MD_AppData.MD_TableHandle[TableIndex]);

Expand Down Expand Up @@ -431,9 +428,9 @@ int32 MD_UpdateTableDwellEntry(uint16 TableIndex, uint16 EntryIndex, uint16 NewL

int32 MD_UpdateTableSignature(uint16 TableIndex, char NewSignature[MD_SIGNATURE_FIELD_LENGTH])
{
int32 Status = CFE_SUCCESS;
int32 GetAddressResult = CFE_SUCCESS;
MD_DwellTableLoad_t *MD_LoadTablePtr = NULL;
int32 Status = CFE_SUCCESS;
MD_DwellTableLoad_t *MD_LoadTablePtr = NULL;
int32 GetAddressResult;

/* Get pointer to Table */
GetAddressResult = CFE_TBL_GetAddress((void *)&MD_LoadTablePtr, MD_AppData.MD_TableHandle[TableIndex]);
Expand Down

0 comments on commit de32e04

Please sign in to comment.