Skip to content

Commit

Permalink
Fix nasa#58, scrub all printf format codes
Browse files Browse the repository at this point in the history
Use the correct printf format code and typecast for printing
various values in log messages and events.
  • Loading branch information
jphickey committed Jan 13, 2022
1 parent d3ae3f9 commit a07bf5e
Show file tree
Hide file tree
Showing 13 changed files with 331 additions and 561 deletions.
24 changes: 12 additions & 12 deletions fsw/src/cf_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ void CF_CheckTables(void)
if (status < CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_CHECK_REL, CFE_EVS_EventType_ERROR,
"CF: error in CFE_TBL_ReleaseAddress (check), returned 0x%08x", status);
"CF: error in CFE_TBL_ReleaseAddress (check), returned 0x%08lx", (unsigned long)status);
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
}

status = CFE_TBL_Manage(CF_AppData.config_handle);
if (status < CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_CHECK_MAN, CFE_EVS_EventType_ERROR,
"CF: error in CFE_TBL_Manage (check), returned 0x%08x", status);
"CF: error in CFE_TBL_Manage (check), returned 0x%08lx", (unsigned long)status);
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
}

status = CFE_TBL_GetAddress((void *)&CF_AppData.config_table, CF_AppData.config_handle);
if (status < CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_CHECK_GA, CFE_EVS_EventType_ERROR,
"CF: failed to get table address (check), returned 0x%08x", status);
"CF: failed to get table address (check), returned 0x%08lx", (unsigned long)status);
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
}
}
Expand Down Expand Up @@ -164,23 +164,23 @@ int32 CF_TableInit(void)
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_REG, CFE_EVS_EventType_ERROR,
"CF: error registering table, returned 0x%08x", status);
"CF: error registering table, returned 0x%08lx", (unsigned long)status);
goto err_out;
}

status = CFE_TBL_Load(CF_AppData.config_handle, CFE_TBL_SRC_FILE, CF_CONFIG_TABLE_FILENAME);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_LOAD, CFE_EVS_EventType_ERROR, "CF: error loading table, returned 0x%08x",
status);
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_LOAD, CFE_EVS_EventType_ERROR,
"CF: error loading table, returned 0x%08lx", (unsigned long)status);
goto err_out;
}

status = CFE_TBL_Manage(CF_AppData.config_handle);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_MANAGE, CFE_EVS_EventType_ERROR,
"CF: error in CFE_TBL_Manage, returned 0x%08x", status);
"CF: error in CFE_TBL_Manage, returned 0x%08lx", (unsigned long)status);
goto err_out;
}

Expand All @@ -189,7 +189,7 @@ int32 CF_TableInit(void)
if ((status != CFE_TBL_INFO_UPDATED) && (status != CFE_SUCCESS))
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_GETADDR, CFE_EVS_EventType_ERROR,
"CF: error getting table address, returned 0x%08x", status);
"CF: error getting table address, returned 0x%08lx", (unsigned long)status);
goto err_out;
}
else
Expand Down Expand Up @@ -330,13 +330,13 @@ int32 CF_Init(void)
if ((status = CFE_EVS_Register(cf_event_filters, sizeof(cf_event_filters) / sizeof(*cf_event_filters),
CFE_EVS_EventFilter_BINARY)) != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("CF app: error registering with EVS, returned 0x%08x", status);
CFE_ES_WriteToSysLog("CF app: error registering with EVS, returned 0x%08lx", (unsigned long)status);
goto err_out;
}

if ((status = CFE_SB_CreatePipe(&CF_AppData.cmd_pipe, CF_PIPE_DEPTH, CF_PIPE_NAME)) != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("CF app: error creating pipe %s, returend 0x%08x", CF_PIPE_NAME, status);
CFE_ES_WriteToSysLog("CF app: error creating pipe %s, returend 0x%08lx", CF_PIPE_NAME, (unsigned long)status);
goto err_out;
}

Expand Down Expand Up @@ -367,7 +367,7 @@ int32 CF_Init(void)

if (status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("CF: error sending init event, returned 0x%08x", status);
CFE_ES_WriteToSysLog("CF: error sending init event, returned 0x%08lx", (unsigned long)status);
goto err_out;
}

