Skip to content

Commit

Permalink
Fix nasa#67, Use size_t for 'size' variables
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Apr 10, 2023
1 parent b824250 commit fe0963c
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 299 deletions.
30 changes: 15 additions & 15 deletions fsw/src/mm_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bool MM_PeekCmd(const CFE_SB_Buffer_t *BufPtr)
bool Valid;
MM_PeekCmd_t *CmdPtr;
cpuaddr SrcAddress = 0;
uint16 ExpectedLength = sizeof(MM_PeekCmd_t);
size_t ExpectedLength = sizeof(MM_PeekCmd_t);
bool Result = false;

/* Verify command packet length */
Expand Down Expand Up @@ -100,9 +100,9 @@ bool MM_PeekMem(const MM_PeekCmd_t *CmdPtr, cpuaddr SrcAddress)
uint16 WordValue = 0;
uint32 DWordValue = 0;
int32 PSP_Status = 0;
uint32 BytesProcessed = 0;
size_t BytesProcessed = 0;
uint32 DataValue = 0;
uint8 DataSize = 0;
size_t DataSize = 0;
uint32 EventID = 0;

/*
Expand Down Expand Up @@ -166,14 +166,14 @@ bool MM_PeekMem(const MM_PeekCmd_t *CmdPtr, cpuaddr SrcAddress)
MM_AppData.HkPacket.DataValue = DataValue;

CFE_EVS_SendEvent(EventID, CFE_EVS_EventType_INFORMATION,
"Peek Command: Addr = %p Size = %d bits Data = 0x%08X", (void *)SrcAddress, DataSize,
(unsigned int)DataValue);
"Peek Command: Addr = %p Size = %u bits Data = 0x%08X", (void *)SrcAddress,
(unsigned int)DataSize, (unsigned int)DataValue);
}
else
{
CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"PSP read memory error: RC=%d, Address=%p, MemType=MEM%d", PSP_Status, (void *)SrcAddress,
DataSize);
"PSP read memory error: RC=%d, Address=%p, MemType=MEM%u", PSP_Status, (void *)SrcAddress,
(unsigned int)DataSize);
}

return ValidPeek;
Expand All @@ -193,7 +193,7 @@ bool MM_DumpMemToFileCmd(const CFE_SB_Buffer_t *BufPtr)
MM_DumpMemToFileCmd_t * CmdPtr;
CFE_FS_Header_t CFEFileHeader;
MM_LoadDumpFileHeader_t MMFileHeader;
uint16 ExpectedLength = sizeof(MM_DumpMemToFileCmd_t);
size_t ExpectedLength = sizeof(MM_DumpMemToFileCmd_t);

/* Verify command packet length */
if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength))
Expand Down Expand Up @@ -374,8 +374,8 @@ bool MM_DumpMemToFile(osal_id_t FileHandle, const char *FileName, const MM_LoadD
bool ValidDump = false;
int32 OS_Status;
uint32 BytesRemaining = FileHeader->NumOfBytes;
uint32 BytesProcessed = 0;
uint32 SegmentSize = MM_MAX_DUMP_DATA_SEG;
size_t BytesProcessed = 0;
size_t SegmentSize = MM_MAX_DUMP_DATA_SEG;
uint8 *SourcePtr = (uint8 *)(FileHeader->SymAddress.Offset);
uint8 *ioBuffer = (uint8 *)&MM_AppData.DumpBuffer[0];

Expand Down Expand Up @@ -405,8 +405,8 @@ bool MM_DumpMemToFile(osal_id_t FileHandle, const char *FileName, const MM_LoadD
{
BytesRemaining = 0;
CFE_EVS_SendEvent(MM_OS_WRITE_EXP_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_write error received: RC = %d, Expected = %d, File = '%s'", OS_Status,
(int)SegmentSize, FileName);
"OS_write error received: RC = %d, Expected = %u, File = '%s'", OS_Status,
(unsigned int)SegmentSize, FileName);
}
}

Expand Down Expand Up @@ -459,8 +459,8 @@ bool MM_WriteFileHeaders(const char *FileName, osal_id_t FileHandle, CFE_FS_Head
/* We either got an error or didn't read as much data as expected */
Valid = false;
CFE_EVS_SendEvent(MM_OS_WRITE_EXP_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_write error received: RC = %d Expected = %d File = '%s'", OS_Status,
(int)sizeof(MM_LoadDumpFileHeader_t), FileName);
"OS_write error received: RC = %d Expected = %u File = '%s'", OS_Status,
(unsigned int)sizeof(MM_LoadDumpFileHeader_t), FileName);

} /* end OS_write if */

