-
Notifications
You must be signed in to change notification settings - Fork 202
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
CFE_SB_Default_Qos exposed globally, with internal defaults, passing structure by value #1123
Comments
@ejtimmon Note CFE_SB_Default_Qos is referenced by ds and hs (and in sch test utils) |
Passing by value is generally OK so long as the structure is small (i.e. 32 bits or less) in case the calling convention in use relies on register(s) to pass argument/return values. However if it grows larger it can become inefficient to pass by value. IIRC the one I was worried about before was But this one is only 16 bits so its probably fine. But it would be a good idea to note in the structure/declaration comments that it is passed by value and therefore needs to be kept small for this reason - so fields shouldn't be added without careful consideration. |
I understand it's OK in this case since it's small, but the extra caution/complexity and currently implementation really doesn't seem justifiable based on a lack of implementation. I'd think a generic uint and setting bits is a more flexible, future proof implementation that needs no special note. Could easily add implementations as modules and assign more bits (or have reserved/user defined bits), etc without having to redefine the elements in the structure (until bits run out). |
Sure, bit fields in an integer could work too - but then you lose the advantage of type safety protection from having it as a struct. That is, one has to declare their local variable as a I definitely agree with moving the constants out of the "private" file and into a public header file - but I would hesitate to actually change the API at this time. |
Fix #1123, Convert global CFE_SB_Default_Qos to macro
Is your feature request related to a problem? Please describe.
CFE_SB_Default_Qos is extern from cfe_sb.h (so any code including cfe_sb.h could change it's value!):
cFE/fsw/cfe-core/src/inc/cfe_sb.h
Lines 175 to 185 in c7363c8
But the defines are "internal" to SB:
cFE/fsw/cfe-core/src/sb/cfe_sb_priv.h
Lines 86 to 87 in c7363c8
Also structure passed by value:
cFE/fsw/cfe-core/src/inc/cfe_sb.h
Line 381 in c7363c8
There is no underlying implementation, so currently just a placeholder in the API.
Describe the solution you'd like
Possibly convert to bits in a uint32/16 or similar (structure is overkill), provide default and the other values publicly as defines, don't expose as a global variable.
Describe alternatives you've considered
None
Additional context
Found when working #1036, it's out of family since it's not at task global scope.
Requester Info
Jacob Hageman
The text was updated successfully, but these errors were encountered: