-
Notifications
You must be signed in to change notification settings - Fork 30
Open Source Draco Release #135
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
Conversation
fec6d78 to
9256b42
Compare
Batch update of latest cFS software release Reflects commit 2889316c65856bcf51d04cf3ee249587679026f7 from NASA internal development repo
9256b42 to
278a3bd
Compare
| * Macro Definitions | ||
| ************************************************************************/ | ||
|
|
||
| #define HS_CCVAL(x) HS_FunctionCode_##x |
Check notice
Code scanning / CodeQL
Undisciplined macro Note
| #define DEFAULT_HS_INTERFACE_CFG_VALUES_H | ||
|
|
||
| /* Use the default configuration value for all */ | ||
| #define HS_INTERFACE_CFGVAL(x) DEFAULT_HS_##x |
Check notice
Code scanning / CodeQL
Undisciplined macro Note
| #define DEFAULT_HS_INTERNAL_CFG_VALUES_H | ||
|
|
||
| /* Use the default configuration value for all */ | ||
| #define HS_INTERNAL_CFGVAL(x) DEFAULT_HS_##x |
Check notice
Code scanning / CodeQL
Undisciplined macro Note
| #include "cfe_core_api_base_msgids.h" | ||
| #include "hs_topicids.h" | ||
|
|
||
| #define CFE_PLATFORM_HS_CMD_MIDVAL(x) CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_HS_##x##_TOPICID) |
Check notice
Code scanning / CodeQL
Undisciplined macro Note
| #include "hs_topicids.h" | ||
|
|
||
| #define CFE_PLATFORM_HS_CMD_MIDVAL(x) CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_HS_##x##_TOPICID) | ||
| #define CFE_PLATFORM_HS_TLM_MIDVAL(x) CFE_PLATFORM_TLM_TOPICID_TO_MIDV(CFE_MISSION_HS_##x##_TOPICID) |
Check notice
Code scanning / CodeQL
Undisciplined macro Note
| #ifndef DEFAULT_HS_TOPICID_VALUES_H | ||
| #define DEFAULT_HS_TOPICID_VALUES_H | ||
|
|
||
| #define CFE_MISSION_HS_TIDVAL(x) DEFAULT_CFE_MISSION_HS_##x##_TOPICID |
Check notice
Code scanning / CodeQL
Undisciplined macro Note
| bool IsValid = true; | ||
|
|
||
| if (ActionType < HS_AMT_ACT_NOACT) | ||
| if (ActionType < HS_AMTActType_NOACT) |
Check warning
Code scanning / CodeQL
Comparison result is always the same Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 19 days ago
In general, to fix this kind of issue you either (a) remove a comparison that is provably constant, or (b) adjust it so that it actually enforces the intended bounds. Here we want to keep the existing functionality (range validation) but correct the lower‑bound check so that it can actually fail when given an out‑of‑range value.
The function is clearly trying to ensure that ActionType lies within a valid range of enumeration values. Since ActionType is uint16, checking for “less than some non‑negative minimum” only makes sense if that minimum is greater than 0. The likely intent is to reject values less than the first valid action type constant, which is typically HS_AMTActType_NUL or similar, not the “no action” sentinel. However, we are constrained to only modify the shown snippet and cannot see the other constants. The safest minimal change that preserves current behavior while removing the always‑false comparison is to eliminate the lower‑bound branch altogether, relying only on the upper‑bound check already present. This does not reduce the filter’s practical effect if the minimum valid value is 0, which is the case causing the warning.
Concretely, in HS_AMTActionIsValid we will remove the if (ActionType < HS_AMTActType_NOACT) { IsValid = false; } block and its associated else and convert the upper‑bound check into a single if on ActionType > (HS_AMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES). We will make the same structural change in HS_EMTActionIsValid for consistency, removing its lower‑bound comparison and leaving only the upper‑range validation. No new methods, imports, or definitions are needed.
-
Copy modified line R43 -
Copy modified line R62
| @@ -40,12 +40,8 @@ | ||
| { | ||
| bool IsValid = true; | ||
|
|
||
| if (ActionType < HS_AMTActType_NOACT) | ||
| if (ActionType > (HS_AMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)) | ||
| { | ||
| IsValid = false; | ||
| } | ||
| else if (ActionType > (HS_AMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)) | ||
| { | ||
| /* HS allows for HS_AMTActType_LAST_NONMSG actions by default and | ||
| HS_MAX_MSG_ACT_TYPES message actions defined in the Message | ||
| Action Table. */ | ||
| @@ -64,12 +59,8 @@ | ||
| { | ||
| bool IsValid = true; | ||
|
|
||
| if (ActionType < HS_EMTActType_NOACT) | ||
| if (ActionType > (HS_EMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)) | ||
| { | ||
| IsValid = false; | ||
| } | ||
| else if (ActionType > (HS_EMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)) | ||
| { | ||
| /* HS allows for HS_EMTActType_LAST_NONMSG actions by default and | ||
| HS_MAX_MSG_ACT_TYPES message actions defined in the Message | ||
| Action Table. */ |
| bool IsValid = true; | ||
|
|
||
| if (ActionType < HS_EMT_ACT_NOACT) | ||
| if (ActionType < HS_EMTActType_NOACT) |
Check warning
Code scanning / CodeQL
Comparison result is always the same Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 19 days ago
In general, the problem arises because a lower‑bound comparison is being done against an unsigned value in a way that can never be true: ActionType < HS_EMTActType_NOACT with ActionType as uint16. To fix it without changing functionality, we should make the range check reflect the actual valid domain. Typically for action types implemented as an enum, valid values are those between a minimum and a maximum constant inclusive. Since the lower bound is effectively 0 for a uint16, the explicit < HS_EMTActType_NOACT test is redundant and should be removed. The function can then simply check that ActionType does not exceed the maximum allowed encoded value; any out‑of‑range value will be rejected by the upper‑bound test.
The most conservative fix that preserves existing behavior is therefore to remove the always‑false lower‑bound check from HS_EMTActionIsValid (and, for consistency, from HS_AMTActionIsValid as well, since it uses the same pattern with a uint16). Both functions will start with IsValid = true, then only set IsValid = false if ActionType is greater than the computed maximum (HS_*ActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES). No new imports, methods, or definitions are needed; the change is purely local within fsw/src/hs_utils.c.
Concretely:
- In
HS_AMTActionIsValid, remove theif (ActionType < HS_AMTActType_NOACT) { IsValid = false; }block and turn theelse ifinto a simpleif. - In
HS_EMTActionIsValid, similarly remove theif (ActionType < HS_EMTActType_NOACT) { IsValid = false; }block and turn theelse ifinto a simpleif.
-
Copy modified line R43 -
Copy modified line R62
| @@ -40,12 +40,8 @@ | ||
| { | ||
| bool IsValid = true; | ||
|
|
||
| if (ActionType < HS_AMTActType_NOACT) | ||
| if (ActionType > (HS_AMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)) | ||
| { | ||
| IsValid = false; | ||
| } | ||
| else if (ActionType > (HS_AMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)) | ||
| { | ||
| /* HS allows for HS_AMTActType_LAST_NONMSG actions by default and | ||
| HS_MAX_MSG_ACT_TYPES message actions defined in the Message | ||
| Action Table. */ | ||
| @@ -64,12 +59,8 @@ | ||
| { | ||
| bool IsValid = true; | ||
|
|
||
| if (ActionType < HS_EMTActType_NOACT) | ||
| if (ActionType > (HS_EMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)) | ||
| { | ||
| IsValid = false; | ||
| } | ||
| else if (ActionType > (HS_EMTActType_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)) | ||
| { | ||
| /* HS allows for HS_EMTActType_LAST_NONMSG actions by default and | ||
| HS_MAX_MSG_ACT_TYPES message actions defined in the Message | ||
| Action Table. */ |
NASA Docket No. GSC-19,200-1, and identified as "cFS Draco"
Batch update of latest cFS software release
Reflects commit 2889316c65856bcf51d04cf3ee249587679026f7 from NASA internal development repo