Skip to content

Assorted Static Analysis cleanup#1501

Merged
WardF merged 5 commits intomasterfrom
sa_cleanup.wif
Oct 25, 2019
Merged

Assorted Static Analysis cleanup#1501
WardF merged 5 commits intomasterfrom
sa_cleanup.wif

Conversation

@WardF
Copy link
Copy Markdown
Member

@WardF WardF commented Oct 24, 2019

Cleaning up assorted issues identified via static analysis.

@WardF WardF added this to the 4.7.3 milestone Oct 24, 2019
@WardF WardF self-assigned this Oct 24, 2019
@t-b
Copy link
Copy Markdown
Contributor

t-b commented Oct 25, 2019

@WardF Can you share the tool you have used? Maybe also the setup?

@WardF
Copy link
Copy Markdown
Member Author

WardF commented Oct 25, 2019

@t-b Sure thing! There is no particular setup/configuration you need to use ahead of time; this can all be done pretty easily.

I'm working on OSX but the same instructions will work on Linux. I believe there is a way to do this on Windows as well, but I have not explored that.

I'm using the clang static analyzer, scan-build. You can use it with either configure or cmake, but I'm using cmake. I'm sure you'll be able to adjust my example to configure if you want to.

From the top-level netcdf-c/ directory:

$ mkdir build-analyze && cd build-analyze
$ scan-build -o tmp cmake .. -DENABLE_TESTS=OFF    //Ignore any errors reported at this step.
$ scan-build -o tmp -V make -j 10

This final command will run the analysis; it will take longer than a normal build, by quite a bit, and my system chokes if I allocate too many threads to it (-j). The -V command tells scan-build to open the results in a web browser automatically when it finishes. This does not always work properly for me; in this case, you'll use the command-line tool scan-view, where you pass the path to the analysis results as the argument.

@WardF WardF merged commit ca4e1ca into master Oct 25, 2019
@WardF WardF deleted the sa_cleanup.wif branch October 25, 2019 20:27
@WardF
Copy link
Copy Markdown
Member Author

WardF commented Oct 25, 2019

Further reference: http://clang-analyzer.llvm.org/

@t-b
Copy link
Copy Markdown
Contributor

t-b commented Oct 25, 2019

@WardF Thanks a lot!

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

Successfully merging this pull request may close these issues.

2 participants