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

cppcheck and clang static analyzer warnings that need a look #66

Open
seanm opened this issue Jan 4, 2019 · 3 comments
Open

cppcheck and clang static analyzer warnings that need a look #66

seanm opened this issue Jan 4, 2019 · 3 comments

Comments

@seanm
Copy link
Contributor

seanm commented Jan 4, 2019

I fixed some cppcheck and clang static analyzer warnings, but others need someone that knows the code:

The enclosing 'for' loop goes to m_NDims (the ivar), should be _nDims (the param)?

src/metaImage.cxx:584:18: Assigned value is garbage or undefined
src/metaImage.cxx:590:25: Assigned value is garbage or undefined

These may be dead code, or something is failing to use those results...

src/metaImage.cxx:1205:5: Value stored to 'posend' is never read
src/metaImage.cxx:2908:9: Value stored to 'fileImageDim' is never read
src/metaImage.cxx:3044:9: Value stored to 'maxV' is never read

redundantAssignment,src/metaImage.cxx:3051,style,Variable 'maxV' is reassigned a value before the old one has been used.
unreadVariable,src/metaImage.cxx:1205,style,Variable 'posend' is assigned a value that is never used.
unreadVariable,src/metaImage.cxx:1290,style,Variable 'elementDataFileName' is assigned a value that is never used.
@dzenanz
Copy link
Member

dzenanz commented Jan 10, 2019

Is this issue addressed by one of your recent PRs? Perhaps write Closes #66 in the commit message or PR description to reference this issue and have it automatically closed when the PR is merged. You can also reference a merged PR from here and close the issue manually.

@seanm
Copy link
Contributor Author

seanm commented Jan 10, 2019

No, I created this ticket precisely because I don't know how to properly fix them, if I did, I would have just created a PR. :)

These need someone that knows the code.

@seanm
Copy link
Contributor Author

seanm commented Feb 12, 2021

@dzenanz @hjmjohnson @aylward

I've just run cppcheck again and fixed a few more things in: #103

There are a few more that look legit that I daren't fix not knowing this codebase at all:

derefInvalidIteratorRedundantCheck,src/metaCommand.cxx:819,warning,Either the condition 'it!=m_OptionVector.end()' is redundant or there is possible dereference of an invalid iterator: it.

ignoredReturnValue,src/metaImage.cxx:1059,warning,Return value of function buffer.find() is not used.

unreadVariable,src/metaImage.cxx:1136,style,Variable 'elementDataFileName' is assigned a value that is never used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants