On Tue, Jun 28, 2016 at 05:09:13PM +0100, Bhanuprakash Bodireddy wrote:
> 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
> ./configure --with-dpdk(in case of DPDK datapath)
> make clang-analyze
> scan-view --host=<ip address> --port <PORT>
>   $OVS_DIR>/clang-analyzer-results/yyyy-mm-dd-114251-1027-1>
>   --allow-all-hosts
> 
> Results can be viewed on browser: http://<ip address>:<PORT>/
> 
> 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.
> 
> Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodire...@intel.com>

I'd tend to write this a little differently, maybe like this:

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-analyzer=/usr/bin/clang $(MAKE)
.PHONY: clang-analyze

But it doesn't work for me anyway.  When I run it from a build tree
configured to use clang, I get the following:

    make  all-recursive
    make[2]: Entering directory '/home/blp/nicira/ovs/_clang'
    Making all in datapath
    make[3]: Entering directory '/home/blp/nicira/ovs/_clang/datapath'
    make[4]: Entering directory '/home/blp/nicira/ovs/_clang/datapath'
    make[4]: Leaving directory '/home/blp/nicira/ovs/_clang/datapath'
    make[3]: Leaving directory '/home/blp/nicira/ovs/_clang/datapath'
    make[3]: Entering directory '/home/blp/nicira/ovs/_clang'
      CC       lib/aes128.lo
    gcc: error: unrecognized command line option '-Wthread-safety'
    gcc: error: unrecognized command line option '-Qunused-arguments'
    gcc: error: unrecognized command line option '-fno-caret-diagnostics'
    Makefile:4179: recipe for target 'lib/aes128.lo' failed
    make[3]: *** [lib/aes128.lo] Error 1
    make[3]: Leaving directory '/home/blp/nicira/ovs/_clang'
    Makefile:4831: recipe for target 'all-recursive' failed
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory '/home/blp/nicira/ovs/_clang'
    Makefile:2749: recipe for target 'all' failed
    make[1]: *** [all] Error 2
    make[1]: Leaving directory '/home/blp/nicira/ovs/_clang'
    scan-build: Removing directory 
'/home/blp/nicira/ovs/tests/clang-analyzer-results/2016-07-02-101251-14653-1' 
because it contains no reports.
    scan-build: No bugs found.
    Makefile:5845: recipe for target 'clang-analyze' failed
    make: *** [clang-analyze] Error 1

Alternatively, if I run it from a build tree configured to use GCC, I
get the following:

    make  all-recursive
    make[2]: Entering directory '/home/blp/nicira/ovs/_build'
    Making all in datapath
    make[3]: Entering directory '/home/blp/nicira/ovs/_build/datapath'
    make[4]: Entering directory '/home/blp/nicira/ovs/_build/datapath'
    make[4]: Leaving directory '/home/blp/nicira/ovs/_build/datapath'
    make[3]: Leaving directory '/home/blp/nicira/ovs/_build/datapath'
    make[3]: Entering directory '/home/blp/nicira/ovs/_build'
      CC       lib/aes128.lo
      CC       lib/backtrace.lo
      CC       lib/bfd.lo
    In file included from ../lib/bfd.h:24:0,
                     from ../lib/bfd.c:16:
    ../lib/packets.h: In function 'eth_addr_invert':
    ../lib/packets.h:237:5: error: 'for' loop initial declarations are only 
allowed in C99 or C11 mode
    ../lib/packets.h:237:5: note: use option -std=c99, -std=gnu99, -std=c11 or 
-std=gnu11 to compile your code
    In file included from ../lib/netdev.h:23:0,
                     from ../lib/dpif.h:391,
                     from ../lib/bfd.c:28:
    ../lib/flow.h: In function 'flowmap_is_empty':
    ../lib/flow.h:267:5: error: 'for' loop initial declarations are only 
allowed in C99 or C11 mode
    ../lib/flow.h:395:5: note: in expansion of macro 'FLOWMAP_FOR_EACH_MAP'
    ../lib/flow.h: In function 'flow_union_with_miniflow_subset':
    ../lib/flow.h:267:5: error: 'for' loop initial declarations are only 
allowed in C99 or C11 mode
    ../lib/flow.h:797:5: note: in expansion of macro 'FLOWMAP_FOR_EACH_MAP'
    In file included from ../lib/flow.h:24:0,
                     from ../lib/netdev.h:23,
                     from ../lib/dpif.h:391,
                     from ../lib/bfd.c:28:
    ../lib/bitmap.h:270:5: error: 'for' loop initial declarations are only 
allowed in C99 or C11 mode
    ../lib/flow.h:221:5: note: in expansion of macro 'ULLONG_FOR_EACH_1'
    ../lib/flow.h:800:9: note: in expansion of macro 'MAP_FOR_EACH_INDEX'
    Makefile:4179: recipe for target 'lib/bfd.lo' failed
    make[3]: *** [lib/bfd.lo] Error 1
    make[3]: Leaving directory '/home/blp/nicira/ovs/_build'
    Makefile:4831: recipe for target 'all-recursive' failed
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory '/home/blp/nicira/ovs/_build'
    Makefile:2749: recipe for target 'all' failed
    make[1]: *** [all] Error 2
    make[1]: Leaving directory '/home/blp/nicira/ovs/_build'
    scan-build: Removing directory 
'/home/blp/nicira/ovs/tests/clang-analyzer-results/2016-07-02-101322-15957-1' 
because it contains no reports.
    scan-build: No bugs found.
    Makefile:5845: recipe for target 'clang-analyze' failed
    make: *** [clang-analyze] Error 1

(In both cases I'm omitting the output from the "clean" part of the
operation.)

How is it supposed to work?

Thanks,

Ben.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to