Skip to content

Commit

Permalink
Merge pull request #2376 from thnkslprpt:fix-2375-use-size-t-for-size…
Browse files Browse the repository at this point in the history
…-variables-and-parameters

Fix #2375, Use size_t for variables/parameters representing size
  • Loading branch information
dzbaker committed Jul 1, 2024
2 parents cb2762e + 99eb3c3 commit 6059459
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions modules/cfe_testcase/src/tbl_content_mang_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ void TblTest_GenerateTblFiles(void)
{
osal_id_t fh1 = OS_OBJECT_ID_UNDEFINED;
osal_id_t fh2 = OS_OBJECT_ID_UNDEFINED;
uint32 PartialOffset;
uint32 PartialSize;
size_t PartialOffset;
size_t PartialSize;
union
{
uint8 u8;
Expand Down
6 changes: 3 additions & 3 deletions modules/core_api/ut-stubs/src/cfe_sb_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
typedef struct
{
CFE_SB_MsgId_t MsgId;
uint32 UserLength;
uint32 TotalLength;
size_t UserLength;
size_t TotalLength;
uint16 CommandCode;
CFE_TIME_SysTime_t TimeStamp;
} CFE_SB_StubMsg_MetaData_t;
Expand Down Expand Up @@ -482,7 +482,7 @@ void UT_DefaultHandler_CFE_SB_GetUserData(void *UserObj, UT_EntryKey_t FuncKey,
CFE_MSG_Message_t *MsgPtr = UT_Hook_GetArgValueByName(Context, "MsgPtr", CFE_MSG_Message_t *);
uint8 * BytePtr;
void * Result;
uint16 HdrSize;
size_t HdrSize;

if (UT_Stub_CopyToLocal(UT_KEY(CFE_SB_GetUserData), &Result, sizeof(Result)) != sizeof(Result))
{
Expand Down
10 changes: 5 additions & 5 deletions modules/core_private/ut-stubs/inc/ut_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ typedef struct
{
CFE_SB_MsgId_t MsgId;
uint16 SnapshotOffset;
uint16 SnapshotSize;
size_t SnapshotSize;
uint16 Count;
void * SnapshotBuffer;
} UT_SoftwareBusSnapshot_Entry_t;
Expand Down Expand Up @@ -394,7 +394,7 @@ void UT_SetStatusBSPResetArea(int32 status, uint32 Signature, uint32 ClockSignal
** This function does not return a value.
**
******************************************************************************/
void UT_SetReadBuffer(void *Buff, int NumBytes);
void UT_SetReadBuffer(void *Buff, size_t NumBytes);

/*****************************************************************************/
/**
Expand All @@ -414,7 +414,7 @@ void UT_SetReadBuffer(void *Buff, int NumBytes);
** This function does not return a value.
**
******************************************************************************/
void UT_SetReadHeader(void *Hdr, int NumBytes);
void UT_SetReadHeader(void *Hdr, size_t NumBytes);

/*****************************************************************************/
/**
Expand Down Expand Up @@ -454,7 +454,7 @@ void UT_SetDummyFuncRtn(int Return);
** \sa
**
******************************************************************************/
void UT_SetSizeofESResetArea(int32 Size);
void UT_SetSizeofESResetArea(size_t Size);

/*****************************************************************************/
/**
Expand All @@ -472,7 +472,7 @@ void UT_SetSizeofESResetArea(int32 Size);
** This function does not return a value.
**
******************************************************************************/
uint8 *UT_SetCDSSize(int32 Size);
uint8 *UT_SetCDSSize(size_t Size);

/*****************************************************************************/
/**
Expand Down
18 changes: 9 additions & 9 deletions modules/core_private/ut-stubs/src/ut_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ uint8 UT_Endianess;
static char UT_appname[80];
static char UT_subsys[5];
static CFE_ES_AppId_t UT_AppID;
static uint32 UT_LastCDSSize = 0;
static size_t UT_LastCDSSize = 0;

typedef union
{
Expand Down Expand Up @@ -387,15 +387,15 @@ void UT_SetStatusBSPResetArea(int32 status, uint32 Signature, uint32 ClockSignal
/*
** Set the contents of the buffer to read
*/
void UT_SetReadBuffer(void *Buff, int NumBytes)
void UT_SetReadBuffer(void *Buff, size_t NumBytes)
{
UT_SetDataBuffer(UT_KEY(OS_read), Buff, NumBytes, true);
}

/*
** Set the contents of the header to read
*/
void UT_SetReadHeader(void *Hdr, int NumBytes)
void UT_SetReadHeader(void *Hdr, size_t NumBytes)
{
UT_SetDataBuffer(UT_KEY(CFE_FS_ReadHeader), Hdr, NumBytes, true);
}
Expand All @@ -411,7 +411,7 @@ void UT_SetDummyFuncRtn(int Return)
/*
** Set the size of the ES reset area
*/
void UT_SetSizeofESResetArea(int32 Size)
void UT_SetSizeofESResetArea(size_t Size)
{
UT_ResetState(UT_KEY(CFE_PSP_GetResetArea));
if (Size > 0)
Expand All @@ -428,12 +428,12 @@ void UT_SetSizeofESResetArea(int32 Size)
/*
** Set the CDS size returned by the BSP
*/
uint8 *UT_SetCDSSize(int32 Size)
uint8 *UT_SetCDSSize(size_t Size)
{
UT_ResetState(UT_KEY(CFE_PSP_GetCDSSize));
UT_ResetState(UT_KEY(CFE_PSP_ReadFromCDS));
UT_ResetState(UT_KEY(CFE_PSP_WriteToCDS));
if (Size <= 0)
if (Size == 0)
{
UT_LastCDSSize = 0;
return NULL;
Expand Down Expand Up @@ -584,7 +584,7 @@ CFE_ES_ResetData_t *UT_GetResetDataPtr(void)
** But on the upside this concession avoids a far more complicated issue of
** needing a fully-fledged implementation of printf in the OS_printf stub.
*/
static int UT_StrCmpFormatStr(const char *FormatStr, const char *TestStr, uint32 FormatLength, uint32 TestLength)
static int UT_StrCmpFormatStr(const char *FormatStr, const char *TestStr, size_t FormatLength, size_t TestLength)
{
const char *ChunkStart;
const char *ChunkEnd;
Expand Down Expand Up @@ -684,13 +684,13 @@ static int UT_StrCmpFormatStr(const char *FormatStr, const char *TestStr, uint32
* A string comparison function that will match exact strings only
* (Printf style conversion strings are compared literally)
*/
static int UT_StrCmpExact(const char *RefStr, const char *TestStr, uint32 RefLength, uint32 TestLength)
static int UT_StrCmpExact(const char *RefStr, const char *TestStr, size_t RefLength, size_t TestLength)
{
return (RefLength == TestLength && memcmp(RefStr, TestStr, RefLength) == 0);
}

static uint32 UT_GetMessageCount(const char *Msg, UT_Buffer_t *Buf,
int (*Comparator)(const char *, const char *, uint32, uint32))
int (*Comparator)(const char *, const char *, size_t, size_t))
{
uint32 Count = 0;
uint32 MsgLen = strlen(Msg);
Expand Down
2 changes: 1 addition & 1 deletion modules/es/fsw/src/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath)
const char *TokenList[CFE_ES_STARTSCRIPT_MAX_TOKENS_PER_LINE];
uint32 NumTokens;
uint32 NumLines;
uint32 BuffLen; /* Length of the current buffer */
size_t BuffLen; /* Length of the current buffer */
osal_id_t AppFile = OS_OBJECT_ID_UNDEFINED;
int32 Status;
int32 OsStatus;
Expand Down
2 changes: 1 addition & 1 deletion modules/es/fsw/src/cfe_es_start.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ typedef struct
char ObjectName[OS_MAX_API_NAME]; /* task or OS object name */
CFE_ES_FuncPtrUnion_t FuncPtrUnion; /* task or function reference */
uint32 ObjectPriority; /* object priority */
uint32 ObjectSize; /* size used for stack, queue size, etc. */
size_t ObjectSize; /* size used for stack, queue size, etc. */
uint32 ObjectFlags; /* extra flags to pass */
} CFE_ES_ObjectTable_t;

Expand Down
12 changes: 6 additions & 6 deletions modules/es/fsw/src/cfe_es_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data)
osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED;
uint32 i;
uint32 EntryCount = 0;
uint32 FileSize = 0;
size_t FileSize = 0;
int32 OsStatus;
int32 Result;
CFE_ES_AppInfo_t AppInfo;
Expand Down Expand Up @@ -1093,8 +1093,8 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data)
OS_close(FileDescriptor);
CFE_ES_Global.TaskData.CommandCounter++;
CFE_EVS_SendEvent(CFE_ES_ALL_APPS_EID, CFE_EVS_EventType_DEBUG,
"App Info file written to %s, Entries=%d, FileSize=%d", QueryAllFilename, (int)EntryCount,
(int)FileSize);
"App Info file written to %s, Entries=%d, FileSize=%lu", QueryAllFilename, (int)EntryCount,
(unsigned long)FileSize);
}
else
{
Expand All @@ -1116,7 +1116,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data)
osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED;
uint32 i;
uint32 EntryCount = 0;
uint32 FileSize = 0;
size_t FileSize = 0;
int32 OsStatus;
int32 Result;
CFE_ES_TaskInfo_t TaskInfo;
Expand Down Expand Up @@ -1245,8 +1245,8 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data)
OS_close(FileDescriptor);
CFE_ES_Global.TaskData.CommandCounter++;
CFE_EVS_SendEvent(CFE_ES_TASKINFO_EID, CFE_EVS_EventType_DEBUG,
"Task Info file written to %s, Entries=%d, FileSize=%d", QueryAllFilename, (int)EntryCount,
(int)FileSize);
"Task Info file written to %s, Entries=%d, FileSize=%lu", QueryAllFilename, (int)EntryCount,
(unsigned long)FileSize);
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void ES_UT_SetupMemPoolId(CFE_ES_MemPoolRecord_t **OutPoolRecPtr)
}
}

