Skip to content
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

Redundant Assignments and Unread Variables #183

Closed
skliper opened this issue Sep 30, 2019 · 2 comments
Closed

Redundant Assignments and Unread Variables #183

skliper opened this issue Sep 30, 2019 · 2 comments

Comments

@skliper
Copy link
Contributor

skliper commented Sep 30, 2019

One common anti-pattern in cFS is to call functions that return
potential error codes, store the return values in variables, then
never bother to check the value of the variable.

cppcheck reports this as a redundant assignment.

Current cases in CFE:

(redundantAssignment)
{{{
cfe/fsw/cfe-core/src/evs/cfe_evs_task.c:1395: performance: Variable 'Status' is reassigned a value before the old one has been used.
cfe/fsw/cfe-core/src/evs/cfe_evs_task.c:1385: performance: Variable 'Status' is reassigned a value before the old one has been used.
}}}

(unreadVariable)
{{{
cfe/fsw/cfe-core/src/es/cfe_es_start.c:486: style: Variable 'status' is assigned a value that is never used.
cfe/fsw/cfe-core/src/es/cfe_es_api.c:469: style: Variable 'ReturnCode' is assigned a value that is never used.
cfe/fsw/cfe-core/src/es/cfe_es_api.c:1964: style: Variable 'Status' is assigned a value that is never used.
cfe/fsw/cfe-core/src/es/cfe_es_apps.c:740: style: Variable 'ReturnCode' is assigned a value that is never used.
cfe/fsw/cfe-core/src/es/cfe_es_apps.c:971: style: Variable 'ReturnCode' is assigned a value that is never used.
}}}

Not sure how we missed this in the 2016-04-12 sweep.

@skliper skliper self-assigned this Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Imported from trac issue 152. Created by glimes on 2016-04-18T12:20:34, last modified: 2019-04-01T16:46:19

@skliper skliper added the bug label Sep 30, 2019
@skliper skliper removed their assignment Sep 30, 2019
@skliper skliper added this to the 6.8.0 milestone Nov 4, 2019
@skliper skliper added duplicate and removed bug labels Jan 2, 2020
@skliper skliper removed this from the 6.8.0 milestone Jan 2, 2020
@skliper
Copy link
Contributor Author

skliper commented Jan 2, 2020

#425 documents and #432 resolves cppcheck issues in the current code base. Closing this as duplicate.

@skliper skliper closed this as completed Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant