[pulseaudio-discuss] [PATCH v2 01/10] build: Add Coverity scan model

Philip Withnall philip at tecnocode.co.uk
Mon Mar 6 08:58:26 UTC 2017


That looks good to me. Thanks for working on this!

Philip

On Mon, 2017-03-06 at 08:43 +0100, Peter Meerwald-Stadler wrote:
> the modeling file help to avoid false positives and increase scanning
> accuracy by explaining code Coverity can't see (out of tree
> libraries);
> the model file must be uploaded by an admin to:
> https://scan.coverity.com/projects/pulseaudio?tab=analysis_settings
> 
> the pa_assert_se() macro needs to be rewritten for Coverity so that
> the assignment is not declared a side-effect
> 
> Signed-off-by: Peter Meerwald-Stadler <pmeerw at pmeerw.net>
> Cc: Philip Withnall <philip at tecnocode.co.uk>
> ---
>  coverity/model.c      | 18 ++++++++++++++++++
>  src/pulsecore/macro.h |  9 +++++++++
>  2 files changed, 27 insertions(+)
>  create mode 100644 coverity/model.c
> 
> diff --git a/coverity/model.c b/coverity/model.c
> new file mode 100644
> index 0000000..afe7ca5
> --- /dev/null
> +++ b/coverity/model.c
> @@ -0,0 +1,18 @@
> +/* Coverity Scan model
> + * Copyright (C) 2017 Peter Meerwald-Stadler <pmeerw at pmeerw.net>
> + *
> + * This is a modeling file for Coverity Scan which helps to avoid
> false
> + * positives and increase scanning accuracy by explaining code
> Coverity
> + * can't see (out of tree libraries); the model file must be
> uploaded by
> + * an admin to:
> + * https://scan.coverity.com/projects/pulseaudio?tab=analysis_settin
> gs
> + */
> +
> +void fail(void) {
> +    __coverity_panic__();
> +}
> +
> +void fail_unless(int x) {
> +    if (!x)
> +        __coverity_panic__();
> +}
> diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
> index 2c5d5f2..dbce5cd 100644
> --- a/src/pulsecore/macro.h
> +++ b/src/pulsecore/macro.h
> @@ -186,6 +186,7 @@ static inline size_t PA_ALIGN(size_t l) {
>  
>  /* pa_assert_se() is an assert which guarantees side effects of x,
>   * i.e. is never optimized away, regardless of NDEBUG or FASTPATH.
> */
> +#ifndef __COVERITY__
>  #define
> pa_assert_se(expr)                                              \
>      do
> {                                                                \
>          if (PA_UNLIKELY(!(expr)))
> {                                     \
> @@ -193,6 +194,14 @@ static inline size_t PA_ALIGN(size_t l) {
>              abort();                                                
>     \
>          }                                                           
>     \
>      } while (false)
> +#else
> +#define
> pa_assert_se(expr)                                              \
> +    do
> {                                                                \
> +        int _unique_var =
> (expr);                                       \
> +        if
> (!_unique_var)                                               \
> +            abort();                                                
>     \
> +    } while (false)
> +#endif
>  
>  /* Does exactly nothing */
>  #define pa_nop() do {} while (false)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20170306/c83b85cb/attachment-0001.sig>


More information about the pulseaudio-discuss mailing list