Skip to content

Commit

Permalink
Fix #89, correct format spec strings and data types
Browse files Browse the repository at this point in the history
Resolves mismatches between format strings and the data types
  • Loading branch information
jphickey committed Jan 11, 2024
1 parent 73285e9 commit acab315
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
6 changes: 3 additions & 3 deletions fsw/src/mm_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ CFE_Status_t MM_AppInit(void)
Status = CFE_SB_CreatePipe(&MM_AppData.CmdPipe, MM_CMD_PIPE_DEPTH, "MM_CMD_PIPE");
if (Status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(MM_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "Error Creating SB Pipe, RC = 0x%08X", Status);
CFE_EVS_SendEvent(MM_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "Error Creating SB Pipe, RC = 0x%08X", (unsigned int)Status);
return Status;
}

Expand All @@ -181,7 +181,7 @@ CFE_Status_t MM_AppInit(void)
if (Status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(MM_HK_SUB_ERR_EID, CFE_EVS_EventType_ERROR, "Error Subscribing to HK Request, RC = 0x%08X",
Status);
(unsigned int)Status);
return Status;
}

Expand All @@ -192,7 +192,7 @@ CFE_Status_t MM_AppInit(void)
if (Status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(MM_CMD_SUB_ERR_EID, CFE_EVS_EventType_ERROR, "Error Subscribing to MM Command, RC = 0x%08X",
Status);
(unsigned int)Status);
return Status;
}

Expand Down
14 changes: 7 additions & 7 deletions fsw/src/mm_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ bool MM_PeekMem(const MM_PeekCmd_t *CmdPtr, cpuaddr SrcAddress)
else
{
CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"PSP read memory error: RC=%d, Address=%p, MemType=MEM%u", PSP_Status, (void *)SrcAddress,
"PSP read memory error: RC=%d, Address=%p, MemType=MEM%u", (int)PSP_Status, (void *)SrcAddress,
(unsigned int)DataSize);
}

Expand Down Expand Up @@ -395,7 +395,7 @@ 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 = %u, File = '%s'", OS_Status,
"OS_write error received: RC = %d, Expected = %u, File = '%s'", (int)OS_Status,
(unsigned int)SegmentSize, FileName);
}
}
Expand Down Expand Up @@ -434,7 +434,7 @@ bool MM_WriteFileHeaders(const char *FileName, osal_id_t FileHandle, CFE_FS_Head
/* We either got an error or didn't write as much data as expected */
Valid = false;
CFE_EVS_SendEvent(MM_CFE_FS_WRITEHDR_ERR_EID, CFE_EVS_EventType_ERROR,
"CFE_FS_WriteHeader error received: RC = %d Expected = %d File = '%s'", OS_Status,
"CFE_FS_WriteHeader error received: RC = %d Expected = %d File = '%s'", (int)OS_Status,
(int)sizeof(CFE_FS_Header_t), FileName);

} /* end CFE_FS_WriteHeader if */
Expand All @@ -449,7 +449,7 @@ 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 = %u File = '%s'", OS_Status,
"OS_write error received: RC = %d Expected = %u File = '%s'", (int)OS_Status,
(unsigned int)sizeof(MM_LoadDumpFileHeader_t), FileName);

} /* end OS_write if */
Expand Down Expand Up @@ -593,7 +593,7 @@ bool MM_FillDumpInEventBuffer(cpuaddr SrcAddress, const MM_DumpInEventCmd_t *Cmd
/* CFE_PSP_MemRead32 error */
Valid = false;
CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM32", PSP_Status,
"PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM32", (int)PSP_Status,
(void *)SrcAddress, (void *)DumpBuffer);
/* Stop load dump buffer loop */
break;
Expand All @@ -617,7 +617,7 @@ bool MM_FillDumpInEventBuffer(cpuaddr SrcAddress, const MM_DumpInEventCmd_t *Cmd
/* CFE_PSP_MemRead16 error */
Valid = false;
CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM16", PSP_Status,
"PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM16", (int)PSP_Status,
(void *)SrcAddress, (void *)DumpBuffer);
/* Stop load dump buffer loop */
break;
Expand All @@ -641,7 +641,7 @@ bool MM_FillDumpInEventBuffer(cpuaddr SrcAddress, const MM_DumpInEventCmd_t *Cmd
/* CFE_PSP_MemRead8 error */
Valid = false;
CFE_EVS_SendEvent(MM_PSP_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM8", PSP_Status,
"PSP read memory error: RC=%d, Src=%p, Tgt=%p, Type=MEM8", (int)PSP_Status,
(void *)SrcAddress, (void *)DumpBuffer);
/* Stop load dump buffer loop */
break;
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/mm_mem16.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ bool MM_FillMem16(cpuaddr DestAddress, const MM_FillMemCmd_t *CmdPtr)
{
NewBytesRemaining = BytesRemaining - (BytesRemaining % 2);
CFE_EVS_SendEvent(MM_FILL_MEM16_ALIGN_WARN_INF_EID, CFE_EVS_EventType_INFORMATION,
"MM_FillMem16 NumOfBytes not multiple of 2. Reducing from %d to %d.", BytesRemaining,
NewBytesRemaining);
"MM_FillMem16 NumOfBytes not multiple of 2. Reducing from %u to %u.", (unsigned int)BytesRemaining,
(unsigned int)NewBytesRemaining);
BytesRemaining = NewBytesRemaining;
}

