Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #113, Use size_t for size parameters and variables #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions fsw/src/ds_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

void DS_FileWriteData(int32 FileIndex, const void *FileData, uint32 DataLength)
void DS_FileWriteData(int32 FileIndex, const void *FileData, size_t DataLength)

Check notice

Code scanning / CodeQL-coding-standard

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
DS_AppFileStatus_t *FileStatus = &DS_AppData.FileStatus[FileIndex];
int32 Result;
Expand Down Expand Up @@ -450,7 +450,7 @@
/* 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_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 @@ -802,7 +802,7 @@
{
DS_AppFileStatus_t *FileStatus = &DS_AppData.FileStatus[FileIndex];
int32 OS_result;
int32 PathLength;
size_t PathLength;
char * FileName;
char PathName[DS_TOTAL_FNAME_BUFSIZE];

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 @@ -122,7 +122,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 @@ -163,7 +163,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 @@ -640,11 +640,11 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

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

Check notice

Code scanning / CodeQL-coding-standard

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 i = 0;
uint32 i;

for (i = 0; i < BufferSize; i++)
{
Expand Down Expand Up @@ -752,7 +752,7 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

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 @@ -332,7 +332,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 @@ -423,7 +423,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
Loading