Skip to content

Commit dd9fd53

Browse files
authored
Merge pull request #219 from jphickey/fix-217-stubs-use-size_t
Fix #217, use size_t in PSP stubs
2 parents e3249a9 + 45718d9 commit dd9fd53

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

unit-test-coverage/ut-stubs/src/libc-stdlib-stubs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void *PCS_malloc(size_t sz)
8585
cpuaddr PoolEnd;
8686
cpuaddr NextBlock;
8787
size_t NextSize;
88-
uint32 PoolSize;
88+
size_t PoolSize;
8989
uint32 CallCnt;
9090
struct MPOOL_REC *Rec;
9191

@@ -156,7 +156,7 @@ void PCS_free(void *ptr)
156156
int32 Status;
157157
cpuaddr BlockAddr;
158158
void *PoolPtr;
159-
uint32 PoolSize;
159+
size_t PoolSize;
160160
struct MPOOL_REC *Rec;
161161

162162
/*

ut-stubs/ut_psp_stubs.c

+27-13
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ int32 CFE_PSP_WriteToCDS(const void *PtrToDataToWrite,
232232
uint32 NumBytes)
233233
{
234234
uint8 *BufPtr;
235-
uint32 CdsSize;
236-
uint32 Position;
235+
size_t CdsSize;
236+
size_t Position;
237237
int32 status;
238238

239239
status = UT_DEFAULT_IMPL(CFE_PSP_WriteToCDS);
@@ -276,8 +276,8 @@ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead,
276276
uint32 NumBytes)
277277
{
278278
uint8 *BufPtr;
279-
uint32 CdsSize;
280-
uint32 Position;
279+
size_t CdsSize;
280+
size_t Position;
281281
int32 status;
282282

283283
status = UT_DEFAULT_IMPL(CFE_PSP_ReadFromCDS);
@@ -313,14 +313,14 @@ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead,
313313
int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS)
314314
{
315315
int32 status;
316-
void *BufPtr;
317-
uint32 Position;
316+
size_t TempSize;
318317

319318
status = UT_DEFAULT_IMPL(CFE_PSP_GetCDSSize);
320319

321320
if (status >= 0)
322321
{
323-
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCDSSize), &BufPtr, SizeOfCDS, &Position);
322+
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCDSSize), NULL, &TempSize, NULL);
323+
*SizeOfCDS = TempSize;
324324
}
325325

326326
return status;
@@ -345,13 +345,17 @@ int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS)
345345
int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk)
346346
{
347347
int32 status;
348-
uint32 Position;
348+
size_t TempSize;
349+
void *TempAddr;
349350

350351
status = UT_DEFAULT_IMPL(CFE_PSP_GetVolatileDiskMem);
351352

352353
if (status >= 0)
353354
{
354-
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVolatileDiskMem), (void**)PtrToVolDisk, SizeOfVolDisk, &Position);
355+
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVolatileDiskMem), &TempAddr, &TempSize, NULL);
356+
357+
*PtrToVolDisk = (cpuaddr)TempAddr;
358+
*SizeOfVolDisk = TempSize;
355359
}
356360

357361
return status;
@@ -426,13 +430,17 @@ void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32* Tbl)
426430
int32 CFE_PSP_GetResetArea(cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea)
427431
{
428432
int32 status;
429-
uint32 Position;
433+
size_t TempSize;
434+
void *TempAddr;
430435

431436
status = UT_DEFAULT_IMPL(CFE_PSP_GetResetArea);
432437

433438
if (status >= 0)
434439
{
435-
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), (void**)PtrToResetArea, SizeOfResetArea, &Position);
440+
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), &TempAddr, &TempSize, NULL);
441+
442+
*PtrToResetArea = (cpuaddr)TempAddr;
443+
*SizeOfResetArea = TempSize;
436444
}
437445

438446
return status;
@@ -553,19 +561,25 @@ int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment,
553561
{
554562
static uint32 LocalTextSegment;
555563
int32 status;
556-
uint32 Position;
564+
void *TempAddr;
565+
size_t TempSize;
557566

558567
status = UT_DEFAULT_IMPL(CFE_PSP_GetCFETextSegmentInfo);
559568

560569
if (status >= 0)
561570
{
562-
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCFETextSegmentInfo), (void**)PtrToCFESegment, SizeOfCFESegment, &Position);
571+
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCFETextSegmentInfo), &TempAddr, &TempSize, NULL);
563572
if (*PtrToCFESegment == 0)
564573
{
565574
/* Backup -- Set the pointer and size to anything */
566575
*PtrToCFESegment = (cpuaddr)&LocalTextSegment;
567576
*SizeOfCFESegment = sizeof(LocalTextSegment);
568577
}
578+
else
579+
{
580+
*PtrToCFESegment = (cpuaddr)TempAddr;
581+
*SizeOfCFESegment = TempSize;
582+
}
569583
}
570584

571585
return status;

0 commit comments

Comments
 (0)