Expand Down
6 changes: 3 additions & 3 deletions fsw/src/mm_mem32.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool MM_LoadMem32FromFile(osal_id_t FileHandle, const char *FileName, const MM_L
/* CFE_PSP_MemWrite32 error */
BytesRemaining = 0;
CFE_EVS_SendEvent(MM_PSP_WRITE_ERR_EID, CFE_EVS_EventType_ERROR,
"PSP write memory error: RC=%d, Address=%p, MemType=MEM32", PSP_Status,
"PSP write memory error: RC=%d, Address=%p, MemType=MEM32", (int)PSP_Status,
(void *)DataPointer32);
/* Stop load segment loop */
break;
Expand Down Expand Up @@ -236,8 +236,8 @@ bool MM_FillMem32(cpuaddr DestAddress, const MM_FillMemCmd_t *CmdPtr)
{
NewBytesRemaining = BytesRemaining - (BytesRemaining % 4);
CFE_EVS_SendEvent(MM_FILL_MEM32_ALIGN_WARN_INF_EID, CFE_EVS_EventType_INFORMATION,
"MM_FillMem32 NumOfBytes not multiple of 4. Reducing from %d to %d.", BytesRemaining,
NewBytesRemaining);
"MM_FillMem32 NumOfBytes not multiple of 4. Reducing from %d to %d.", (int)BytesRemaining,
(int)NewBytesRemaining);
BytesRemaining = NewBytesRemaining;
}

Expand Down
12 changes: 2 additions & 10 deletions unit-test/mm_mem16_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,10 @@ void MM_FillMem16_Test_Align(void)
{
MM_FillMemCmd_t CmdPacket;
uint32 DestAddress = 1;
CmdPacket.Payload.NumOfBytes = 3;
CmdPacket.Payload.FillPattern = 3;
int32 strCmpResult;
char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];
bool Result;

snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH,
"MM_FillMem16 NumOfBytes not multiple of 2. Reducing from %%d to %%d.");
CmdPacket.Payload.NumOfBytes = 3;
CmdPacket.Payload.FillPattern = 3;

/* Execute the function being tested */
Result = MM_FillMem16(DestAddress, &CmdPacket);
Expand All @@ -488,10 +484,6 @@ void MM_FillMem16_Test_Align(void)
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, MM_FILL_MEM16_ALIGN_WARN_INF_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_INFORMATION);

strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec);

call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));

UtAssert_True(call_count_CFE_EVS_SendEvent == 1, "CFE_EVS_SendEvent was called %u time(s), expected 1",
Expand Down

0 comments on commit acab315

Please sign in to comment.