[libvirt PATCH 1/2] src: rework static analysis detection
Pavel Hrdina
phrdina at redhat.com
Fri Nov 20 13:39:04 UTC 2020
On Fri, Nov 20, 2020 at 06:57:10AM -0500, John Ferlan wrote:
>
>
> On 11/16/20 10:36 AM, Pavel Hrdina wrote:
> > Inspired by QEMU code.
> >
> > Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> > ---
> > meson.build | 14 --------------
> > src/internal.h | 4 ++++
> > 2 files changed, 4 insertions(+), 14 deletions(-)
> >
> > diff --git a/meson.build b/meson.build
> > index cecaad199d..dbbc9632f1 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -142,20 +142,6 @@ if get_option('test_coverage')
> > endif
> >
> >
> > -# Detect when running under the clang static analyzer's scan-build driver
> > -# or Coverity-prevent's cov-build. Define STATIC_ANALYSIS accordingly.
> > -
> > -rc = run_command(
> > - 'sh', '-c',
> > - 'test -n "${CCC_ANALYZER_HTML}"' +
> > - ' -o -n "${CCC_ANALYZER_ANALYSIS+set}"' +
> > - ' -o -n "$COVERITY_BUILD_COMMAND$COVERITY_LD_PRELOAD"',
> > -)
> > -if rc.returncode() == 0
> > - conf.set('STATIC_ANALYSIS', 1)
> > -endif
> > -
> > -
> > # Add RPATH information when building for a non-standard prefix, or
> > # when explicitly requested to do so
> >
> > diff --git a/src/internal.h b/src/internal.h
> > index d167e56b48..5226667d3d 100644
> > --- a/src/internal.h
> > +++ b/src/internal.h
> > @@ -29,6 +29,10 @@
> > #include <stdlib.h>
> > #include "glibcompat.h"
> >
> > +#if defined __clang_analyzer__ || defined __COVERITY__
>
> ^^ Bah humbug ... what defines __COVERITY__ then?
>
> In my Coverity environment, nothing... OK, sure I can add it, no problem
> but something in QEMU's coverity build environment must do that as it's
> not predefined as far as I can tell.
Hi John,
There is no need to add it anywhere. When building something using
coverity it is indeed not defined so GCC will ignore any code guarded
with __COVERITY__.
The __COVERITY__ is defined by cov-emit binary which is executed by
cov-build internally which creates the files that are later analyzed.
This is directly from cov-emit --help:
Description
The cov-emit command parses a source file and outputs it into a directory
(emit repository) that can later be analyzed with cov-analyze. The
cov-emit command is typically called by cov-translate, which is in turn
typically called by cov-build (cov-emit is a low-level command and is not
normally called directly). The cov-emit command defines the __COVERITY__
preprocessor symbol.
Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20201120/303c6569/attachment-0001.sig>
More information about the libvir-list
mailing list