Skip to content

Commit

Permalink
Fix #113, Use size_t for size parameters and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Jun 15, 2023
1 parent 2a6c6a2 commit e4be2f2
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
18 changes: 9 additions & 9 deletions fsw/src/ds_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void DS_FileSetupWrite(int32 FileIndex, const CFE_SB_Buffer_t *BufPtr)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

void DS_FileWriteData(int32 FileIndex, const void *FileData, uint32 DataLength)
void DS_FileWriteData(int32 FileIndex, const void *FileData, size_t DataLength)
{
DS_AppFileStatus_t *FileStatus = &DS_AppData.FileStatus[FileIndex];
int32 Result;
Expand Down Expand Up @@ -450,7 +450,7 @@ void DS_FileWriteHeader(int32 FileIndex)
/* File write error handler */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void DS_FileWriteError(uint32 FileIndex, uint32 DataLength, int32 WriteResult)
void DS_FileWriteError(uint32 FileIndex, size_t DataLength, int32 WriteResult)
{
DS_AppFileStatus_t *FileStatus = &DS_AppData.FileStatus[FileIndex];

Expand Down Expand Up @@ -552,9 +552,9 @@ void DS_FileCreateDest(uint32 FileIndex)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void DS_FileCreateName(uint32 FileIndex)
{
DS_DestFileEntry_t *DestFile = &DS_AppData.DestFileTblPtr->File[FileIndex];
DS_AppFileStatus_t *FileStatus = &DS_AppData.FileStatus[FileIndex];
int32 TotalLength = 0;
DS_DestFileEntry_t *DestFile = &DS_AppData.DestFileTblPtr->File[FileIndex];
DS_AppFileStatus_t *FileStatus = &DS_AppData.FileStatus[FileIndex];
size_t TotalLength;

char Workname[2 * DS_TOTAL_FNAME_BUFSIZE];
char Sequence[DS_TOTAL_FNAME_BUFSIZE];
Expand Down Expand Up @@ -805,10 +805,10 @@ void DS_FileCloseDest(int32 FileIndex)
/*
** Move file from working directory to downlink directory...
*/
int32 OS_result;
int32 PathLength;
char *FileName;
char PathName[DS_TOTAL_FNAME_BUFSIZE];
int32 OS_result;
size_t PathLength;
char * FileName;
char PathName[DS_TOTAL_FNAME_BUFSIZE];

/*
** First, close the file...
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/ds_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void DS_FileSetupWrite(int32 FileIndex, const CFE_SB_Buffer_t *BufPtr);
*
* \sa #DS_AppFileStatus_t, #DS_DestFileEntry_t
*/
void DS_FileWriteData(int32 FileIndex, const void *FileData, uint32 DataLength);
void DS_FileWriteData(int32 FileIndex, const void *FileData, size_t DataLength);

/**
* \brief Write data storage file header
Expand Down Expand Up @@ -165,7 +165,7 @@ void DS_FileWriteHeader(int32 FileIndex);
* \param[in] DataLength Length of data being written to file
* \param[in] WriteResult Result of file write
*/
void DS_FileWriteError(uint32 FileIndex, uint32 DataLength, int32 WriteResult);
void DS_FileWriteError(uint32 FileIndex, size_t DataLength, int32 WriteResult);

/**
* \brief Create a new data storage destination file
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/ds_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,11 @@ bool DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex,
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableEntryUnused(const void *TableEntry, int32 BufferSize)
bool DS_TableEntryUnused(const void *TableEntry, size_t BufferSize)
{
const char *Buffer = (char *)TableEntry;
bool Result = true;
int32 i = 0;
uint32 i;

for (i = 0; i < BufferSize; i++)
{
Expand Down Expand Up @@ -751,7 +751,7 @@ bool DS_TableVerifyState(uint16 EnableState)
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

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

Expand Down
4 changes: 2 additions & 2 deletions fsw/src/ds_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
bool DS_TableEntryUnused(const void *TableEntry, size_t BufferSize);

/**
* \brief Verify destination file index
Expand Down Expand Up @@ -354,7 +354,7 @@ bool DS_TableVerifyState(uint16 EnableState);
*
* \sa #DS_TableVerifyAge, #DS_TableVerifyCount, #DS_DestFileEntry_t
*/
bool DS_TableVerifySize(uint32 MaxFileSize);
bool DS_TableVerifySize(size_t MaxFileSize);

/**
* \brief Verify destination file max age limit
Expand Down
4 changes: 2 additions & 2 deletions unit-test/ds_file_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void DS_FileWriteData_Test_Nominal(void)
void DS_FileWriteData_Test_Error(void)
{
int32 FileIndex = 0;
uint32 DataLength = 10;
size_t DataLength = 10;

size_t forced_Size = sizeof(DS_NoopCmd_t);
CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID);
Expand Down Expand Up @@ -433,7 +433,7 @@ void DS_FileWriteHeader_Test_SecondaryHeaderError(void)
void DS_FileWriteError_Test(void)
{
int32 FileIndex = 0;
uint32 DataLength = 10;
size_t DataLength = 10;
int32 WriteResult = -1;

/* Set up the handle */
Expand Down
4 changes: 2 additions & 2 deletions unit-test/ds_table_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ void DS_TableVerifyState_Test_Fail(void)

void DS_TableVerifySize_Test_Nominal(void)
{
uint32 MaxFileSize = DS_FILE_MIN_SIZE_LIMIT;
size_t MaxFileSize = DS_FILE_MIN_SIZE_LIMIT;

/* Execute the function being tested */
UtAssert_BOOL_TRUE(DS_TableVerifySize(MaxFileSize));
Expand All @@ -1225,7 +1225,7 @@ void DS_TableVerifySize_Test_Nominal(void)

void DS_TableVerifySize_Test_Fail(void)
{
uint32 MaxFileSize = DS_FILE_MIN_SIZE_LIMIT - 1;
size_t MaxFileSize = DS_FILE_MIN_SIZE_LIMIT - 1;

/* Execute the function being tested */
UtAssert_BOOL_FALSE(DS_TableVerifySize(MaxFileSize));
Expand Down
8 changes: 4 additions & 4 deletions unit-test/stubs/ds_file_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ void DS_FileUpdateHeader(int32 FileIndex)
* Generated stub function for DS_FileWriteData()
* ----------------------------------------------------
*/
void DS_FileWriteData(int32 FileIndex, const void *FileData, uint32 DataLength)
void DS_FileWriteData(int32 FileIndex, const void *FileData, size_t DataLength)
{
UT_GenStub_AddParam(DS_FileWriteData, int32, FileIndex);
UT_GenStub_AddParam(DS_FileWriteData, const void *, FileData);
UT_GenStub_AddParam(DS_FileWriteData, uint32, DataLength);
UT_GenStub_AddParam(DS_FileWriteData, size_t, DataLength);

UT_GenStub_Execute(DS_FileWriteData, Basic, NULL);
}
Expand All @@ -157,10 +157,10 @@ void DS_FileWriteData(int32 FileIndex, const void *FileData, uint32 DataLength)
* Generated stub function for DS_FileWriteError()
* ----------------------------------------------------
*/
void DS_FileWriteError(uint32 FileIndex, uint32 DataLength, int32 WriteResult)
void DS_FileWriteError(uint32 FileIndex, size_t DataLength, int32 WriteResult)
{
UT_GenStub_AddParam(DS_FileWriteError, uint32, FileIndex);
UT_GenStub_AddParam(DS_FileWriteError, uint32, DataLength);
UT_GenStub_AddParam(DS_FileWriteError, size_t, DataLength);
UT_GenStub_AddParam(DS_FileWriteError, int32, WriteResult);

UT_GenStub_Execute(DS_FileWriteError, Basic, NULL);
Expand Down
8 changes: 4 additions & 4 deletions unit-test/stubs/ds_table_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ void DS_TableCreateHash(void)
* Generated stub function for DS_TableEntryUnused()
* ----------------------------------------------------
*/
bool DS_TableEntryUnused(const void *TableEntry, int32 BufferSize)
bool DS_TableEntryUnused(const void *TableEntry, size_t BufferSize)
{
UT_GenStub_SetupReturnBuffer(DS_TableEntryUnused, bool);

UT_GenStub_AddParam(DS_TableEntryUnused, const void *, TableEntry);
UT_GenStub_AddParam(DS_TableEntryUnused, int32, BufferSize);
UT_GenStub_AddParam(DS_TableEntryUnused, size_t, BufferSize);

UT_GenStub_Execute(DS_TableEntryUnused, Basic, NULL);

Expand Down Expand Up @@ -325,11 +325,11 @@ bool DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorith
* Generated stub function for DS_TableVerifySize()
* ----------------------------------------------------
*/
bool DS_TableVerifySize(uint32 MaxFileSize)
bool DS_TableVerifySize(size_t MaxFileSize)
{
UT_GenStub_SetupReturnBuffer(DS_TableVerifySize, bool);

UT_GenStub_AddParam(DS_TableVerifySize, uint32, MaxFileSize);
UT_GenStub_AddParam(DS_TableVerifySize, size_t, MaxFileSize);

UT_GenStub_Execute(DS_TableVerifySize, Basic, NULL);

Expand Down

0 comments on commit e4be2f2

Please sign in to comment.