Expand Down Expand Up @@ -468,7 +468,7 @@ void CF_AppMain(void)
else if (status != CFE_SB_TIME_OUT && status != CFE_SB_NO_MESSAGE)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_MSG_RECV, CFE_EVS_EventType_ERROR,
"CF: exiting due to CFE_SB_ReceiveBuffer error 0x%08x", status);
"CF: exiting due to CFE_SB_ReceiveBuffer error 0x%08lx", (unsigned long)status);
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
}
else
Expand Down
32 changes: 17 additions & 15 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,8 @@ int CF_CFDP_RecvMd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
if (!CF_CODEC_IS_OK(ph->pdec))
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_MD_SHORT, CFE_EVS_EventType_ERROR,
"CF: metadata packet too short: %lu bytes received", CF_CODEC_GET_SIZE(ph->pdec));
"CF: metadata packet too short: %lu bytes received",
(unsigned long)CF_CODEC_GET_SIZE(ph->pdec));
goto err_out;
}

Expand Down Expand Up @@ -748,7 +749,7 @@ int CF_CFDP_RecvFd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
if (!CF_CODEC_IS_OK(ph->pdec))
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_FD_SHORT, CFE_EVS_EventType_ERROR,
"CF: filedata pdu too short: %lu bytes received", CF_CODEC_GET_SIZE(ph->pdec));
"CF: filedata pdu too short: %lu bytes received", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec));
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.error;
ret = -1;
}
Expand Down Expand Up @@ -782,7 +783,7 @@ int CF_CFDP_RecvEof(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
if (!CF_CODEC_IS_OK(ph->pdec))
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_EOF_SHORT, CFE_EVS_EventType_ERROR,
"CF: eof pdu too short: %lu bytes received", CF_CODEC_GET_SIZE(ph->pdec));
"CF: eof pdu too short: %lu bytes received", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec));
ret = -1;
}

Expand All @@ -807,7 +808,7 @@ int CF_CFDP_RecvAck(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
if (!CF_CODEC_IS_OK(ph->pdec))
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_ACK_SHORT, CFE_EVS_EventType_ERROR,
"CF: ack pdu too short: %lu bytes received", CF_CODEC_GET_SIZE(ph->pdec));
"CF: ack pdu too short: %lu bytes received", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec));
ret = -1;
}

Expand All @@ -833,7 +834,7 @@ int CF_CFDP_RecvFin(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
if (!CF_CODEC_IS_OK(ph->pdec))
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_FIN_SHORT, CFE_EVS_EventType_ERROR,
"CF: fin pdu too short: %lu bytes received", CF_CODEC_GET_SIZE(ph->pdec));
"CF: fin pdu too short: %lu bytes received", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec));
ret = -1;
}

Expand All @@ -859,7 +860,7 @@ int CF_CFDP_RecvNak(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
if (!CF_CODEC_IS_OK(ph->pdec))
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_NAK_SHORT, CFE_EVS_EventType_ERROR,
"CF: nak pdu too short: %lu bytes received", CF_CODEC_GET_SIZE(ph->pdec));
"CF: nak pdu too short: %lu bytes received", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec));
ret = -1;
}

Expand Down Expand Up @@ -995,7 +996,7 @@ int32 CF_CFDP_InitEngine(void)
CF_AppData.config_table->chan[i].pipe_depth_input, nbuf)) != CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_PIPE, CFE_EVS_EventType_ERROR,
"CF: failed to create pipe %s, returned 0x%08x", nbuf, ret);
"CF: failed to create pipe %s, returned 0x%08lx", nbuf, (unsigned long)ret);
goto err_out;
}

Expand All @@ -1004,8 +1005,8 @@ int32 CF_CFDP_InitEngine(void)
CF_AppData.config_table->chan[i].pipe_depth_input)) != CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_SUB, CFE_EVS_EventType_ERROR,
"CF: failed to subscribe to MID 0x%04x, returned 0x%08x",
CF_AppData.config_table->chan[i].mid_input, ret);
"CF: failed to subscribe to MID 0x%lx, returned 0x%08lx",
(unsigned long)CF_AppData.config_table->chan[i].mid_input, (unsigned long)ret);
goto err_out;
}

