Skip to content

Commit

Permalink
Merge pull request #65 from jphickey/fix-64-formatspecs
Browse files Browse the repository at this point in the history
Fix #64, correct format spec strings and types
  • Loading branch information
dzbaker authored Jan 18, 2024
2 parents 74b620b + 9d86831 commit fe60ebc
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 190 deletions.
37 changes: 21 additions & 16 deletions fsw/src/md_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -280,12 +280,13 @@ 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);
}

/*
Expand All @@ -298,7 +299,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);
}
}

Expand All @@ -312,7 +313,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);
}
}

Expand Down Expand Up @@ -348,7 +349,8 @@ 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;

Expand All @@ -362,7 +364,8 @@ 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;

Expand Down Expand Up @@ -433,7 +436,8 @@ 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
Expand All @@ -455,8 +459,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
Expand All @@ -475,7 +479,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)
{
Expand Down Expand Up @@ -533,8 +537,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 */
Expand All @@ -548,7 +552,8 @@ 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;
}

Expand Down
39 changes: 24 additions & 15 deletions fsw/src/md_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -166,7 +166,8 @@ void MD_ProcessStopCmd(const CFE_SB_Buffer_t *BufPtr)
if (ErrorCount == 0)
{
CFE_EVS_SendEvent(MD_STOP_DWELL_INF_EID, CFE_EVS_EventType_INFORMATION,
"Stop Dwell Table command processed successfully for table mask 0x%04X", Stop->Payload.TableMask);
"Stop Dwell Table command processed successfully for table mask 0x%04X",
Stop->Payload.TableMask);

MD_AppData.CmdCounter++;
}
Expand All @@ -176,7 +177,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
Expand Down Expand Up @@ -265,8 +266,8 @@ void MD_ProcessJamCmd(const CFE_SB_Buffer_t *BufPtr)
if (Status == CFE_SUCCESS)
{
CFE_EVS_SendEvent(MD_JAM_NULL_DWELL_INF_EID, CFE_EVS_EventType_INFORMATION,
"Successful Jam of a Null Dwell Entry to Dwell Tbl#%d Entry #%d", Jam->Payload.TableId,
Jam->Payload.EntryId);
"Successful Jam of a Null Dwell Entry to Dwell Tbl#%d Entry #%d",
Jam->Payload.TableId, Jam->Payload.EntryId);
}
else
{
Expand Down Expand Up @@ -311,22 +312,25 @@ void MD_ProcessJamCmd(const CFE_SB_Buffer_t *BufPtr)
AllInputsValid = false;
}
#if MD_ENFORCE_DWORD_ALIGN == 0
else if ((Jam->Payload.FieldLength == 4) && MD_Verify16Aligned(ResolvedAddr, (uint32)Jam->Payload.FieldLength) != true)
else if ((Jam->Payload.FieldLength == 4) &&
MD_Verify16Aligned(ResolvedAddr, (uint32)Jam->Payload.FieldLength) != true)
{
CFE_EVS_SendEvent(MD_JAM_ADDR_NOT_16BIT_ERR_EID, CFE_EVS_EventType_ERROR,
"Jam Cmd rejected because address 0x%08X is not 16-bit aligned", ResolvedAddr);
AllInputsValid = false;
}
#else
else if ((Jam->Payload.FieldLength == 4) && MD_Verify32Aligned(ResolvedAddr, (uint32)Jam->Payload.FieldLength) != true)
else if ((Jam->Payload.FieldLength == 4) &&
MD_Verify32Aligned(ResolvedAddr, (uint32)Jam->Payload.FieldLength) != true)
{
CFE_EVS_SendEvent(MD_JAM_ADDR_NOT_32BIT_ERR_EID, CFE_EVS_EventType_ERROR,
"Jam Cmd rejected because address 0x%08X is not 32-bit aligned",
(unsigned int)ResolvedAddr);
AllInputsValid = false;
}
#endif
else if ((Jam->Payload.FieldLength == 2) && MD_Verify16Aligned(ResolvedAddr, (uint32)Jam->Payload.FieldLength) != true)
else if ((Jam->Payload.FieldLength == 2) &&
MD_Verify16Aligned(ResolvedAddr, (uint32)Jam->Payload.FieldLength) != true)
{
CFE_EVS_SendEvent(MD_JAM_ADDR_NOT_16BIT_ERR_EID, CFE_EVS_EventType_ERROR,
"Jam Cmd rejected because address 0x%08X is not 16-bit aligned",
Expand Down Expand Up @@ -356,19 +360,21 @@ void MD_ProcessJamCmd(const CFE_SB_Buffer_t *BufPtr)
strncpy(NewDwellAddress.SymName, Jam->Payload.DwellAddress.SymName, OS_MAX_SYM_LEN - 1);
NewDwellAddress.SymName[OS_MAX_SYM_LEN - 1] = '\0';

Status = MD_UpdateTableDwellEntry(TableIndex, EntryIndex, Jam->Payload.FieldLength, Jam->Payload.DwellDelay,
NewDwellAddress);
Status = MD_UpdateTableDwellEntry(TableIndex, EntryIndex, Jam->Payload.FieldLength,
Jam->Payload.DwellDelay, NewDwellAddress);

/* Issue event */
if (Status == CFE_SUCCESS)
{
CFE_EVS_SendEvent(MD_JAM_DWELL_INF_EID, CFE_EVS_EventType_INFORMATION,
"Successful Jam to Dwell Tbl#%d Entry #%d", Jam->Payload.TableId, Jam->Payload.EntryId);
"Successful Jam to Dwell Tbl#%d Entry #%d", Jam->Payload.TableId,
Jam->Payload.EntryId);
}
else
{
CFE_EVS_SendEvent(MD_JAM_DWELL_ERR_EID, CFE_EVS_EventType_ERROR,
"Failed Jam to Dwell Tbl#%d Entry #%d", Jam->Payload.TableId, Jam->Payload.EntryId);
"Failed Jam to Dwell Tbl#%d Entry #%d", Jam->Payload.TableId,
Jam->Payload.EntryId);

AllInputsValid = false;
}
Expand Down Expand Up @@ -451,22 +457,25 @@ void MD_ProcessSignatureCmd(const CFE_SB_Buffer_t *BufPtr)
*/
{
/* Copy signature field to local dwell control structure */
strncpy(MD_AppData.MD_DwellTables[TblId - 1].Signature, SignatureCmd->Payload.Signature, MD_SIGNATURE_FIELD_LENGTH - 1);
strncpy(MD_AppData.MD_DwellTables[TblId - 1].Signature, SignatureCmd->Payload.Signature,
MD_SIGNATURE_FIELD_LENGTH - 1);
MD_AppData.MD_DwellTables[TblId - 1].Signature[MD_SIGNATURE_FIELD_LENGTH - 1] = '\0';

/* Update signature in Table Services buffer */
Status = MD_UpdateTableSignature(TblId - 1, SignatureCmd->Payload.Signature);
if (Status == CFE_SUCCESS)
{
CFE_EVS_SendEvent(MD_SET_SIGNATURE_INF_EID, CFE_EVS_EventType_INFORMATION,
"Successfully set signature for Dwell Tbl#%d to '%s'", TblId, SignatureCmd->Payload.Signature);
"Successfully set signature for Dwell Tbl#%d to '%s'", TblId,
SignatureCmd->Payload.Signature);

MD_AppData.CmdCounter++;
}
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++;
}
Expand Down
14 changes: 7 additions & 7 deletions fsw/src/md_dwell_tbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
Loading

0 comments on commit fe60ebc

Please sign in to comment.