-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
Checklist
- I reviewed the Contributing Guide.
- I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.
Describe the bug
count_check and ret are only used once, so they are unnecessary and can be removed.
chan_index and cc don't seem to get updated so can be initialized once instead of in every run through the loop.
Code snips
Lines 1480 to 1541 in ba12bc1
| void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan) | |
| { | |
| CF_Poll_t * poll; | |
| CF_ChannelConfig_t *cc; | |
| CF_PollDir_t * pd; | |
| int i; | |
| int chan_index; | |
| int count_check; | |
| int ret; | |
| for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i) | |
| { | |
| poll = &chan->poll[i]; | |
| chan_index = (chan - CF_AppData.engine.channels); | |
| cc = &CF_AppData.config_table->chan[chan_index]; | |
| pd = &cc->polldir[i]; | |
| count_check = 0; | |
| if (pd->enabled) | |
| { | |
| if (!poll->pb.busy && !poll->pb.num_ts) | |
| { | |
| if (!poll->timer_set && pd->interval_sec) | |
| { | |
| /* timer was not set, so set it now */ | |
| CF_Timer_InitRelSec(&poll->interval_timer, pd->interval_sec); | |
| poll->timer_set = 1; | |
| } | |
| else if (CF_Timer_Expired(&poll->interval_timer)) | |
| { | |
| /* the timer has expired */ | |
| ret = CF_CFDP_PlaybackDir_Initiate(&poll->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, | |
| chan_index, pd->priority, pd->dest_eid); | |
| if (!ret) | |
| { | |
| poll->timer_set = 0; | |
| } | |
| else | |
| { | |
| /* error occurred in playback directory, so reset the timer */ | |
| /* an event is sent in CF_CFDP_PlaybackDir_Initiate so there is no reason to | |
| * to have another here */ | |
| CF_Timer_InitRelSec(&poll->interval_timer, pd->interval_sec); | |
| } | |
| } | |
| else | |
| { | |
| CF_Timer_Tick(&poll->interval_timer); | |
| } | |
| } | |
| else | |
| { | |
| /* playback is active, so step it */ | |
| CF_CFDP_ProcessPlaybackDirectory(chan, &poll->pb); | |
| } | |
| count_check = 1; | |
| } | |
| CF_CFDP_UpdatePollPbCounted(&poll->pb, count_check, &CF_AppData.hk.Payload.channel_hk[chan_index].poll_counter); | |
| } | |
| } |
Expected behavior
Simplify where possible to improve clarify and ease future maintenance.
Reporter Info
Avi Weiss @thnkslprpt
Metadata
Metadata
Assignees
Labels
No labels