Expand All @@ -1016,8 +1017,8 @@ int32 CF_CFDP_InitEngine(void)
if (ret != OS_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_SEM, CFE_EVS_EventType_ERROR,
"CF: failed to get sem id for name %s, error=0x%08x",
CF_AppData.config_table->chan[i].sem_name, ret);
"CF: failed to get sem id for name %s, error=%ld",
CF_AppData.config_table->chan[i].sem_name, (long)ret);
goto err_out;
}
}
Expand Down Expand Up @@ -1253,9 +1254,10 @@ static void CF_CFDP_TxFile_Initiate(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_cl
uint8 priority, CF_EntityId_t dest_id)
{
CFE_EVS_SendEvent(CF_EID_INF_CFDP_S_START_SEND, CFE_EVS_EventType_INFORMATION,
"CF: start class %d tx of file %d:%.*s -> %d:%.*s", cfdp_class + 1,
CF_AppData.config_table->local_eid, CF_FILENAME_MAX_LEN, t->history->fnames.src_filename, dest_id,
CF_FILENAME_MAX_LEN, t->history->fnames.dst_filename);
"CF: start class %d tx of file %lu:%.*s -> %lu:%.*s", cfdp_class + 1,
(unsigned long)CF_AppData.config_table->local_eid, CF_FILENAME_MAX_LEN,
t->history->fnames.src_filename, (unsigned long)dest_id, CF_FILENAME_MAX_LEN,
t->history->fnames.dst_filename);

CF_CFDP_InitTxnTxFile(t, cfdp_class, keep, chan, priority);

Expand Down Expand Up @@ -1332,7 +1334,7 @@ static int32 CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *p, const char *src_file
if (ret != OS_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_OPENDIR, CFE_EVS_EventType_ERROR,
"CF: failed to open playback directory %s, error=0x%08x", src_filename, ret);
"CF: failed to open playback directory %s, error=%ld", src_filename, (long)ret);
++CF_AppData.hk.channel_hk[chan].counters.fault.directory_read;
goto err_out;
}
Expand Down
16 changes: 8 additions & 8 deletions fsw/src/cf_cfdp_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
{
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.spurious;
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_DC_INV, CFE_EVS_EventType_ERROR,
"CF R%d(%u:%u): received pdu with invalid directive code %d for sub-state %d",
(t->state == CF_TxnState_R2), t->history->src_eid, t->history->seq_num,
fdh->directive_code, t->state_data.r.sub_state);
"CF R%d(%lu:%lu): received pdu with invalid directive code %d for sub-state %d",
(t->state == CF_TxnState_R2), (unsigned long)t->history->src_eid,
(unsigned long)t->history->seq_num, fdh->directive_code, t->state_data.r.sub_state);
}
}
else
Expand Down Expand Up @@ -127,16 +127,16 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
{
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.spurious;
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_DC_INV, CFE_EVS_EventType_ERROR,
"CF S%d(%u:%u): received pdu with invalid directive code %d for sub-state %d",
(t->state == CF_TxnState_S2), t->history->src_eid, t->history->seq_num,
fdh->directive_code, t->state_data.s.sub_state);
"CF S%d(%lu:%lu): received pdu with invalid directive code %d for sub-state %d",
(t->state == CF_TxnState_S2), (unsigned long)t->history->src_eid,
(unsigned long)t->history->seq_num, fdh->directive_code, t->state_data.s.sub_state);
}
}
else
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_NON_FD_PDU, CFE_EVS_EventType_ERROR,
"CF S%d(%u:%u): received non-file directive pdu", (t->state == CF_TxnState_S2),
t->history->src_eid, t->history->seq_num);
"CF S%d(%lu:%lu): received non-file directive pdu", (t->state == CF_TxnState_S2),
(unsigned long)t->history->src_eid, (unsigned long)t->history->seq_num);
}

/* check that there's a valid function pointer. if there isn't,
Expand Down
Loading

0 comments on commit a07bf5e

Please sign in to comment.