Skip to content

Commit

Permalink
[nasa/nos3#176] Change from bools to int32 across the entire applicat…
Browse files Browse the repository at this point in the history
…ion;
  • Loading branch information
jlucas9 committed Jul 23, 2024
1 parent 659e972 commit 1427a22
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 73 deletions.
2 changes: 1 addition & 1 deletion fsw/src/ds_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

#include <stdio.h>

bool DS_VerifyLength(const CFE_SB_Buffer_t *BufPtr, size_t ExpectedLength, uint16 FailEventID, const char *CommandName)
int32 DS_VerifyLength(const CFE_SB_Buffer_t *BufPtr, size_t ExpectedLength, uint16 FailEventID, const char *CommandName)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
size_t ActualLength = 0;

Expand Down
10 changes: 5 additions & 5 deletions fsw/src/ds_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
/* Apply common filter algorithm to Software Bus packet */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
int32 DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.

Check notice

Code scanning / CodeQL

Function too long Note

DS_IsPacketFiltered has too many lines (124, while 60 are allowed).
uint16 Algorithm_O)
{
/*
** Algorithm_N = the filter will pass this many packets
** Algorithm_X = out of every group of this many packets
** Algorithm_O = starting at this offset within the group
*/
bool PacketIsFiltered = false;
int32 PacketIsFiltered = false;
CFE_TIME_SysTime_t PacketTime;
uint16 PacketValue;
uint16 Seconds;
Expand Down Expand Up @@ -188,8 +188,8 @@ void DS_FileStorePacket(CFE_SB_MsgId_t MessageID, const CFE_SB_Buffer_t *BufPtr)
{
DS_PacketEntry_t *PacketEntry = NULL;
DS_FilterParms_t *FilterParms = NULL;
bool PassedFilter = false;
bool FilterResult = false;
int32 PassedFilter = false;
int32 FilterResult = false;
int32 FilterIndex = 0;
int32 FileIndex = 0;
int32 i = 0;
Expand Down Expand Up @@ -271,7 +271,7 @@ void DS_FileSetupWrite(int32 FileIndex, const CFE_SB_Buffer_t *BufPtr)
{
DS_DestFileEntry_t *DestFile = &DS_AppData.DestFileTblPtr->File[FileIndex];
DS_AppFileStatus_t *FileStatus = &DS_AppData.FileStatus[FileIndex];
bool OpenNewFile = false;
int32 OpenNewFile = false;
size_t PacketLength = 0;

/*
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/ds_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void DS_FileTransmit(DS_AppFileStatus_t *FileStatus);
* \retval true The packet should be filtered (not used)
* \retval false The packet should not be filtered (used)
*/
bool DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
int32 DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
uint16 Algorithm_O);

#endif
44 changes: 22 additions & 22 deletions fsw/src/ds_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ CFE_Status_t DS_TableInit(void)
{
CFE_Status_t Result1;
CFE_Status_t Result2;
bool NeedToLoadDestTable = false;
bool NeedToLoadFilterTable = false;
int32 NeedToLoadDestTable = false;
int32 NeedToLoadFilterTable = false;
uint16 TableRegisterFlags = CFE_TBL_OPT_SNGL_BUFFER | CFE_TBL_OPT_LOAD_DUMP;

if (DS_MAKE_TABLES_CRITICAL == 1)
Expand Down Expand Up @@ -441,10 +441,10 @@ CFE_Status_t DS_TableVerifyDestFile(const void *TableData)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyDestFileEntry(DS_DestFileEntry_t *DestFileEntry, uint8 TableIndex, int32 ErrorCount)
int32 DS_TableVerifyDestFileEntry(DS_DestFileEntry_t *DestFileEntry, uint8 TableIndex, int32 ErrorCount)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.

Check notice

Code scanning / CodeQL

Function too long Note

DS_TableVerifyDestFileEntry has too many lines (63, while 60 are allowed).
{
const char *CommonErrorText = "Destination file table verify err:";
bool Result = true;
int32 Result = true;

/*
** Perform the following "per table entry" validation:
Expand Down Expand Up @@ -563,11 +563,11 @@ CFE_Status_t DS_TableVerifyFilter(const void *TableData)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex, int32 ErrorCount)
int32 DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex, int32 ErrorCount)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.

Check notice

Code scanning / CodeQL

Function too long Note

DS_TableVerifyFilterEntry has too many lines (70, while 60 are allowed).
{
const char * CommonErrorText = "Filter table verify err:";
DS_FilterParms_t *FilterParms;
bool Result = true;
int32 Result = true;
int32 i = 0;

/*
Expand Down Expand Up @@ -640,10 +640,10 @@ bool DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex,
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableEntryUnused(const void *TableEntry, int32 BufferSize)
int32 DS_TableEntryUnused(const void *TableEntry, int32 BufferSize)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
const char *Buffer = (char *)TableEntry;
bool Result = true;
int32 Result = true;
int32 i = 0;

for (i = 0; i < BufferSize; i++)
Expand All @@ -664,9 +664,9 @@ bool DS_TableEntryUnused(const void *TableEntry, int32 BufferSize)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyFileIndex(uint16 FileTableIndex)
int32 DS_TableVerifyFileIndex(uint16 FileTableIndex)
{
bool Result = true;
int32 Result = true;

if (FileTableIndex >= DS_DEST_FILE_CNT)
{
Expand All @@ -682,9 +682,9 @@ bool DS_TableVerifyFileIndex(uint16 FileTableIndex)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorithm_O)
int32 DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorithm_O)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
bool Result = true;
int32 Result = true;

/*
** Unused entries (all zero's) are valid
Expand Down Expand Up @@ -716,9 +716,9 @@ bool DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorith
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyType(uint16 TimeVsCount)
int32 DS_TableVerifyType(uint16 TimeVsCount)
{
bool Result = true;
int32 Result = true;

if ((TimeVsCount != DS_BY_COUNT) && (TimeVsCount != DS_BY_TIME))
{
Expand All @@ -734,9 +734,9 @@ bool DS_TableVerifyType(uint16 TimeVsCount)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyState(uint16 EnableState)
int32 DS_TableVerifyState(uint16 EnableState)
{
bool Result = true;
int32 Result = true;

if ((EnableState != DS_ENABLED) && (EnableState != DS_DISABLED))
{
Expand All @@ -752,9 +752,9 @@ bool DS_TableVerifyState(uint16 EnableState)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifySize(uint32 MaxFileSize)
int32 DS_TableVerifySize(uint32 MaxFileSize)
{
bool Result = true;
int32 Result = true;

if (MaxFileSize < DS_FILE_MIN_SIZE_LIMIT)
{
Expand All @@ -770,9 +770,9 @@ bool DS_TableVerifySize(uint32 MaxFileSize)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyAge(uint32 MaxFileAge)
int32 DS_TableVerifyAge(uint32 MaxFileAge)
{
bool Result = true;
int32 Result = true;

if (MaxFileAge < DS_FILE_MIN_AGE_LIMIT)
{
Expand All @@ -788,9 +788,9 @@ bool DS_TableVerifyAge(uint32 MaxFileAge)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyCount(uint32 SequenceCount)
int32 DS_TableVerifyCount(uint32 SequenceCount)
{
bool Result = true;
int32 Result = true;

if (SequenceCount > DS_MAX_SEQUENCE_COUNT)
{
Expand Down
20 changes: 10 additions & 10 deletions fsw/src/ds_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ CFE_Status_t DS_TableVerifyDestFile(const void *TableData);
*
* \sa #DS_DestFileEntry_t, #DS_TableVerifyDestFile
*/
bool DS_TableVerifyDestFileEntry(DS_DestFileEntry_t *DestFileEntry, uint8 TableIndex, int32 ErrorCount);
int32 DS_TableVerifyDestFileEntry(DS_DestFileEntry_t *DestFileEntry, uint8 TableIndex, int32 ErrorCount);

/**
* \brief Verify packet filter table data
Expand Down Expand Up @@ -208,7 +208,7 @@ CFE_Status_t DS_TableVerifyFilter(const void *TableData);
*
* \sa #DS_PacketEntry_t, #DS_FilterParms_t, #DS_TableVerifyFilter
*/
bool DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex, int32 ErrorCount);
int32 DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex, int32 ErrorCount);

/**
* \brief Test for unused table entry
Expand All @@ -229,7 +229,7 @@ bool DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex,
*
* \sa #DS_PacketEntry_t, #DS_FilterParms_t, #DS_DestFileEntry_t
*/
bool DS_TableEntryUnused(const void *TableEntry, int32 BufferSize);
int32 DS_TableEntryUnused(const void *TableEntry, int32 BufferSize);

/**
* \brief Verify destination file index
Expand Down Expand Up @@ -262,7 +262,7 @@ bool DS_TableEntryUnused(const void *TableEntry, int32 BufferSize);
*
* \sa #DS_PacketEntry_t, #DS_FilterParms_t, #DS_DestFileEntry_t
*/
bool DS_TableVerifyFileIndex(uint16 FileTableIndex);
int32 DS_TableVerifyFileIndex(uint16 FileTableIndex);

/**
* \brief Verify packet filter parameters
Expand All @@ -286,7 +286,7 @@ bool DS_TableVerifyFileIndex(uint16 FileTableIndex);
*
* \sa #DS_TableVerifyType, #DS_TableVerifyState, #DS_DestFileEntry_t
*/
bool DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorithm_O);
int32 DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorithm_O);