Expand All @@ -480,7 +480,7 @@ bool MM_DumpInEventCmd(const CFE_SB_Buffer_t *BufPtr)
MM_DumpInEventCmd_t *CmdPtr;
uint32 i;
cpuaddr SrcAddress = 0;
uint16 ExpectedLength = sizeof(MM_DumpInEventCmd_t);
size_t ExpectedLength = sizeof(MM_DumpInEventCmd_t);
uint8 * BytePtr;
char TempString[MM_DUMPINEVENT_TEMP_CHARS];
static char EventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];
Expand Down
36 changes: 18 additions & 18 deletions fsw/src/mm_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool MM_PokeCmd(const CFE_SB_Buffer_t *BufPtr)
bool Valid = false;
cpuaddr DestAddress = 0;
MM_PokeCmd_t *CmdPtr;
uint16 ExpectedLength = sizeof(MM_PokeCmd_t);
size_t ExpectedLength = sizeof(MM_PokeCmd_t);

/* Verify command packet length */
if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength))
Expand Down Expand Up @@ -109,9 +109,9 @@ bool MM_PokeMem(const MM_PokeCmd_t *CmdPtr, cpuaddr DestAddress)
uint16 WordValue;
int32 PSP_Status = CFE_PSP_SUCCESS;
uint32 DataValue = 0;
uint32 BytesProcessed = 0;
size_t BytesProcessed = 0;
bool ValidPoke = false;
uint8 DataSize = 0; /* only used for giving MEM type/size in events */
size_t DataSize = 0; /* only used for giving MEM type/size in events */
uint32 EventID = 0;

/* Write input number of bits to destination address */
Expand Down Expand Up @@ -170,14 +170,14 @@ bool MM_PokeMem(const MM_PokeCmd_t *CmdPtr, cpuaddr DestAddress)
MM_AppData.HkPacket.BytesProcessed = BytesProcessed;

CFE_EVS_SendEvent(EventID, CFE_EVS_EventType_INFORMATION,
"Poke Command: Addr = %p, Size = %d bits, Data = 0x%08X", (void *)DestAddress, DataSize,
(unsigned int)DataValue);
"Poke Command: Addr = %p, Size = %u bits, Data = 0x%08X", (void *)DestAddress,
(unsigned int)DataSize, (unsigned int)DataValue);
}
else
{
CFE_EVS_SendEvent(MM_PSP_WRITE_ERR_EID, CFE_EVS_EventType_ERROR,
"PSP write memory error: RC=0x%08X, Address=%p, MemType=MEM%d", (unsigned int)PSP_Status,
(void *)DestAddress, DataSize);
"PSP write memory error: RC=0x%08X, Address=%p, MemType=MEM%u", (unsigned int)PSP_Status,
(void *)DestAddress, (unsigned int)DataSize);
}

return ValidPoke;
Expand All @@ -194,7 +194,7 @@ bool MM_PokeEeprom(const MM_PokeCmd_t *CmdPtr, cpuaddr DestAddress)
uint16 WordValue;
int32 PSP_Status;
uint32 DataValue = 0;
uint32 BytesProcessed = 0;
size_t BytesProcessed = 0;
bool ValidPoke = false;

CFE_ES_PerfLogEntry(MM_EEPROM_POKE_PERF_ID);
Expand Down Expand Up @@ -295,7 +295,7 @@ bool MM_LoadMemWIDCmd(const CFE_SB_Buffer_t *BufPtr)
MM_LoadMemWIDCmd_t *CmdPtr;
uint32 ComputedCRC;
cpuaddr DestAddress = 0;
uint16 ExpectedLength = sizeof(MM_LoadMemWIDCmd_t);
size_t ExpectedLength = sizeof(MM_LoadMemWIDCmd_t);
bool CmdResult = false;

/* Verify command packet length */
Expand Down Expand Up @@ -369,7 +369,7 @@ bool MM_LoadMemFromFileCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_FS_Header_t CFEFileHeader;
MM_LoadDumpFileHeader_t MMFileHeader;
uint32 ComputedCRC;
uint16 ExpectedLength = sizeof(MM_LoadMemFromFileCmd_t);
size_t ExpectedLength = sizeof(MM_LoadMemFromFileCmd_t);