void ES_UT_SetupCDSGlobal(uint32 CDS_Size)
void ES_UT_SetupCDSGlobal(size_t CDS_Size)
{
CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars;

Expand Down Expand Up @@ -1145,7 +1145,7 @@ static void ES_UT_Config_IterateAll(void *UserObj, UT_EntryKey_t FuncKey, const

void TestApps(void)
{
int NumBytes;
size_t NumBytes;
CFE_ES_AppInfo_t AppInfo;
CFE_ES_AppId_t AppId;
CFE_ES_TaskId_t TaskId;
Expand Down Expand Up @@ -3996,7 +3996,7 @@ void TestAPI(void)
osal_id_t TestObjId;
char AppName[OS_MAX_API_NAME + 12];
char SysLogBuf[CFE_TIME_PRINTED_STRING_SIZE + 20];
uint32 SysLogBufSize;
size_t SysLogBufSize;
uint32 StackBuf[8];
uint8 Data[12];
uint32 ResetType;
Expand Down Expand Up @@ -4739,7 +4739,7 @@ void TestCDS()
CFE_ES_CDSHandle_t CDSHandle;
CFE_ES_CDS_RegRec_t *UtCDSRegRecPtr;
uint32 i;
uint32 TempSize;
size_t TempSize;
uint8 BlockData[ES_UT_CDS_BLOCK_SIZE];

UtPrintf("Begin Test CDS");
Expand Down
6 changes: 3 additions & 3 deletions modules/evs/ut-coverage/evs_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static int32 UT_EVS_MSGInitHook(void *UserObj, int32 StubRetcode, uint32 CallCou
return StubRetcode;
}

static void UT_EVS_DoDispatchCheckEvents_Impl(void *MsgPtr, uint32 MsgSize, UT_TaskPipeDispatchId_t DispatchId,
static void UT_EVS_DoDispatchCheckEvents_Impl(void *MsgPtr, size_t MsgSize, UT_TaskPipeDispatchId_t DispatchId,
const UT_SoftwareBusSnapshot_Entry_t *SnapshotCfg,
UT_EVS_EventCapture_t * EventCapture)
{
Expand All @@ -189,13 +189,13 @@ static void UT_EVS_DoDispatchCheckEvents_Impl(void *MsgPtr, uint32 MsgSize, UT_T
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), NULL, NULL);
}

static void UT_EVS_DoDispatchCheckEvents(void *MsgPtr, uint32 MsgSize, UT_TaskPipeDispatchId_t DispatchId,
static void UT_EVS_DoDispatchCheckEvents(void *MsgPtr, size_t MsgSize, UT_TaskPipeDispatchId_t DispatchId,
UT_EVS_EventCapture_t *EventCapture)
{
UT_EVS_DoDispatchCheckEvents_Impl(MsgPtr, MsgSize, DispatchId, &UT_EVS_LONGFMT_SNAPSHOTDATA, EventCapture);
}

static void UT_EVS_DoDispatchCheckEventsShort(void *MsgPtr, uint32 MsgSize, UT_TaskPipeDispatchId_t DispatchId,
static void UT_EVS_DoDispatchCheckEventsShort(void *MsgPtr, size_t MsgSize, UT_TaskPipeDispatchId_t DispatchId,
UT_EVS_EventCapture_t *EventCapture)
{
UT_EVS_DoDispatchCheckEvents_Impl(MsgPtr, MsgSize, DispatchId, &UT_EVS_SHORTFMT_SNAPSHOTDATA, EventCapture);
Expand Down
2 changes: 1 addition & 1 deletion modules/sb/fsw/src/cfe_sb_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef struct
{
const char *Filename; /* File name for error reporting */
osal_id_t Fd; /* File id for writing */
uint32 FileSize; /* File size for reporting */
size_t FileSize; /* File size for reporting */
uint32 EntryCount; /* Entry count for reporting */
int32 Status; /* File write status */
} CFE_SB_FileWriteCallback_t;
Expand Down
4 changes: 2 additions & 2 deletions modules/sb/ut-coverage/sb_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -3843,7 +3843,7 @@ void Test_TransmitMsg_GetPoolBufErr(void)
*/
void Test_AllocateMessageBuffer(void)
{
uint16 MsgSize = 10;
size_t MsgSize = 10;
uint32 MemUse;

/* Attempt to allocate a message buffer greater than the max size */
Expand Down Expand Up @@ -4032,7 +4032,7 @@ void Test_ReleaseMessageBuffer(void)
CFE_SB_Buffer_t *ZeroCpyMsgPtr2 = NULL;
CFE_SB_Buffer_t *ZeroCpyMsgPtr3 = NULL;
CFE_SB_BufferD_t BadBufferDesc;
uint16 MsgSize = 10;
size_t MsgSize = 10;

ZeroCpyMsgPtr1 = CFE_SB_AllocateMessageBuffer(MsgSize);
ZeroCpyMsgPtr2 = CFE_SB_AllocateMessageBuffer(MsgSize);
Expand Down
2 changes: 1 addition & 1 deletion modules/tbl/ut-coverage/tbl_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ void Test_CFE_TBL_ActivateCmd(void)
*/
void Test_CFE_TBL_DumpToFile(void)
{
uint32 TblSizeInBytes = 9;
size_t TblSizeInBytes = 9;

UtPrintf("Begin Test Dump to File");

Expand Down

0 comments on commit 6059459

Please sign in to comment.