Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CF_CFDP_ProcessPollingDirectories() can be simplified #467

Open
2 tasks done
thnkslprpt opened this issue Nov 28, 2024 · 0 comments · May be fixed by #468
Open
2 tasks done

CF_CFDP_ProcessPollingDirectories() can be simplified #467

thnkslprpt opened this issue Nov 28, 2024 · 0 comments · May be fixed by #468

Comments

@thnkslprpt
Copy link
Contributor

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

CF/fsw/src/cf_cfdp.c

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

thnkslprpt added a commit to thnkslprpt/CF that referenced this issue Nov 28, 2024
@thnkslprpt thnkslprpt linked a pull request Nov 28, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant