Skip to content

Commit

Permalink
build: Add Coverity scan model
Browse files Browse the repository at this point in the history
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@pmeerw.net>
  • Loading branch information
pmeerw committed Mar 6, 2017
1 parent e368ee4 commit 424e97a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
18 changes: 18 additions & 0 deletions coverity/model.c
@@ -0,0 +1,18 @@
/* Coverity Scan model
* Copyright (C) 2017 Peter Meerwald-Stadler <pmeerw@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_settings
*/

void fail(void) {
__coverity_panic__();
}

void fail_unless(int x) {
if (!x)
__coverity_panic__();
}
9 changes: 9 additions & 0 deletions src/pulsecore/macro.h
Expand Up @@ -186,13 +186,22 @@ 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))) { \
pa_log_error("Assertion '%s' failed at %s:%u, function %s(). Aborting.", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
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)
Expand Down

0 comments on commit 424e97a

Please sign in to comment.