/**
* \brief Verify packet filter type or filename type
Expand All @@ -311,7 +311,7 @@ bool DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorith
*
* \sa #DS_TableVerifyState, #DS_TableVerifySize, #DS_DestFileEntry_t
*/
bool DS_TableVerifyType(uint16 TimeVsCount);
int32 DS_TableVerifyType(uint16 TimeVsCount);

/**
* \brief Verify application or destination file enable/disable state
Expand All @@ -333,7 +333,7 @@ bool DS_TableVerifyType(uint16 TimeVsCount);
*
* \sa #DS_TableVerifySize, #DS_TableVerifyAge, #DS_DestFileEntry_t
*/
bool DS_TableVerifyState(uint16 EnableState);
int32 DS_TableVerifyState(uint16 EnableState);

/**
* \brief Verify destination file max size limit
Expand All @@ -354,7 +354,7 @@ bool DS_TableVerifyState(uint16 EnableState);
*
* \sa #DS_TableVerifyAge, #DS_TableVerifyCount, #DS_DestFileEntry_t
*/
bool DS_TableVerifySize(uint32 MaxFileSize);
int32 DS_TableVerifySize(uint32 MaxFileSize);

/**
* \brief Verify destination file max age limit
Expand All @@ -375,7 +375,7 @@ bool DS_TableVerifySize(uint32 MaxFileSize);
*
* \sa #DS_TableVerifySize, #DS_TableVerifyCount, #DS_DestFileEntry_t
*/
bool DS_TableVerifyAge(uint32 MaxFileAge);
int32 DS_TableVerifyAge(uint32 MaxFileAge);

