Skip to content

Commit

Permalink
Fix #217, use size_t in PSP stubs
Browse files Browse the repository at this point in the history
Recent API updates require use of the size_t type
instead of uint32.
  • Loading branch information
jphickey authored and arielswalker committed Jan 7, 2021
1 parent 203d0f0 commit a8d2e39
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
4 changes: 2 additions & 2 deletions unit-test-coverage/ut-stubs/src/libc-stdlib-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void *PCS_malloc(size_t sz)
cpuaddr PoolEnd;
cpuaddr NextBlock;
size_t NextSize;
uint32 PoolSize;
size_t PoolSize;
uint32 CallCnt;
struct MPOOL_REC *Rec;

Expand Down Expand Up @@ -156,7 +156,7 @@ void PCS_free(void *ptr)
int32 Status;
cpuaddr BlockAddr;
void *PoolPtr;
uint32 PoolSize;
size_t PoolSize;
struct MPOOL_REC *Rec;

/*
Expand Down
40 changes: 27 additions & 13 deletions ut-stubs/ut_psp_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ int32 CFE_PSP_WriteToCDS(const void *PtrToDataToWrite,
uint32 NumBytes)
{
uint8 *BufPtr;
uint32 CdsSize;
uint32 Position;
size_t CdsSize;
size_t Position;
int32 status;

status = UT_DEFAULT_IMPL(CFE_PSP_WriteToCDS);
Expand Down Expand Up @@ -276,8 +276,8 @@ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead,
uint32 NumBytes)
{
uint8 *BufPtr;
uint32 CdsSize;
uint32 Position;
size_t CdsSize;
size_t Position;
int32 status;

status = UT_DEFAULT_IMPL(CFE_PSP_ReadFromCDS);
Expand Down Expand Up @@ -313,14 +313,14 @@ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead,
int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS)
{
int32 status;
void *BufPtr;
uint32 Position;
size_t TempSize;

status = UT_DEFAULT_IMPL(CFE_PSP_GetCDSSize);

if (status >= 0)
{
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCDSSize), &BufPtr, SizeOfCDS, &Position);
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCDSSize), NULL, &TempSize, NULL);
*SizeOfCDS = TempSize;
}

return status;
Expand All @@ -345,13 +345,17 @@ int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS)
int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk)
{
int32 status;
uint32 Position;
size_t TempSize;
void *TempAddr;

status = UT_DEFAULT_IMPL(CFE_PSP_GetVolatileDiskMem);

if (status >= 0)
{
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVolatileDiskMem), (void**)PtrToVolDisk, SizeOfVolDisk, &Position);
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVolatileDiskMem), &TempAddr, &TempSize, NULL);

*PtrToVolDisk = (cpuaddr)TempAddr;
*SizeOfVolDisk = TempSize;
}

return status;
Expand Down Expand Up @@ -426,13 +430,17 @@ void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32* Tbl)
int32 CFE_PSP_GetResetArea(cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea)
{
int32 status;
uint32 Position;
size_t TempSize;
void *TempAddr;

status = UT_DEFAULT_IMPL(CFE_PSP_GetResetArea);

if (status >= 0)
{
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), (void**)PtrToResetArea, SizeOfResetArea, &Position);
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), &TempAddr, &TempSize, NULL);

*PtrToResetArea = (cpuaddr)TempAddr;
*SizeOfResetArea = TempSize;
}

return status;
Expand Down Expand Up @@ -553,19 +561,25 @@ int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment,
{
static uint32 LocalTextSegment;
int32 status;
uint32 Position;
void *TempAddr;
size_t TempSize;

status = UT_DEFAULT_IMPL(CFE_PSP_GetCFETextSegmentInfo);

if (status >= 0)
{
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCFETextSegmentInfo), (void**)PtrToCFESegment, SizeOfCFESegment, &Position);
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCFETextSegmentInfo), &TempAddr, &TempSize, NULL);
if (*PtrToCFESegment == 0)
{
/* Backup -- Set the pointer and size to anything */
*PtrToCFESegment = (cpuaddr)&LocalTextSegment;
*SizeOfCFESegment = sizeof(LocalTextSegment);
}
else
{
*PtrToCFESegment = (cpuaddr)TempAddr;
*SizeOfCFESegment = TempSize;
}
}

return status;
Expand Down

0 comments on commit a8d2e39

Please sign in to comment.