From 4068927becdd1919819c366652b6f0fb719711cf Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Tue, 13 Jun 2023 11:47:05 +1000 Subject: [PATCH] Fix #390, Update size variables to `size_t` and `CF_ChunkSize_t` typedefs --- fsw/src/cf_cfdp_types.h | 2 +- fsw/src/cf_cmd.c | 4 ++-- fsw/src/cf_cmd.h | 2 +- fsw/src/cf_crc.c | 4 ++-- fsw/src/cf_crc.h | 2 +- fsw/src/cf_utils.c | 2 +- unit-test/cf_cmd_tests.c | 4 ++-- unit-test/stubs/cf_cmd_stubs.c | 4 ++-- unit-test/stubs/cf_crc_stubs.c | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fsw/src/cf_cfdp_types.h b/fsw/src/cf_cfdp_types.h index a4d9c85a..1b383f0a 100644 --- a/fsw/src/cf_cfdp_types.h +++ b/fsw/src/cf_cfdp_types.h @@ -250,7 +250,7 @@ typedef struct CF_TxState_Data typedef struct CF_RxS2_Data { uint32 eof_crc; - uint32 eof_size; + size_t eof_size; uint32 rx_crc_calc_bytes; CF_CFDP_FinDeliveryCode_t dc; CF_CFDP_FinFileStatus_t fs; diff --git a/fsw/src/cf_cmd.c b/fsw/src/cf_cmd.c index da09e0d1..4b352d59 100644 --- a/fsw/src/cf_cmd.c +++ b/fsw/src/cf_cmd.c @@ -899,7 +899,7 @@ void CF_CmdWriteQueue(CFE_SB_Buffer_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -CFE_Status_t CF_CmdValidateChunkSize(uint32 val, uint8 chan_num /* ignored */) +CFE_Status_t CF_CmdValidateChunkSize(CF_ChunkSize_t val, uint8 chan_num /* ignored */) { CFE_Status_t ret = CFE_SUCCESS; if (val > sizeof(CF_CFDP_PduFileDataContent_t)) @@ -942,7 +942,7 @@ void CF_CmdGetSetParam(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value, struct { void * ptr; - uint32 size; + size_t size; int (*fn)(uint32, uint8 chan_num); } item; diff --git a/fsw/src/cf_cmd.h b/fsw/src/cf_cmd.h index 85148d44..0a1d6ca6 100644 --- a/fsw/src/cf_cmd.h +++ b/fsw/src/cf_cmd.h @@ -472,7 +472,7 @@ void CF_CmdWriteQueue(CFE_SB_Buffer_t *msg); * @retval CF_ERROR if failed (val is greater than max PDU) * */ -CFE_Status_t CF_CmdValidateChunkSize(uint32 val, uint8 chan_num); +CFE_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 diff --git a/fsw/src/cf_crc.c b/fsw/src/cf_crc.c index d8e6bfa1..97f4d1a4 100644 --- a/fsw/src/cf_crc.c +++ b/fsw/src/cf_crc.c @@ -50,9 +50,9 @@ void CF_CRC_Start(CF_Crc_t *c) * See description in cf_crc.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_CRC_Digest(CF_Crc_t *c, const uint8 *data, int len) +void CF_CRC_Digest(CF_Crc_t *c, const uint8 *data, size_t len) { - int i = 0; + uint32 i = 0; for (; i < len; ++i) { diff --git a/fsw/src/cf_crc.h b/fsw/src/cf_crc.h index fd1b862e..737539b9 100644 --- a/fsw/src/cf_crc.h +++ b/fsw/src/cf_crc.h @@ -63,7 +63,7 @@ void CF_CRC_Start(CF_Crc_t *c); * @param len Length of data to digest * */ -void CF_CRC_Digest(CF_Crc_t *c, const uint8 *data, int len); +void CF_CRC_Digest(CF_Crc_t *c, const uint8 *data, size_t len); /************************************************************************/ /** @brief Finalize a CRC calculation. diff --git a/fsw/src/cf_utils.c b/fsw/src/cf_utils.c index 89171407..16595474 100644 --- a/fsw/src/cf_utils.c +++ b/fsw/src/cf_utils.c @@ -174,7 +174,7 @@ CFE_Status_t CF_WriteHistoryEntryToFile(osal_id_t fd, const CF_History_t *h) 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) diff --git a/unit-test/cf_cmd_tests.c b/unit-test/cf_cmd_tests.c index f3d2e81f..940e5bef 100644 --- a/unit-test/cf_cmd_tests.c +++ b/unit-test/cf_cmd_tests.c @@ -3391,7 +3391,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; CFE_Status_t local_result; /* Act */ @@ -3421,7 +3421,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); CFE_Status_t local_result; /* Act */ diff --git a/unit-test/stubs/cf_cmd_stubs.c b/unit-test/stubs/cf_cmd_stubs.c index 4fff043e..125b11f7 100644 --- a/unit-test/stubs/cf_cmd_stubs.c +++ b/unit-test/stubs/cf_cmd_stubs.c @@ -302,11 +302,11 @@ void CF_CmdTxFile(CFE_SB_Buffer_t *msg) * Generated stub function for CF_CmdValidateChunkSize() * ---------------------------------------------------- */ -CFE_Status_t CF_CmdValidateChunkSize(uint32 val, uint8 chan_num) +CFE_Status_t CF_CmdValidateChunkSize(CF_ChunkSize_t val, uint8 chan_num) { UT_GenStub_SetupReturnBuffer(CF_CmdValidateChunkSize, CFE_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); diff --git a/unit-test/stubs/cf_crc_stubs.c b/unit-test/stubs/cf_crc_stubs.c index 148a29d9..d0889e7a 100644 --- a/unit-test/stubs/cf_crc_stubs.c +++ b/unit-test/stubs/cf_crc_stubs.c @@ -31,11 +31,11 @@ * Generated stub function for CF_CRC_Digest() * ---------------------------------------------------- */ -void CF_CRC_Digest(CF_Crc_t *c, const uint8 *data, int len) +void CF_CRC_Digest(CF_Crc_t *c, const uint8 *data, size_t len) { UT_GenStub_AddParam(CF_CRC_Digest, CF_Crc_t *, c); 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); }