Fix #52, Remove initializations causing Cppcheck errors #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Describe the contribution
Fixes #52
Note: all are local variables only.
In order of the errors reported in the issue report:
hs_cmds.c
int32 Status = CFE_SUCCESS;
: The only uses ofStatus
are after it has been set, and given that this is avoid
function, there seems no need to have it initialized to a default value at the top of the function.hs_custom.c
uint32 j = 0;
:j
is assigned a value before each use, so this can be changed from an initialization to a declaration.uint32 ThisValue = 0;
:ThisValue
is assigned a value before its use in a mutually exclusiveif
/else
statement beginning on line 292. Therefore, this is also safe to change to declaration-only.uint32 Ordinal = 0;
:Ordinal
is assigned a value before its first use (on line 327).uint32 NewOrdinalIndex = 0;
:NewOrdinalIndex
is assigned a value on line 338 before its first use.hs_monitors.c
In the
HS_MonitorApplications()
function:int32 Status = CFE_SUCCESS;
:Status
is assigned a value (on line 65) before it is used, and this assignment covers all of its references. Given that this is avoid
function, there is no issue with someone trying to potentially returnStatus
uninitialized if it doesn't get set somehow during the function logic (similar to the first case forStatus
in hs_cmds.c).uint16 ActionType = 0;
:ActionType
is assigned a value (on line 58) before any and all of its references.In the
HS_MonitorEvent()
function:uint16 ActionType = 0;
:ActionType
is assigned a value (on line 234) before any and all of its references.In the
HS_ValidateAMTable()
function:int32 EntryResult = 0;
:EntryResult
is assigned a value (on line 482) before any and all of its references.uint16 ActionType = 0;
:ActionType
is assigned a value (on line 479) before any and all of its references.uint16 CycleCount = 0;
:CycleCount
is assigned a value (on line 480) before any and all of its references.uint16 NullTerm = 0;
:NullTerm
is assigned a value (on line 481) before any and all of its references.In the
HS_ValidateEMTable()
function:int32 EntryResult = 0;
:EntryResult
is assigned a value (on line 573) before any and all of its references.uint16 ActionType = 0;
:ActionType
is assigned a value (on line 570) before any and all of its references.uint16 EventID = 0;
:EventID
is assigned a value (on line 571) before any and all of its references.uint16 NullTerm = 0;
:NullTerm
is assigned a value (on line 572) before any and all of its references.In the
HS_ValidateMATable()
function:uint16 EnableState = 0;
:EnableState
is assigned a value (on line 758) before any and all of its references.int32 EntryResult = 0;
:EntryResult
is assigned a value (on line 754) before any and all of its references.Testing performed
GitHub CI actions (incl. Build + Run, Unit Tests etc.) all passing successfully.
Expected behavior changes
No impact on behavior.
Cppcheck now passes without error again.
Contributor Info
Avi @thnkslprpt