From patchwork Fri Jul 15 18:43:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 648950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rrhN66dKhz9sBR for ; Sat, 16 Jul 2016 04:45:42 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 0F19C10C23; Fri, 15 Jul 2016 11:45:41 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 8749510C22 for ; Fri, 15 Jul 2016 11:45:39 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id C15211631C5 for ; Fri, 15 Jul 2016 12:45:38 -0600 (MDT) X-ASG-Debug-ID: 1468608335-0b3237299a15fb0001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar6.cudamail.com with ESMTP id pQdHH1tnP8P1AHj9 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 15 Jul 2016 12:45:35 -0600 (MDT) X-Barracuda-Envelope-From: bhanuprakash.bodireddy@intel.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mga03.intel.com) (134.134.136.65) by mx1-pf2.cudamail.com with SMTP; 15 Jul 2016 18:45:35 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at intel.com designates 134.134.136.65 as permitted sender) X-Barracuda-Apparent-Source-IP: 134.134.136.65 X-Barracuda-RBL-IP: 134.134.136.65 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 15 Jul 2016 11:45:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,369,1464678000"; d="scan'208";a="734843117" Received: from unknown (HELO silpixa00393942.ir.intel.com) ([10.243.18.113]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jul 2016 11:45:34 -0700 X-CudaMail-Envelope-Sender: bhanuprakash.bodireddy@intel.com From: Bhanuprakash Bodireddy To: dev@openvswitch.org X-CudaMail-MID: CM-E2-714047487 X-CudaMail-DTE: 071516 X-CudaMail-Originating-IP: 134.134.136.65 Date: Fri, 15 Jul 2016 19:43:24 +0100 X-ASG-Orig-Subj: [##CM-E2-714047487##][PATCH v5] Makefile.am: Add clang static analysis support Message-Id: <1468608204-13639-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 X-GBUdb-Analysis: 0, 134.134.136.65, Ugly c=0.142858 p=-0.5 Source Normal X-MessageSniffer-Rules: 0-0-0-6885-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1468608335 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.31287 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH v5] Makefile.am: Add clang static analysis support X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Clang Static Analyzer is a source code analysis tool to find bugs. This patch adds make target to trigger static analysis using below commands. ./boot.sh For Clang: ./configure CC=clang --with-dpdk For GCC: ./configure CC=gcc --with-dpdk CFLAGS="-std=gnu99" make clang-analyze Run 'scan-view ' command to examine the bug report. Signed-off-by: Bhanuprakash Bodireddy Acked-By: Lance Richardson --- v4->v5: Minor fixes in INSTALL.md v3->v4: * Add "Static Code Analysis" to INSTALL.md * Remove redundant --use-analyzer option v2->v3: * Refactor the code as suggested. * Add --use-cc to scan-build. v1->v2: * Change the output directory to tests/clang-analyzer-results * Remove '-j' make option, This might potentially hang some system while spawning infinite jobs. INSTALL.md | 22 ++++++++++++++++++++++ Makefile.am | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index f4d232b..47126a3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -746,6 +746,28 @@ Instructions to setup travis-ci for your GitHub repository: 4. Pushing a commit to the repository which breaks the build or the testsuite will now trigger a email sent to mylist@mydomain.org +Static Code Analysis +-------------------- + +Static Analysis is a method of debugging Software by examining code rather +than actually executing it. This can be done through 'scan-build' commandline +utility which internally uses clang (or) gcc to compile the code and also +invokes a static analyzer to do the code analysis. At the end of the build, the +reports are aggregated in to a common folder and can later be analyzed using +'scan-view'. + +Open vSwitch includes a Makefile target to trigger static code Analysis and +the instructions are below. + +1. ./boot.sh +2. ./configure CC=clang (when using clang compiler) + ./configure CC=gcc CFLAGS="-std=gnu99" (when using GCC) +3. make clang-analyze + +You should invoke scan-view to view analysis results. The last line of output +from 'make clang-analyze' shall list the command (containing results directory) +that you should invoke to view the results on a browser. + Bug Reporting ============= diff --git a/Makefile.am b/Makefile.am index be42921..e913679 100644 --- a/Makefile.am +++ b/Makefile.am @@ -402,6 +402,13 @@ ovsext_clean: datapath-windows/ovsext.sln endif .PHONY: ovsext +clang-analyze: clean + @which clang scan-build >/dev/null 2>&1 || \ + (echo "Unable to find clang/scan-build, Install clang,clang-analyzer packages"; exit 1) + @$(MKDIR_P) "$(srcdir)/tests/clang-analyzer-results" + @scan-build -o $(srcdir)/tests/clang-analyzer-results --use-cc=$(CC) $(MAKE) +.PHONY: clang-analyze + dist-hook: $(DIST_HOOKS) all-local: $(ALL_LOCAL) clean-local: $(CLEAN_LOCAL)