memset(&MMFileHeader, 0, sizeof(MMFileHeader));

Expand Down Expand Up @@ -560,7 +560,7 @@ bool MM_LoadMemFromFile(osal_id_t FileHandle, const char *FileName, const MM_Loa
int32 BytesRemaining = FileHeader->NumOfBytes;
int32 BytesProcessed = 0;
int32 ReadLength;
uint32 SegmentSize = MM_MAX_LOAD_DATA_SEG;
size_t SegmentSize = MM_MAX_LOAD_DATA_SEG;
uint8 *ioBuffer = (uint8 *)&MM_AppData.LoadBuffer[0];
uint8 *TargetPointer = (uint8 *)DestAddress;

Expand Down Expand Up @@ -593,8 +593,8 @@ bool MM_LoadMemFromFile(osal_id_t FileHandle, const char *FileName, const MM_Loa
else
{
CFE_EVS_SendEvent(MM_OS_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_read error received: RC = 0x%08X Expected = %d File = '%s'", (unsigned int)ReadLength,
(int)SegmentSize, FileName);
"OS_read error received: RC = 0x%08X Expected = %u File = '%s'", (unsigned int)ReadLength,
(unsigned int)SegmentSize, FileName);
BytesRemaining = 0;
}
}
Expand Down Expand Up @@ -627,7 +627,7 @@ bool MM_VerifyLoadFileSize(const char *FileName, const MM_LoadDumpFileHeader_t *
{
bool Valid = true;
int32 OS_Status;
uint32 ExpectedSize;
size_t ExpectedSize;
int32 ActualSize; /* The size returned by OS_stat is signed */
os_fstat_t FileStats;

Expand Down Expand Up @@ -661,8 +661,8 @@ bool MM_VerifyLoadFileSize(const char *FileName, const MM_LoadDumpFileHeader_t *
** the variable ActualSize to this function.
*/
CFE_EVS_SendEvent(MM_LD_FILE_SIZE_ERR_EID, CFE_EVS_EventType_ERROR,
"Load file size error: Reported by OS = %d Expected = %d File = '%s'", (int)ActualSize,
(int)ExpectedSize, FileName);
"Load file size error: Reported by OS = %d Expected = %u File = '%s'", (int)ActualSize,
(unsigned int)ExpectedSize, FileName);
}
}

