89
USER GUIDE – VERSION 3.3.2 LINUX/WINDOWS EDITION September 5, 2014 c 2008-2014 Red Lizard Software

USER GUIDE – VERSION 3.3.2 LINUX/WINDOWS · PDF file10.11Using CppCheck And CppNcss With Goanna ... Requirements for Goanna Dashboard and HTML Report Goanna Dashboard (see8) and

Embed Size (px)

Citation preview

  • USER GUIDE VERSION 3.3.2LINUX/WINDOWS EDITION

    September 5, 2014

    c 2008-2014 Red Lizard Software

  • Copyright c 2008-2014 Red Lizard SoftwareAll rights reserved.

    This document, as well as the software described in it, isprovided under license and may only be used or copiedin accordance with the terms of such license. The infor-mation contained herein is the property of NICTA and ismade available under license to Red Lizard Software. Itis confidential information as between the Recipient andRed Lizard Software and remains the exclusive propertyof NICTA. No part of this documentation may be copied,translated, stored in a retrieval system, or transmitted inany form or by any means, electronic, mechanical, photo-copying, recording or otherwise without the prior writtenpermission of NICTA.NICTA does not warrant that this document is error-free.

    Red Lizard SoftwareAustralian Technology ParkLevel 5, 13 Garden Street

    Eveleigh NSW 2015Australia

    Web: http://www.redlizards.comSupport: [email protected]

  • Contents

    1 System Requirements 61.1 Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    1.1.1 Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    1.1.2 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    1.1.3 Other Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    1.2 Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    1.3 Supported Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    1.3.1 A Word On C99 and C++11 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    1.3.2 A Word On Compiler-Specific Syntax Extensions . . . . . . . . . . . . . . . . . . . . . . . 9

    1.3.3 Analog Devices CrossCore C/C++ Compiler (cc21x Dialect) . . . . . . . . . . . . . . . . 91.3.4 ARM C/C++ Compiler (armcc Dialect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.3.5 Cosmic Software C Cross Compiler (cosmic Dialect) . . . . . . . . . . . . . . . . . . . . 91.3.6 Cygwin GCC (cygwin Dialect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.3.7 Freescale (metrowerks Dialect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.3.8 GNU C/C++ Compiler (GCC) (gnu Dialect) . . . . . . . . . . . . . . . . . . . . . . . . . 101.3.9 IAR Toolchain for 8051, ARM and MSP430 (iar-8051, iar-arm and iar-msp430 Di-

    alects) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    1.3.10 Keil Cx51 and C166 Optimizing C Compiler (c51 and c166 Dialects) . . . . . . . . . . . . 101.3.11 Microsoft Visual C++ (microsoft Dialect) . . . . . . . . . . . . . . . . . . . . . . . . . . 101.3.12 QNX QCC (qnx Dialect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.3.13 Renesas H8S, H8/300 Series C/C++ Compiler (renesas-h8 Dialect) . . . . . . . . . . . . 111.3.14 Renesas RXC Toolchain (renesas-rx Dialect) . . . . . . . . . . . . . . . . . . . . . . . 111.3.15 Tasking VX-toolset for C166/ST10 (tasking-c166 Dialect) . . . . . . . . . . . . . . . . 111.3.16 TI Build Tools (ti-cl16x, ti-cl2000, ti-cl430, ti-cl470, ti-cl500 and ti-cl55

    Dialects) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    1.3.17 Wind River Diab Compiler (diab Dialect) . . . . . . . . . . . . . . . . . . . . . . . . . . 121.4 Supported Build Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    1.4.1 GNU Make, QNX Make and Microsoft NMake . . . . . . . . . . . . . . . . . . . . . . . . 13

    1.4.2 SCons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    1.4.3 CMake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    1.4.4 IAR Embedded Workbench R (IarBuild.exe) . . . . . . . . . . . . . . . . . . . . . . . 131.4.5 Keil

    TMVision R (UV4.exe) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    2 Getting Started 142.1 License Agreement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    2.2 Installation (Linux) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    2.3 Installation (Windows) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    2.4 License Activation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    2.4.1 Activating Node-locked License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    2.4.2 Using Network (Floating) License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    2.5 Next Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    2

  • 3 Setting Up Projects for Goanna Analysis 183.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    3.2 Setting Up GNU Make, QNX Make and Microsoft NMake Projects with goannamake . . . . . . . 193.2.1 Preparing Makefile for Goanna Integration . . . . . . . . . . . . . . . . . . . . . . . . . 193.2.2 Using goannamake To Capture The Build Settings . . . . . . . . . . . . . . . . . . . . . . 20

    3.3 Setting Up SCons Projects with goannascons . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.3.1 Preparing SConstruct file for Goanna Integration . . . . . . . . . . . . . . . . . . . . . . 213.3.2 Using goannascons To Capture The Build Settings . . . . . . . . . . . . . . . . . . . . . 22

    3.4 Setting Up CMake Projects with goannacmake-conv . . . . . . . . . . . . . . . . . . . . . . . . 233.4.1 Using goannacmake-conv To Generate The Build Settings . . . . . . . . . . . . . . . . . 23

    3.5 Setting Up IAR Embedded Workbench R Projects with goannaiarbuild . . . . . . . . . . . . . . 24

    3.6 Setting Up KeilTM

    Vision R Projects with gotrace . . . . . . . . . . . . . . . . . . . . . . . . . 25

    4 Running Goanna Analysis 264.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    4.2 Running Goanna Analysis On Non-Keil Projects With goanna . . . . . . . . . . . . . . . . . . . . 27

    4.3 Running Goanna Analysis On KeilTM

    Vision R Projects With gokeil . . . . . . . . . . . . . . . . 274.4 Reading Analysis Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    4.4.1 Goanna Output On The Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    4.4.2 HTML Report of Analysis Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

    4.4.3 Analysis Results In XML File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    4.4.4 Using Goanna Dashboard Web Interface To Interact With Analysis Results . . . . . . . . . 30

    4.4.5 Using SonarQube To Interact With Analysis Results . . . . . . . . . . . . . . . . . . . . . 30

    5 Configuring Goanna Analysis 315.1 Setting Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    5.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    5.1.2 Selecting Checks With Command Line Options . . . . . . . . . . . . . . . . . . . . . . . . 31

    5.1.3 Using Checks File To Select Multiple Checks . . . . . . . . . . . . . . . . . . . . . . . . . 32

    5.1.4 Enabling All Available Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    5.2 Checks Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    5.2.1 Listing Checks Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    5.2.2 Enabling Available Checks Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    5.2.3 Disabling Installed Checks Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    5.2.4 Installing Custom Checks Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    5.3 Including Headers Into Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    5.4 Excluding Certain Files From Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    5.5 Setting Analysis Timeouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    5.6 Ignoring Certain Warnings ("Warning Suppression") . . . . . . . . . . . . . . . . . . . . . . . . . 35

    5.7 Other Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    6 Running Goanna Analysis From Within IDEs 366.1 Running Goanna Analysis From IAR Embedded Workbench R . . . . . . . . . . . . . . . . . . . . 36

    6.2 Running Goanna Analysis From KeilTM

    Vision R . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    3

  • 7 Getting the Best Results from Goanna 407.1 Interprocedural Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    7.2 A Word on False Positives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    7.3 Using the _GOANNA Preprocessor Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417.4 Using the assert macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417.5 Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . . . .