From 624e72e5d1dbade3328db79f8924938835412792 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 11 Jan 2024 08:55:48 -0500 Subject: [PATCH] Fix #64, correct format spec strings and types Resolves mismatches between format strings and the data types --- fsw/src/md_app.c | 32 ++++++++++++++++---------------- fsw/src/md_cmds.c | 6 +++--- fsw/src/md_dwell_tbl.c | 14 +++++++------- unit-test/md_dwell_tbl_tests.c | 4 ++-- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/fsw/src/md_app.c b/fsw/src/md_app.c index ee671f1..3ef7a0b 100644 --- a/fsw/src/md_app.c +++ b/fsw/src/md_app.c @@ -69,7 +69,7 @@ void MD_AppMain(void) if (Status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("MD:Application Init Failed,RC=%d\n", Status); + CFE_ES_WriteToSysLog("MD:Application Init Failed,RC=%08x\n", (unsigned int)Status); MD_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR; } @@ -97,7 +97,7 @@ void MD_AppMain(void) ** Exit on pipe read error */ CFE_EVS_SendEvent(MD_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, - "SB Pipe Read Error, App will exit. Pipe Return Status = %d", Status); + "SB Pipe Read Error, App will exit. Pipe Return Status = %08x", (unsigned int)Status); MD_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR; } @@ -194,7 +194,7 @@ CFE_Status_t MD_AppInit(void) } else { - CFE_ES_WriteToSysLog("MD_APP:Call to CFE_EVS_Register Failed:RC=%d\n", Status); + CFE_ES_WriteToSysLog("MD_APP:Call to CFE_EVS_Register Failed:RC=%d\n", (unsigned int)Status); } /* @@ -280,12 +280,12 @@ CFE_Status_t MD_InitSoftwareBusServices(void) if (Status != CFE_SUCCESS) { CFE_EVS_SendEvent(MD_SUB_HK_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to subscribe to HK requests RC = %d", - Status); + (unsigned int)Status); } } else { - CFE_EVS_SendEvent(MD_CREATE_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to create pipe. RC = %d", Status); + CFE_EVS_SendEvent(MD_CREATE_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to create pipe. RC = %d", (unsigned int)Status); } /* @@ -298,7 +298,7 @@ CFE_Status_t MD_InitSoftwareBusServices(void) if (Status != CFE_SUCCESS) { CFE_EVS_SendEvent(MD_SUB_CMD_ERR_EID, CFE_EVS_EventType_ERROR, "Failed to subscribe to commands. RC = %d", - Status); + (unsigned int)Status); } } @@ -312,7 +312,7 @@ CFE_Status_t MD_InitSoftwareBusServices(void) if (Status != CFE_SUCCESS) { CFE_EVS_SendEvent(MD_SUB_WAKEUP_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to subscribe to wakeup messages. RC = %d", Status); + "Failed to subscribe to wakeup messages. RC = %08x", (unsigned int)Status); } } @@ -348,7 +348,7 @@ CFE_Status_t MD_InitTableServices(void) if (Status < 0) { CFE_EVS_SendEvent(MD_INIT_TBL_NAME_ERR_EID, CFE_EVS_EventType_ERROR, - "TableName could not be made. Err=0x%08X, Idx=%d", Status, TblIndex); + "TableName could not be made. Err=0x%08X, Idx=%u", (unsigned int)Status, (unsigned int)TblIndex); TableInitValidFlag = false; @@ -362,7 +362,7 @@ CFE_Status_t MD_InitTableServices(void) if (Status < 0) { CFE_EVS_SendEvent(MD_INIT_TBL_FILENAME_ERR_EID, CFE_EVS_EventType_ERROR, - "TblFileName could not be made. Err=0x%08X, Idx=%d", Status, TblIndex); + "TblFileName could not be made. Err=0x%08X, Idx=%u", (unsigned int)Status, (unsigned int)TblIndex); TableInitValidFlag = false; @@ -433,7 +433,7 @@ CFE_Status_t MD_InitTableServices(void) else if (Status != CFE_SUCCESS) { CFE_EVS_SendEvent(MD_TBL_REGISTER_CRIT_EID, CFE_EVS_EventType_CRITICAL, - "CFE_TBL_Register error %d received for tbl#%d", Status, TblIndex + 1); + "CFE_TBL_Register error %08x received for tbl#%u", (unsigned int)Status, (unsigned int)TblIndex + 1); TableInitValidFlag = false; } else @@ -455,8 +455,8 @@ CFE_Status_t MD_InitTableServices(void) if (Status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("MD_APP: Error 0x%08X received loading tbl#%d\n", (unsigned int)Status, - TblIndex + 1); + CFE_ES_WriteToSysLog("MD_APP: Error 0x%08X received loading tbl#%u\n", (unsigned int)Status, + (unsigned int)TblIndex + 1); TableInitValidFlag = false; } else @@ -475,7 +475,7 @@ CFE_Status_t MD_InitTableServices(void) /* Output init and recovery event message */ CFE_EVS_SendEvent(MD_TBL_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, - "Dwell Tables Recovered: %d, Dwell Tables Initialized: %d", TblRecos, TblInits); + "Dwell Tables Recovered: %u, Dwell Tables Initialized: %u", TblRecos, TblInits); if (TableInitValidFlag == true) { @@ -533,8 +533,8 @@ CFE_Status_t MD_ManageDwellTable(uint8 TblIndex) else { CFE_EVS_SendEvent(MD_NO_TBL_COPY_ERR_EID, CFE_EVS_EventType_ERROR, - "Didn't update MD tbl #%d due to unexpected CFE_TBL_GetAddress return: %d", - TblIndex + 1, GetAddressResult); + "Didn't update MD tbl #%d due to unexpected CFE_TBL_GetAddress return: %u", + (unsigned int)TblIndex + 1, (unsigned int)GetAddressResult); } /* Unlock Table */ @@ -548,7 +548,7 @@ CFE_Status_t MD_ManageDwellTable(uint8 TblIndex) else if ((Status & CFE_SEVERITY_BITMASK) == CFE_SEVERITY_ERROR) { CFE_EVS_SendEvent(MD_TBL_STATUS_ERR_EID, CFE_EVS_EventType_ERROR, - "Received unexpected error %d from CFE_TBL_GetStatus for tbl #%d", Status, TblIndex + 1); + "Received unexpected error %08x from CFE_TBL_GetStatus for tbl #%u", (unsigned int)Status, (unsigned int)TblIndex + 1); FinishedManaging = true; } diff --git a/fsw/src/md_cmds.c b/fsw/src/md_cmds.c index 36b068f..8af2fe1 100644 --- a/fsw/src/md_cmds.c +++ b/fsw/src/md_cmds.c @@ -115,7 +115,7 @@ void MD_ProcessStartCmd(const CFE_SB_Buffer_t *BufPtr) CFE_EVS_SendEvent(MD_START_DWELL_ERR_EID, CFE_EVS_EventType_ERROR, "Start Dwell Table for mask 0x%04X failed for %d of %d tables", Start->Payload.TableMask, - ErrorCount, NumTblInMask); + (int)ErrorCount, (int)NumTblInMask); } } else /* No valid table id's specified in mask */ @@ -176,7 +176,7 @@ void MD_ProcessStopCmd(const CFE_SB_Buffer_t *BufPtr) CFE_EVS_SendEvent(MD_STOP_DWELL_ERR_EID, CFE_EVS_EventType_ERROR, "Stop Dwell Table for mask 0x%04X failed for %d of %d tables", Stop->Payload.TableMask, - ErrorCount, NumTblInMask); + (int)ErrorCount, (int)NumTblInMask); } } else @@ -466,7 +466,7 @@ void MD_ProcessSignatureCmd(const CFE_SB_Buffer_t *BufPtr) else { CFE_EVS_SendEvent(MD_SET_SIGNATURE_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to set signature for Dwell Tbl#%d. Update returned 0x%08X", TblId, Status); + "Failed to set signature for Dwell Tbl#%d. Update returned 0x%08X", (int)TblId, (unsigned int)Status); MD_AppData.ErrCounter++; } diff --git a/fsw/src/md_dwell_tbl.c b/fsw/src/md_dwell_tbl.c index 3b87465..e9fe135 100644 --- a/fsw/src/md_dwell_tbl.c +++ b/fsw/src/md_dwell_tbl.c @@ -220,7 +220,7 @@ int32 MD_CheckTableEntries(MD_DwellTableLoad_t *TblPtr, uint16 *ErrorEntryArg) /* Keep counting good,bad,unused, don't exit immediately */ CFE_EVS_SendEvent(MD_TBL_ENTRY_ERR_EID, CFE_EVS_EventType_ERROR, - "Table entry %d failed with status 0x%08X", EntryIndex, Status); + "Table entry %d failed with status 0x%08X", (int)EntryIndex, (unsigned int)Status); } } } @@ -343,8 +343,8 @@ CFE_Status_t MD_UpdateTableEnabledField(uint16 TableIndex, uint16 FieldValue) if ((Status != CFE_SUCCESS) && (Status != CFE_TBL_INFO_UPDATED)) { CFE_EVS_SendEvent(MD_UPDATE_TBL_EN_ERR_EID, CFE_EVS_EventType_ERROR, - "MD_UpdateTableEnabledField, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", TableIndex, - Status); + "MD_UpdateTableEnabledField, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", (int)TableIndex, + (unsigned int)Status); } else { @@ -375,8 +375,8 @@ CFE_Status_t MD_UpdateTableDwellEntry(uint16 TableIndex, uint16 EntryIndex, uint if ((Status != CFE_SUCCESS) && (Status != CFE_TBL_INFO_UPDATED)) { CFE_EVS_SendEvent(MD_UPDATE_TBL_DWELL_ERR_EID, CFE_EVS_EventType_ERROR, - "MD_UpdateTableDwellEntry, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", TableIndex, - Status); + "MD_UpdateTableDwellEntry, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", (int)TableIndex, + (unsigned int)Status); } else { @@ -420,8 +420,8 @@ CFE_Status_t MD_UpdateTableSignature(uint16 TableIndex, char NewSignature[MD_SIG if ((Status != CFE_SUCCESS) && (Status != CFE_TBL_INFO_UPDATED)) { CFE_EVS_SendEvent(MD_UPDATE_TBL_SIG_ERR_EID, CFE_EVS_EventType_ERROR, - "MD_UpdateTableSignature, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", TableIndex, - Status); + "MD_UpdateTableSignature, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", (int)TableIndex, + (unsigned int)Status); } else { diff --git a/unit-test/md_dwell_tbl_tests.c b/unit-test/md_dwell_tbl_tests.c index 2748ecc..5f75172 100644 --- a/unit-test/md_dwell_tbl_tests.c +++ b/unit-test/md_dwell_tbl_tests.c @@ -721,7 +721,7 @@ void MD_ValidTableEntry_Test_InvalidLength(void) Result = MD_ValidTableEntry(&Entry); /* Verify results */ - UtAssert_True(Result == MD_INVALID_LEN_ERROR, "Result == MD_INVALID_LEN_ERROR 0x%x", Result); + UtAssert_INT32_EQ(Result, MD_INVALID_LEN_ERROR); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); @@ -850,7 +850,7 @@ void MD_ValidTableEntry_Test_NotAligned16DwellLength2(void) Result = MD_ValidTableEntry(&Entry); /* Verify results */ - UtAssert_True(Result == MD_NOT_ALIGNED_ERROR, "Result == MD_NOT_ALIGNED_ERROR 0x%x", Result); + UtAssert_INT32_EQ(Result, MD_NOT_ALIGNED_ERROR); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));