nasa / LC

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

LC_TableInit has an if/else if without an else clause and its behavior is undefined #12

Closed skliper closed 2 years ago

skliper commented 2 years ago

So at the end of the LC_TableInit function there is an odd branching

if (LC_CDS_ENABLED) { if (LC_CDS_RESTORED) { restored event } else if (LC_CDS_UPDATED) { default event } // nothing else here !!! } else { CDS disabled event } So, the question is: Can we have a scenario where LC_CDS_ENABLED is TRUE, but both LC_CDS_RESTORED and LC_CDS_UPDATED are FALSE? And IF SO: What is the desired behavior here?? This is a situation where the lack of an else clause on an "else if" most definitively is cause for concern. If that scenario cannot exist, then it would seem an "else if" is not required. Unfortunately, due to the convoluted nature of this function and those that it calls, it is would be difficult to determine if the above scenario is a possibility. Imported from GSFCCFS-1104
skliper commented 2 years ago

Code link: https://github.com/nasa/LC/blob/bb910369436b80b48bd098e8a987e2b0ad4cd1cf/fsw/src/lc_app.c#L467-L489

Behavior is not "undefined", it's behaving as intended (send an event if any of the cases match). The convoluted nature of the routine is a separate issue (#36)