Skip to content

Static Analysis

Jon Szymaniak edited this page Jun 30, 2014 · 3 revisions

Table of Contents

Clang and scan-build

Developers are highly encouraged to use scan-build to check for various issues before the manifest themselves in defect reports. Please do this before submitting pull requests.

In many Linux distributions, scan-build is included with the clang package.

Below is an example of how to run a scan against the bladeRF host code:

$ cd ~/projects/bladeRF/host/
$ mkdir -p build/scan
$ cd build/scan
$ cmake -DCMAKE_C_COMPILER=/usr/share/clang/scan-build/ccc-analyzer ../../
$ /usr/share/clang/scan-build/scan-build make clean all

When this completes, it will print instructions on how to view the defect reports, which will be html pages populated in a /tmp directory.

Coverity

Coverity does not allow for public access to defect lists. However, it does allow project maintainers to grant registered Coverity users Contributor/Member, Contributer/Viewer, and Other/Observer permissions. You're more than welcome to the bladeRF Coverity scan results, all you have to do is ask! :)

Setup

  1. Download Coverity Scan from https://scan.coverity.com/download
  2. Extract and add the Coverity Scan tools to the path
  3. Add the FX3 compiler to the Coverity configuration
    1. `cov-configure --comptype gcc --compiler /opt/cypress/fx3_sdk/arm-2011.03/bin/arm-none-eabi-gcc`
    2. Replace /opt/cypress/fx3_sdk/arm-2011.03/bin/arm-none-eabi-gcc with wherever your FX3 SDK is installed

Performing a build

Always use the root level CMakeLists.txt to do a build, not the one in host. If you do a build in host, the fx3 sources will be removed from Coverity.

Setup common CMake build folder (if needed)

  1. cd to root of source tree (e.g. cd ~/bladeRF)
  2. `mkdir build`
  3. `cd build`
  4. `cmake ..`

Perform the Coverity build

  1. cd to root build folder (e.g. cd ~/bladeRF/build)
  2. `make clean`
  3. `rm -rf cov-int`
  4. `cov-build --dir cov-int make`
  5. `tar -czvf bladeRF.tgz cov-int/`
  6. The tarball can be manually submitted to the website, or you can automatically submit it via
 - curl --form project=bladeRF --form token=PUT_YOUR_API_TOKEN_HERE--form email=PUT_YOU_EMAIL@HERE --form file=@bladeRF.tgz --form version=0.4.0 --form description=Description http://scan5.coverity.com/cgi-bin/upload.py
Clone this wiki locally