Expand Down Expand Up @@ -723,7 +723,7 @@ bool MM_FillMemCmd(const CFE_SB_Buffer_t *BufPtr)
{
cpuaddr DestAddress = 0;
MM_FillMemCmd_t *CmdPtr = (MM_FillMemCmd_t *)BufPtr;
uint16 ExpectedLength = sizeof(MM_FillMemCmd_t);
size_t ExpectedLength = sizeof(MM_FillMemCmd_t);
bool CmdResult = false;

/* Verify command packet length */
Expand Down Expand Up @@ -797,7 +797,7 @@ bool MM_FillMem(cpuaddr DestAddress, const MM_FillMemCmd_t *CmdPtr)
{
uint16 i;
bool Valid = true;
uint32 BytesProcessed = 0;
size_t BytesProcessed = 0;
uint32 BytesRemaining = CmdPtr->NumOfBytes;
uint32 SegmentSize = MM_MAX_FILL_DATA_SEG;
uint8 *TargetPointer = (uint8 *)DestAddress;
Expand Down
14 changes: 7 additions & 7 deletions fsw/src/mm_mem16.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool MM_LoadMem16FromFile(osal_id_t FileHandle, const char *FileName, const MM_L
int32 BytesRemaining = FileHeader->NumOfBytes;
uint16 *DataPointer16 = (uint16 *)DestAddress;
uint16 *ioBuffer16 = (uint16 *)&MM_AppData.LoadBuffer[0];
uint32 SegmentSize = MM_MAX_LOAD_DATA_SEG;
size_t SegmentSize = MM_MAX_LOAD_DATA_SEG;
bool Valid = false;

while (BytesRemaining != 0)
Expand All @@ -73,8 +73,8 @@ bool MM_LoadMem16FromFile(osal_id_t FileHandle, const char *FileName, const MM_L
{
BytesRemaining = 0;
CFE_EVS_SendEvent(MM_OS_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_read error received: RC = 0x%08X Expected = %d File = '%s'", (unsigned int)ReadLength,
(int)SegmentSize, FileName);
"OS_read error received: RC = 0x%08X Expected = %u File = '%s'", (unsigned int)ReadLength,
(unsigned int)SegmentSize, FileName);
}
else
{
Expand Down Expand Up @@ -142,7 +142,7 @@ bool MM_DumpMem16ToFile(osal_id_t FileHandle, const char *FileName, const MM_Loa
uint32 BytesRemaining = FileHeader->NumOfBytes;
uint16 *DataPointer16 = (uint16 *)(FileHeader->SymAddress.Offset);
uint16 *ioBuffer16 = (uint16 *)&MM_AppData.DumpBuffer[0];
uint32 SegmentSize = MM_MAX_DUMP_DATA_SEG;
size_t SegmentSize = MM_MAX_DUMP_DATA_SEG;

while (BytesRemaining != 0)
{
Expand Down Expand Up @@ -193,8 +193,8 @@ bool MM_DumpMem16ToFile(osal_id_t FileHandle, const char *FileName, const MM_Loa
Valid = false;
BytesRemaining = 0;
CFE_EVS_SendEvent(MM_OS_WRITE_EXP_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_write error received: RC = 0x%08X Expected = %d File = '%s'",
(unsigned int)OS_Status, (int)SegmentSize, FileName);
"OS_write error received: RC = 0x%08X Expected = %u File = '%s'",
(unsigned int)OS_Status, (unsigned int)SegmentSize, FileName);
}
}
}
Expand Down Expand Up @@ -227,7 +227,7 @@ bool MM_FillMem16(cpuaddr DestAddress, const MM_FillMemCmd_t *CmdPtr)
uint32 NewBytesRemaining;
uint16 FillPattern16 = (uint16)CmdPtr->FillPattern;
uint16 *DataPointer16 = (uint16 *)DestAddress;
uint32 SegmentSize = MM_MAX_FILL_DATA_SEG;
size_t SegmentSize = MM_MAX_FILL_DATA_SEG;
bool Result = true;

/* Check fill size and warn if not a multiple of 2 */
Expand Down
14 changes: 7 additions & 7 deletions fsw/src/mm_mem32.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool MM_LoadMem32FromFile(osal_id_t FileHandle, const char *FileName, const MM_L
int32 BytesRemaining = FileHeader->NumOfBytes;
uint32 *DataPointer32 = (uint32 *)DestAddress;
uint32 *ioBuffer32 = (uint32 *)&MM_AppData.LoadBuffer[0];
uint32 SegmentSize = MM_MAX_LOAD_DATA_SEG;
size_t SegmentSize = MM_MAX_LOAD_DATA_SEG;
bool Valid = false;

while (BytesRemaining != 0)
Expand All @@ -73,8 +73,8 @@ bool MM_LoadMem32FromFile(osal_id_t FileHandle, const char *FileName, const MM_L
{
BytesRemaining = 0;
CFE_EVS_SendEvent(MM_OS_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_read error received: RC = 0x%08X Expected = %d File = '%s'", (unsigned int)ReadLength,
(int)SegmentSize, FileName);
"OS_read error received: RC = 0x%08X Expected = %u File = '%s'", (unsigned int)ReadLength,
(unsigned int)SegmentSize, FileName);
}
else
{
Expand Down Expand Up @@ -142,7 +142,7 @@ bool MM_DumpMem32ToFile(osal_id_t FileHandle, const char *FileName, const MM_Loa
uint32 BytesRemaining = FileHeader->NumOfBytes;
uint32 *DataPointer32 = (uint32 *)(FileHeader->SymAddress.Offset);
uint32 *ioBuffer32 = (uint32 *)&MM_AppData.DumpBuffer[0];
uint32 SegmentSize = MM_MAX_DUMP_DATA_SEG;
size_t SegmentSize = MM_MAX_DUMP_DATA_SEG;

while (BytesRemaining != 0)
{
Expand Down Expand Up @@ -194,8 +194,8 @@ bool MM_DumpMem32ToFile(osal_id_t FileHandle, const char *FileName, const MM_Loa
Valid = false;
BytesRemaining = 0;
CFE_EVS_SendEvent(MM_OS_WRITE_EXP_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_write error received: RC = 0x%08X Expected = %d File = '%s'",
(unsigned int)OS_Status, (int)SegmentSize, FileName);
"OS_write error received: RC = 0x%08X Expected = %u File = '%s'",
(unsigned int)OS_Status, (unsigned int)SegmentSize, FileName);
}
}
}
Expand Down Expand Up @@ -228,7 +228,7 @@ bool MM_FillMem32(cpuaddr DestAddress, const MM_FillMemCmd_t *CmdPtr)
uint32 NewBytesRemaining;
uint32 FillPattern32 = CmdPtr->FillPattern;
uint32 *DataPointer32 = (uint32 *)(DestAddress);
uint32 SegmentSize = MM_MAX_FILL_DATA_SEG;
size_t SegmentSize = MM_MAX_FILL_DATA_SEG;
bool Result = true;

/* Check fill size and warn if not a multiple of 4 */
Expand Down
18 changes: 9 additions & 9 deletions fsw/src/mm_mem8.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool MM_LoadMem8FromFile(osal_id_t FileHandle, const char *FileName, const MM_Lo
int32 BytesRemaining = FileHeader->NumOfBytes;
uint8 *DataPointer8 = (uint8 *)DestAddress;
uint8 *ioBuffer8 = (uint8 *)&MM_AppData.LoadBuffer[0];
uint32 SegmentSize = MM_MAX_LOAD_DATA_SEG;
size_t SegmentSize = MM_MAX_LOAD_DATA_SEG;
bool Valid = false;

while (BytesRemaining != 0)
Expand All @@ -73,8 +73,8 @@ bool MM_LoadMem8FromFile(osal_id_t FileHandle, const char *FileName, const MM_Lo
{
BytesRemaining = 0;
CFE_EVS_SendEvent(MM_OS_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_read error received: RC = 0x%08X Expected = %d File = '%s'", (unsigned int)ReadLength,
(int)SegmentSize, FileName);
"OS_read error received: RC = 0x%08X Expected = %u File = '%s'", (unsigned int)ReadLength,
(unsigned int)SegmentSize, FileName);
}
else
{
Expand Down Expand Up @@ -138,11 +138,11 @@ bool MM_DumpMem8ToFile(osal_id_t FileHandle, const char *FileName, const MM_Load
int32 OS_Status;
int32 PSP_Status = CFE_PSP_SUCCESS;
uint32 i;
uint32 BytesProcessed = 0;
size_t BytesProcessed = 0;
uint32 BytesRemaining = FileHeader->NumOfBytes;
uint8 *DataPointer8 = (uint8 *)(FileHeader->SymAddress.Offset);
uint8 *ioBuffer8 = (uint8 *)&MM_AppData.DumpBuffer[0];
uint32 SegmentSize = MM_MAX_DUMP_DATA_SEG;
size_t SegmentSize = MM_MAX_DUMP_DATA_SEG;

while (BytesRemaining != 0)
{
Expand Down Expand Up @@ -193,8 +193,8 @@ bool MM_DumpMem8ToFile(osal_id_t FileHandle, const char *FileName, const MM_Load
Valid = false;
BytesRemaining = 0;
CFE_EVS_SendEvent(MM_OS_WRITE_EXP_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_write error received: RC = 0x%08X Expected = %d File = '%s'",
(unsigned int)OS_Status, (int)SegmentSize, FileName);
"OS_write error received: RC = 0x%08X Expected = %u File = '%s'",
(unsigned int)OS_Status, (unsigned int)SegmentSize, FileName);
}
}
}
Expand Down Expand Up @@ -222,11 +222,11 @@ bool MM_FillMem8(cpuaddr DestAddress, const MM_FillMemCmd_t *CmdPtr)
{
uint32 i;
int32 PSP_Status = CFE_PSP_SUCCESS;
uint32 BytesProcessed = 0;
size_t BytesProcessed = 0;
uint32 BytesRemaining = CmdPtr->NumOfBytes;
uint8 FillPattern8 = (uint8)CmdPtr->FillPattern;
uint8 *DataPointer8 = (uint8 *)DestAddress;
uint32 SegmentSize = MM_MAX_FILL_DATA_SEG;
size_t SegmentSize = MM_MAX_FILL_DATA_SEG;
bool Result = true;

while (BytesRemaining != 0)
Expand Down
Loading

0 comments on commit fe0963c

Please sign in to comment.