Skip to content

Commit a07bf5e

Browse files
committed
Fix nasa#58, scrub all printf format codes
Use the correct printf format code and typecast for printing various values in log messages and events.
1 parent d3ae3f9 commit a07bf5e

File tree

13 files changed

+331
-561
lines changed

13 files changed

+331
-561
lines changed

fsw/src/cf_app.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,23 @@ void CF_CheckTables(void)
8484
if (status < CFE_SUCCESS)
8585
{
8686
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_CHECK_REL, CFE_EVS_EventType_ERROR,
87-
"CF: error in CFE_TBL_ReleaseAddress (check), returned 0x%08x", status);
87+
"CF: error in CFE_TBL_ReleaseAddress (check), returned 0x%08lx", (unsigned long)status);
8888
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
8989
}
9090

9191
status = CFE_TBL_Manage(CF_AppData.config_handle);
9292
if (status < CFE_SUCCESS)
9393
{
9494
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_CHECK_MAN, CFE_EVS_EventType_ERROR,
95-
"CF: error in CFE_TBL_Manage (check), returned 0x%08x", status);
95+
"CF: error in CFE_TBL_Manage (check), returned 0x%08lx", (unsigned long)status);
9696
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
9797
}
9898

9999
status = CFE_TBL_GetAddress((void *)&CF_AppData.config_table, CF_AppData.config_handle);
100100
if (status < CFE_SUCCESS)
101101
{
102102
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_CHECK_GA, CFE_EVS_EventType_ERROR,
103-
"CF: failed to get table address (check), returned 0x%08x", status);
103+
"CF: failed to get table address (check), returned 0x%08lx", (unsigned long)status);
104104
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
105105
}
106106
}
@@ -164,23 +164,23 @@ int32 CF_TableInit(void)
164164
if (status != CFE_SUCCESS)
165165
{
166166
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_REG, CFE_EVS_EventType_ERROR,
167-
"CF: error registering table, returned 0x%08x", status);
167+
"CF: error registering table, returned 0x%08lx", (unsigned long)status);
168168
goto err_out;
169169
}
170170

171171
status = CFE_TBL_Load(CF_AppData.config_handle, CFE_TBL_SRC_FILE, CF_CONFIG_TABLE_FILENAME);
172172
if (status != CFE_SUCCESS)
173173
{
174-
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_LOAD, CFE_EVS_EventType_ERROR, "CF: error loading table, returned 0x%08x",
175-
status);
174+
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_LOAD, CFE_EVS_EventType_ERROR,
175+
"CF: error loading table, returned 0x%08lx", (unsigned long)status);
176176
goto err_out;
177177
}
178178

179179
status = CFE_TBL_Manage(CF_AppData.config_handle);
180180
if (status != CFE_SUCCESS)
181181
{
182182
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_MANAGE, CFE_EVS_EventType_ERROR,
183-
"CF: error in CFE_TBL_Manage, returned 0x%08x", status);
183+
"CF: error in CFE_TBL_Manage, returned 0x%08lx", (unsigned long)status);
184184
goto err_out;
185185
}
186186

@@ -189,7 +189,7 @@ int32 CF_TableInit(void)
189189
if ((status != CFE_TBL_INFO_UPDATED) && (status != CFE_SUCCESS))
190190
{
191191
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_GETADDR, CFE_EVS_EventType_ERROR,
192-
"CF: error getting table address, returned 0x%08x", status);
192+
"CF: error getting table address, returned 0x%08lx", (unsigned long)status);
193193
goto err_out;
194194
}
195195
else
@@ -330,13 +330,13 @@ int32 CF_Init(void)
330330
if ((status = CFE_EVS_Register(cf_event_filters, sizeof(cf_event_filters) / sizeof(*cf_event_filters),
331331
CFE_EVS_EventFilter_BINARY)) != CFE_SUCCESS)
332332
{
333-
CFE_ES_WriteToSysLog("CF app: error registering with EVS, returned 0x%08x", status);
333+
CFE_ES_WriteToSysLog("CF app: error registering with EVS, returned 0x%08lx", (unsigned long)status);
334334
goto err_out;
335335
}
336336

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

@@ -367,7 +367,7 @@ int32 CF_Init(void)
367367

368368
if (status != CFE_SUCCESS)
369369
{
370-
CFE_ES_WriteToSysLog("CF: error sending init event, returned 0x%08x", status);
370+
CFE_ES_WriteToSysLog("CF: error sending init event, returned 0x%08lx", (unsigned long)status);
371371
goto err_out;
372372
}
373373

@@ -468,7 +468,7 @@ void CF_AppMain(void)
468468
else if (status != CFE_SB_TIME_OUT && status != CFE_SB_NO_MESSAGE)
469469
{
470470
CFE_EVS_SendEvent(CF_EID_ERR_INIT_MSG_RECV, CFE_EVS_EventType_ERROR,
471-
"CF: exiting due to CFE_SB_ReceiveBuffer error 0x%08x", status);
471+
"CF: exiting due to CFE_SB_ReceiveBuffer error 0x%08lx", (unsigned long)status);
472472
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
473473
}
474474
else

fsw/src/cf_cfdp.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ int CF_CFDP_RecvMd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
672672
if (!CF_CODEC_IS_OK(ph->pdec))
673673
{
674674
CFE_EVS_SendEvent(CF_EID_ERR_PDU_MD_SHORT, CFE_EVS_EventType_ERROR,
675-
"CF: metadata packet too short: %lu bytes received", CF_CODEC_GET_SIZE(ph->pdec));
675+
"CF: metadata packet too short: %lu bytes received",
676+
(unsigned long)CF_CODEC_GET_SIZE(ph->pdec));
676677
goto err_out;
677678
}
678679

