[glib/mcatanzaro/coverity-noreturn] Implement G_ANALYZER_NORETURN for Coverity




commit f97ff20adf4eb7b952dd83e2c13046fe9e282f50
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Thu Apr 8 11:34:21 2021 -0500

    Implement G_ANALYZER_NORETURN for Coverity
    
    This change is proposed by Kamil Dudka. It teaches Coverity to assume
    that g_critical() will never return, which is desirable for the same
    reasons it is for scan-build: once you've triggered undefined behavior,
    the game is already lost, and there's limited benefit from trying to
    avoid every possible memory leak on such codepaths. Notably, this
    affects g_return_if_fail().
    
    Arguably it might be desirable to fix every such issue, but if we're
    already not doing so for scan-build, it doesn't make sense to hold
    developers working with Coverity to a higher standard. This allows
    focusing on more serious issues found by Coverity.
    
    Thanks Kamil!

 glib/gmacros.h | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 8071f91f2..5bba1d77e 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -760,6 +760,9 @@
 #if g_macro__has_feature(attribute_analyzer_noreturn) && defined(__clang_analyzer__)
 #define G_ANALYZER_ANALYZING 1
 #define G_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
+#elif defined(__COVERITY__)
+#define G_ANALYZER_ANALYZING 1
+#define G_ANALYZER_NORETURN __attribute__((noreturn))
 #else
 #define G_ANALYZER_ANALYZING 0
 #define G_ANALYZER_NORETURN


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]