Fix #39, Remove initializations causing Cppcheck errors #40
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 #39
Note: all are local variables only.
In order of the errors reported in the issue report:
md_cmds.c
In the
MD_ProcessStartCmd()
function:int32 Status = CFE_SUCCESS;
:Status
only has a single use (on line 88) and it is assigned a value prior to this (on line 87), so this can safely be changed from an initialization to a declaration-only.uint16 TableIndex = 0;
:TableIndex
is assigned a value (on line 80) before any and all of its references.In the
MD_ProcessStopCmd()
function:int32 Status = CFE_SUCCESS;
:Status
is assigned a value (on line 155) and is used only once on the next line. Given that this is avoid
function, there is no issue with this value being returned uninitialized if it doesn't get set somehow during the function logic or anything like that.uint16 TableIndex = 0;
:TableIndex
is assigned a value (on line 146) before any and all of its references, so this can safely be converted from an initialization to a declaration-only at the top of the function.In the
MD_ProcessJamCmd()
function:int32 Status = CFE_SUCCESS;
:Status
is used twice in this function and is assigned a value both times on the immediately preceding line (on line 261, and later on line 358).MD_DwellControlEntry_t *DwellEntryPtr = 0;
:DwellEntryPtr
is just initialized to0
, so can't be used in this state anyway. Its variables are actually assigned values on line 246 and both of its uses are after this line and covered by it.uint16 EntryIndex = 0;
:EntryIndex
is only used inside the if block which starts on line 241, and is assigned a value prior to any and all of its references on line 244.In the
MD_ProcessSignatureCmd()
function:int32 Status = CFE_SUCCESS;
:Status
is only used once (on line 458) and is assigned a value on the line immediately before this use.md_dwell_pkt.c
int32 Result = 0;
:Result
is only used once (on line 86), and is assigned a value on the immediately preceding line.uint16 EntryIndex = 0;
:EntryIndex
is assigned a value (on line 81) before any and all of its references.uint16 NumDwellAddresses = 0;
:NumDwellAddresses
is assigned a value (on line 50) before any and all of its references.md_dwell_tbl.c
int32 Status = CFE_SUCCESS;
:Status
is assigned a value (on line 192) and is only used in the mutually exclusiveif
/else
block which immediately follows this assignment.md_utils.c
int32 OS_Status = OS_SUCCESS;
:OS_Status
is only used once (on line 216) and is assigned a value on the immediately preceding line.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