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

repeated assignments without using the value (unit test edition) #157

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

repeated assignments without using the value (unit test edition) #157

skliper opened this issue Sep 30, 2019 · 4 comments
Labels

Comments

@skliper
Copy link
Contributor

skliper commented Sep 30, 2019

cppcheck messages:
{{{
src/tests/mutex-test/mutex-test.c:47: performance: Variable 'status' is reassigned a value before the old one has been used.
src/tests/mutex-test/mutex-test.c:100: performance: Variable 'status' is reassigned a value before the old one has been used.
src/tests/mutex-test/mutex-test.c:154: performance: Variable 'status' is reassigned a value before the old one has been used.
src/unit-tests/oscore-test/ut_oscore_task_test.c:205: performance: Variable 'res' is reassigned a value before the old one has been used.
src/unit-tests/oscore-test/ut_oscore_task_test.c:508: performance: Variable 'res' is reassigned a value before the old one has been used.
src/unit-tests/oscore-test/ut_oscore_task_test.c:522: performance: Variable 'res' is reassigned a value before the old one has been used.
src/unit-tests/oscore-test/ut_oscore_task_test.c:594: performance: Variable 'res' is reassigned a value before the old one has been used.
(484 more lines...)
}}}

There are two lines indicating sources outside testing, a separate bug
has been filed as we may put more priority on fixing those lines than
on globally smashing this bug in the test code.

Recommended fix methods, PICK ONE:

  1. Actually check the status variables to see if an error was returned
  2. put a (void) cast on the function call instead of storing the data that is not actually ever going to be looked at. This advertises to maintainers and to the compiler and to static analysis that we are purposefully ignoring the return value of the function.
@skliper skliper self-assigned this Sep 30, 2019
@skliper skliper added the bug label Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Imported from trac issue 134. Created by glimes on 2015-12-10T14:51:26, last modified: 2019-08-14T14:11:46

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by glimes on 2015-12-10 14:52:22:

See ticket #158 for this warning outside unit test code.

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by glimes on 2015-12-31 13:00:35:

Going to start grinding on these as I have time available.
Hoping I can stare at it a bit and come up with some way
to apply a clean solution in less than ''mumble'' hours.

@skliper
Copy link
Contributor Author

skliper commented Jan 2, 2020

See also #309, these are now reported as 'style' issues by cppcheck. No plan to fix style issues in test code.

@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
Labels
Projects
None yet
Development

No branches or pull requests

1 participant