/**
* \brief Verify destination file sequence count
Expand All @@ -396,7 +396,7 @@ bool DS_TableVerifyAge(uint32 MaxFileAge);
*
* \sa #DS_TableVerifySize, #DS_TableVerifyAge, #DS_DestFileEntry_t
*/
bool DS_TableVerifyCount(uint32 SequenceCount);
int32 DS_TableVerifyCount(uint32 SequenceCount);

/**
* \brief Subscribe to packet filter table packets
Expand Down
6 changes: 3 additions & 3 deletions unit-test/stubs/ds_file_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ void DS_FileWriteHeader(int32 FileIndex)
* Generated stub function for DS_IsPacketFiltered()
* ----------------------------------------------------
*/
bool DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
int32 DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
uint16 Algorithm_O)
{
UT_GenStub_SetupReturnBuffer(DS_IsPacketFiltered, bool);
UT_GenStub_SetupReturnBuffer(DS_IsPacketFiltered, int32);

UT_GenStub_AddParam(DS_IsPacketFiltered, CFE_MSG_Message_t *, MessagePtr);
UT_GenStub_AddParam(DS_IsPacketFiltered, uint16, FilterType);
Expand All @@ -196,5 +196,5 @@ bool DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint1

UT_GenStub_Execute(DS_IsPacketFiltered, Basic, NULL);

return UT_GenStub_GetReturnValue(DS_IsPacketFiltered, bool);
return UT_GenStub_GetReturnValue(DS_IsPacketFiltered, int32);
}
Loading

0 comments on commit 1427a22

Please sign in to comment.