@@ -748,7 +749,7 @@ int CF_CFDP_RecvFd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
748749
if (!CF_CODEC_IS_OK(ph->pdec))
749750
{
750751
CFE_EVS_SendEvent(CF_EID_ERR_PDU_FD_SHORT, CFE_EVS_EventType_ERROR,
751-
"CF: filedata pdu too short: %lu bytes received", CF_CODEC_GET_SIZE(ph->pdec));
752+
"CF: filedata pdu too short: %lu bytes received", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec));
752753
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.error;
753754
ret = -1;
754755
}
@@ -782,7 +783,7 @@ int CF_CFDP_RecvEof(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
782783
if (!CF_CODEC_IS_OK(ph->pdec))
783784
{
784785
CFE_EVS_SendEvent(CF_EID_ERR_PDU_EOF_SHORT, CFE_EVS_EventType_ERROR,
785-
"CF: eof pdu too short: %lu bytes received", CF_CODEC_GET_SIZE(ph->pdec));
786+
"CF: eof pdu too short: %lu bytes received", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec));
786787
ret = -1;
787788
}
788789

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

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

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

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

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

@@ -1016,8 +1017,8 @@ int32 CF_CFDP_InitEngine(void)
10161017
if (ret != OS_SUCCESS)
10171018
{
10181019
CFE_EVS_SendEvent(CF_EID_ERR_INIT_SEM, CFE_EVS_EventType_ERROR,
1019-
"CF: failed to get sem id for name %s, error=0x%08x",
1020-
CF_AppData.config_table->chan[i].sem_name, ret);
1020+
"CF: failed to get sem id for name %s, error=%ld",
1021+
CF_AppData.config_table->chan[i].sem_name, (long)ret);
10211022
goto err_out;
10221023
}
10231024
}
@@ -1253,9 +1254,10 @@ static void CF_CFDP_TxFile_Initiate(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_cl
12531254
uint8 priority, CF_EntityId_t dest_id)
12541255
{
12551256
CFE_EVS_SendEvent(CF_EID_INF_CFDP_S_START_SEND, CFE_EVS_EventType_INFORMATION,
1256-
"CF: start class %d tx of file %d:%.*s -> %d:%.*s", cfdp_class + 1,
1257-
CF_AppData.config_table->local_eid, CF_FILENAME_MAX_LEN, t->history->fnames.src_filename, dest_id,
1258-
CF_FILENAME_MAX_LEN, t->history->fnames.dst_filename);
1257+
"CF: start class %d tx of file %lu:%.*s -> %lu:%.*s", cfdp_class + 1,
1258+
(unsigned long)CF_AppData.config_table->local_eid, CF_FILENAME_MAX_LEN,
1259+
t->history->fnames.src_filename, (unsigned long)dest_id, CF_FILENAME_MAX_LEN,
1260+
t->history->fnames.dst_filename);
12591261

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

@@ -1332,7 +1334,7 @@ static int32 CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *p, const char *src_file
13321334
if (ret != OS_SUCCESS)
13331335
{
13341336
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_OPENDIR, CFE_EVS_EventType_ERROR,
1335-
"CF: failed to open playback directory %s, error=0x%08x", src_filename, ret);
1337+
"CF: failed to open playback directory %s, error=%ld", src_filename, (long)ret);
13361338
++CF_AppData.hk.channel_hk[chan].counters.fault.directory_read;
13371339
goto err_out;
13381340
}

fsw/src/cf_cfdp_dispatch.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
6666
{
6767
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.spurious;
6868
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_DC_INV, CFE_EVS_EventType_ERROR,
69-
"CF R%d(%u:%u): received pdu with invalid directive code %d for sub-state %d",
70-
(t->state == CF_TxnState_R2), t->history->src_eid, t->history->seq_num,
71-
fdh->directive_code, t->state_data.r.sub_state);
69+
"CF R%d(%lu:%lu): received pdu with invalid directive code %d for sub-state %d",
70+
(t->state == CF_TxnState_R2), (unsigned long)t->history->src_eid,
71+
(unsigned long)t->history->seq_num, fdh->directive_code, t->state_data.r.sub_state);
7272
}
7373
}
7474
else
@@ -127,16 +127,16 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
127127
{
128128
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.spurious;
129129
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_DC_INV, CFE_EVS_EventType_ERROR,
130-
"CF S%d(%u:%u): received pdu with invalid directive code %d for sub-state %d",
131-
(t->state == CF_TxnState_S2), t->history->src_eid, t->history->seq_num,
132-
fdh->directive_code, t->state_data.s.sub_state);
130+
"CF S%d(%lu:%lu): received pdu with invalid directive code %d for sub-state %d",
131+
(t->state == CF_TxnState_S2), (unsigned long)t->history->src_eid,
132+
(unsigned long)t->history->seq_num, fdh->directive_code, t->state_data.s.sub_state);
133133
}
134134
}
135135
else
136136
{
137137
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_NON_FD_PDU, CFE_EVS_EventType_ERROR,
138-
"CF S%d(%u:%u): received non-file directive pdu", (t->state == CF_TxnState_S2),
139-
t->history->src_eid, t->history->seq_num);
138+
"CF S%d(%lu:%lu): received non-file directive pdu", (t->state == CF_TxnState_S2),
139+
(unsigned long)t->history->src_eid, (unsigned long)t->history->seq_num);
140140
}
141141

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

0 commit comments

Comments
 (0)