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

Simplify message action logic to avoid unreachable branch #31

Closed
3 tasks done
skliper opened this issue Jun 13, 2022 · 0 comments · Fixed by #34
Closed
3 tasks done

Simplify message action logic to avoid unreachable branch #31

skliper opened this issue Jun 13, 2022 · 0 comments · Fixed by #34
Assignees
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Jun 13, 2022

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I reviewed the README file to see if the feature is in the major future work.
  • I performed a cursory search to see if the feature request is relevant, not redundant, nor in conflict with other tickets.

Is your feature request related to a problem? Please describe.
Branch can't be covered since there's no way to get to this decision with a ActionType <= HS_AMT_ACT_LAST_NONMSG:

HS/fsw/src/hs_monitors.c

Lines 182 to 184 in 2fc0dd9

if ((HS_AppData.MsgActsState == HS_STATE_ENABLED) &&
(ActionType > HS_AMT_ACT_LAST_NONMSG) &&
(ActionType <= (HS_AMT_ACT_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)))

This is due to ActionType already being checked here:

if ((ActionType != HS_AMT_ACT_NOACT) && (HS_AppData.AppMonCheckInCountdown[TableIndex] != 0))

All other cases of current implementation are handled. Only way to exercise this decision as false would be to introduce a bug.

Describe the solution you'd like
Slight refactor to simplify and allow full coverage - remove the NOACT case since it can never happen:

case HS_AMT_ACT_NOACT:

Also swap the logic to calculate MsgActsIndex first and just check the result for in-range.

Describe alternatives you've considered
Could do enabled check first, but it's already 9 levels deep. Better to save that for #5 to really clean up duplicated logic.

Additional context
None

Requester Info
Jacob Hageman - NASA/GSFC

@skliper skliper added this to the Draco milestone Jun 13, 2022
@skliper skliper self-assigned this Jun 13, 2022
skliper added a commit to skliper/HS that referenced this issue Jun 13, 2022
dzbaker added a commit that referenced this issue Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant