You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CF uses function pointers to implement its state machines, but generally do not use a "typedef" for this, they are mostly declared inline. For example:
Not only is this hard to read, it does not facilitate or encourage any sort of uniformity/consistency in the dynamically-called functions. No doubt this is likely a contributor to the fact that some functions take a pointer to the PDU header and some do not (see #90, #91).
Recommendation to fix:
Determine a common set of arguments that all "state handler" functions are likely to need - from initial inspection, this is probably a pointer to the transaction structure, a pointer to the current PDU header, and a generic/opaque argument for any additional data (this may or may not be needed/used now, but future proofs the calling conventions in case state-specific data becomes needed)
Declare a global-scope function pointer typedef that conforms to that spec (accepting the standard set of args)
Convert all "dispatcher" code to use that typedef.
This will not only make the code more readable (function pointer syntax in C is particularly messy) but also encourage more uniformity on the arguments and patterns of state handler functions. It will likely help solve the fact that some functions read their packet data from a global, while others read it from a passed-in pointer (and mixed within the same processing cycle!).
The text was updated successfully, but these errors were encountered:
Standardize the dynamic handler functions to two basic types,
one that accepts a PDU (recv) and one that does not (send).
Also create several dispatch table types, one based on
file directive code, one based on Tx sub state, and one based
on Rx sub state.
Change the dispatcher functions to use these common types
and create new dispatcher functions where there was not
a separate function already (this makes the pattern consistent).
Make all "receive" helper functions accept a pointer to the
recieved PDU and actually use that pointer to read the data. This
substantially reduces reliance on the global and fixes some
cases where a pointer was actually passed into a function, but
ignored. This takes a significant step toward removing the
global entirely, but does not do so yet.
CF uses function pointers to implement its state machines, but generally do not use a "typedef" for this, they are mostly declared inline. For example:
CF/fsw/src/cf_cfdp.c
Lines 153 to 154 in a894069
CF/fsw/src/cf_cfdp.c
Line 170 in a894069
Not only is this hard to read, it does not facilitate or encourage any sort of uniformity/consistency in the dynamically-called functions. No doubt this is likely a contributor to the fact that some functions take a pointer to the PDU header and some do not (see #90, #91).
Recommendation to fix:
This will not only make the code more readable (function pointer syntax in C is particularly messy) but also encourage more uniformity on the arguments and patterns of state handler functions. It will likely help solve the fact that some functions read their packet data from a global, while others read it from a passed-in pointer (and mixed within the same processing cycle!).
The text was updated successfully, but these errors were encountered: