nasa / LC

The Core Flight System (cFS) Limit Checker (LC) application.
Apache License 2.0
30 stars 21 forks source link

LC has duplicate conditions leading to untestable branches #17

Closed skliper closed 2 years ago

skliper commented 2 years ago

LC_ValidateWDT has duplicate conditions in its switch statement for both DataType and OperatorID. This leads to branches that cannot be covered by unit testing.

Imported from GSFCCFS-1731

EDIT: Duplicate conditional in PUSH_RPN_DATA, since the limit is checked before the push and can never be exceeded https://github.com/nasa/LC/blob/bb910369436b80b48bd098e8a987e2b0ad4cd1cf/fsw/src/lc_action.c#L298

Setting Done to true when IllegalOperand is true makes the checks redundant https://github.com/nasa/LC/blob/bb910369436b80b48bd098e8a987e2b0ad4cd1cf/fsw/src/lc_action.c#L416-L423 https://github.com/nasa/LC/blob/bb910369436b80b48bd098e8a987e2b0ad4cd1cf/fsw/src/lc_action.c#L450 https://github.com/nasa/LC/blob/bb910369436b80b48bd098e8a987e2b0ad4cd1cf/fsw/src/lc_action.c#L321

Recommended resolutions: Remove duplicate condions in LC_ValidateWDT, replace PUSH_RPN_DATA with simple push, don't set Done when IllegalOperand.