Skip to content

Commit

Permalink
Fix #390, Update size variables to size_t and CF_ChunkSize_t type…
Browse files Browse the repository at this point in the history
…defs
  • Loading branch information
thnkslprpt committed Jan 14, 2024
1 parent ab17422 commit 5f768d4
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions fsw/src/cf_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg)
* See description in cf_cmd.h for argument/return detail
*
*-----------------------------------------------------------------*/
CF_ChanAction_Status_t CF_CmdValidateChunkSize(uint32 val, uint8 chan_num /* ignored */)
CF_ChanAction_Status_t CF_CmdValidateChunkSize(CF_ChunkSize_t val, uint8 chan_num /* ignored */)
{
CF_ChanAction_Status_t ret = CF_ChanAction_Status_SUCCESS;
if (val > sizeof(CF_CFDP_PduFileDataContent_t))
Expand Down Expand Up @@ -989,7 +989,7 @@ void CF_GetSetParamCmd(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value,
struct
{
void * ptr;
uint32 size;
size_t size;
CF_ChanAction_Status_t (*fn)(uint32, uint8 chan_num);
} item;

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 @@ -524,7 +524,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg);
* @retval CF_ChanAction_Status_ERROR if failed (val is greater than max PDU)
*
*/
CF_ChanAction_Status_t CF_CmdValidateChunkSize(uint32 val, uint8 chan_num);
CF_ChanAction_Status_t CF_CmdValidateChunkSize(CF_ChunkSize_t val, uint8 chan_num);

/************************************************************************/
/** @brief Checks if the value is within allowable range as outgoing packets per wakeup
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/cf_crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ void CF_CRC_Start(CF_Crc_t *crc)
* See description in cf_crc.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CRC_Digest(CF_Crc_t *crc, const uint8 *data, int len)
void CF_CRC_Digest(CF_Crc_t *crc, const uint8 *data, size_t len)

Check notice

Code scanning / CodeQL

Long function without assertion Note

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

for (; i < len; ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_crc.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void CF_CRC_Start(CF_Crc_t *crc);
* @param len Length of data to digest
*
*/
void CF_CRC_Digest(CF_Crc_t *crc, const uint8 *data, int len);
void CF_CRC_Digest(CF_Crc_t *crc, const uint8 *data, size_t len);

/************************************************************************/
/** @brief Finalize a CRC calculation.
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ CFE_Status_t CF_WriteHistoryEntryToFile(osal_id_t fd, const CF_History_t *histor

int i;
CFE_Status_t ret;
int32 len;
size_t len;
char linebuf[(CF_FILENAME_MAX_LEN * 2) + 128]; /* buffer for line data */

for (i = 0; i < 3; ++i)
Expand Down
4 changes: 2 additions & 2 deletions unit-test/cf_cmd_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3304,7 +3304,7 @@ void Test_CF_CmdValidateChunkSize_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1(
{
/* Arrange */
uint8 arg_chan_num = Any_uint8(); /* value labeled as 'ignored' in func def */
uint32 arg_val = sizeof(CF_CFDP_PduFileDataContent_t) + 1;
size_t arg_val = sizeof(CF_CFDP_PduFileDataContent_t) + 1;
CF_ChanAction_Status_t local_result;

/* Act */
Expand Down Expand Up @@ -3332,7 +3332,7 @@ void Test_CF_CmdValidateChunkSize_val_SizeOf_pdu_fd_data_t_SuccessAndReturn_0(vo
{
/* Arrange */
uint8 arg_chan_num = Any_uint8(); /* value labeled as 'ignored' in func def */
uint32 arg_val = sizeof(CF_CFDP_PduFileDataContent_t);
size_t arg_val = sizeof(CF_CFDP_PduFileDataContent_t);
CF_ChanAction_Status_t local_result;

/* Act */
Expand Down
4 changes: 2 additions & 2 deletions unit-test/stubs/cf_cmd_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ void CF_CmdCancel_Txn(CF_Transaction_t *txn, void *ignored)
* Generated stub function for CF_CmdValidateChunkSize()
* ----------------------------------------------------
*/
CF_ChanAction_Status_t CF_CmdValidateChunkSize(uint32 val, uint8 chan_num)
CF_ChanAction_Status_t CF_CmdValidateChunkSize(CF_ChunkSize_t val, uint8 chan_num)
{
UT_GenStub_SetupReturnBuffer(CF_CmdValidateChunkSize, CF_ChanAction_Status_t);

UT_GenStub_AddParam(CF_CmdValidateChunkSize, uint32, val);
UT_GenStub_AddParam(CF_CmdValidateChunkSize, CF_ChunkSize_t, val);
UT_GenStub_AddParam(CF_CmdValidateChunkSize, uint8, chan_num);

UT_GenStub_Execute(CF_CmdValidateChunkSize, Basic, NULL);
Expand Down
4 changes: 2 additions & 2 deletions unit-test/stubs/cf_crc_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
* Generated stub function for CF_CRC_Digest()
* ----------------------------------------------------
*/
void CF_CRC_Digest(CF_Crc_t *crc, const uint8 *data, int len)
void CF_CRC_Digest(CF_Crc_t *crc, const uint8 *data, size_t len)
{
UT_GenStub_AddParam(CF_CRC_Digest, CF_Crc_t *, crc);
UT_GenStub_AddParam(CF_CRC_Digest, const uint8 *, data);
UT_GenStub_AddParam(CF_CRC_Digest, int, len);
UT_GenStub_AddParam(CF_CRC_Digest, size_t, len);

UT_GenStub_Execute(CF_CRC_Digest, Basic, NULL);
}
Expand Down

0 comments on commit 5f768d4

Please sign in to comment.