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 (real code edition) #158

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

repeated assignments without using the value (real code edition) #158

skliper opened this issue Sep 30, 2019 · 10 comments
Labels
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Sep 30, 2019

cppcheck messages:
{{{
src/os/vxworks6/osnetwork.c:73: performance: Variable 'retval' is reassigned a value before the old one has been used.
src/os/vxworks6/ostimer.c:331: style: Variable 'status' is assigned a value that is never used.
}}}

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.

It would be a good idea to check the posix and rtems implementations to see if they have the same construct in this place.

See ticket #157 for the same problem occurring very frequently in unit test code.

@skliper skliper added this to the osal-4.2 milestone Sep 30, 2019
@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 135. Created by glimes on 2015-12-10T14:52:04, last modified: 2016-01-14T11:33:37

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by glimes on 2015-12-31 13:05:51:

osnetwork:
retval is initialized to ERROR,
then is the target of an assignment.
There are no conditionals that might
cause the assignment to be skipped.
Proposed: toss the redundant initializer.

ostimer:
return value of timer_delete is captured in status
then ignored as we are already in an error path.
Proposed: since we are not checking the return value,
change status = timer_delete(...) to (void) timer_delete(...)

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by glimes on 2015-12-31 13:08:04:

... not sure why I added a "recommend accept" comment to a
ticket that I've not yet marked as work complete, much less
to a ticket where I'm the one preparing the edit ... must have
been a "wrong browser tab" error. Sorry ...

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by glimes on 2016-01-05 09:56:37:

Commit [changeset:ccd776c] trac-135-repeated-assignments-real-code is ready for merge.

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by sduran on 2016-01-08 14:34:39:

recommend accept

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by sstrege on 2016-01-10 18:28:19:

Recommend/accept

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by jphickey on 2016-01-11 13:11:40:

recommend accept

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by glimes on 2016-01-11 13:11:43:

Per discussion on CFS CCB telecon,
marking the proposed tickets with
the "osal-4.2" Milestone.

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by glimes on 2016-01-14 11:31:23:

Included in the 2016-01-11 CCB merge.

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by glimes on 2016-01-14 11:33:37:

Development advanced to include the 2016-01-11 merge.

@skliper skliper closed this as completed Sep 30, 2019
@skliper skliper removed their assignment Sep 30, 2019
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