diff options
| author | Russ White <russ@riw.us> | 2023-09-19 10:19:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-19 10:19:07 -0400 |
| commit | 7e1eb2a1e02ac3191c87b71acb7d2346dca4a9ca (patch) | |
| tree | 8c6e7c68c599859d4ae9a78e250f6b068071286c /lib/compiler.h | |
| parent | ffbff9b5150ba7d7b8166d41733c4e3c89371d8f (diff) | |
| parent | 71510e531d8874f35d15460eb4c8a99d3ef31869 (diff) | |
Merge pull request #14414 from opensourcerouting/coverity-assume
lib: another attempt at Coverity false positives
Diffstat (limited to 'lib/compiler.h')
| -rw-r--r-- | lib/compiler.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/compiler.h b/lib/compiler.h index 29fcfbefbf..ce6727685f 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -122,6 +122,14 @@ extern "C" { #define assume(x) #endif +#ifdef __COVERITY__ +/* __coverity_panic__() is named a bit poorly, it's essentially the same as + * __builtin_unreachable(). Used to eliminate false positives. + */ +#undef assume +#define assume(x) do { if (!(x)) __coverity_panic__(); } while (0) +#endif + /* for helper functions defined inside macros */ #define macro_inline static inline __attribute__((unused)) #define macro_pure static inline __attribute__((unused, pure)) |
