Skip to contentSkip to conversation

misc/coverity: Model __builtin_unreachable()

PATCH In review Andrew Cooper 2 participants 3 messages Sep 24, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc/coverity: Model __builtin_unreachable()

This resolves 23 issues Coverity had identified by following the false path of an ASSERT().

CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
---
 misc/coverity/model.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
misc/coverity/model.c +10 -0
index fac2ecb..bd62566 100644
@@ -121,6 +121,16 @@ void libxl__ctx_unlock(libxl_ctx *ctx)
 }
 
 /*
+ * Coverity doesn't understand __builtin_unreachable(), which causes it to
+ * incorrectly find issues based on continuing execution along the false
+ * branch of an ASSERT().
+ */
+void __builtin_unreachable(void)
+{
+    __coverity_panic__();
+}
+
+/*
  * Local variables:
  * mode: C
  * c-file-style: "BSD"
Signature · 1 line
1.7.10.4
#1 lore raw

misc/coverity/model.c void libxl__ctx_unlock(libxl_ctx *ctx) · line 131

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 24.09.14 at 15:53, <[email protected]> wrote:

/*
+ * Coverity doesn't understand __builtin_unreachable(), which causes it to
+ * incorrectly find issues based on continuing execution along the false
+ * branch of an ASSERT().
+ */

misc/coverity/model.c +4 -0
+void __builtin_unreachable(void)
+{
+    __coverity_panic__();
+}

And (for those of us without intimate knowledge of Coverity) __coverity_panic__() does what? By its name I would conclude it terminates the current scan altogether...

Jan

#2 lore raw
Quoted 14 lines · Jan Beulich

misc/coverity/model.c void libxl__ctx_unlock(libxl_ctx *ctx) · line 131

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 24.09.14 at 15:53, <[email protected]> wrote:

/*
+ * Coverity doesn't understand __builtin_unreachable(), which causes it to
+ * incorrectly find issues based on continuing execution along the false
+ * branch of an ASSERT().
+ */

misc/coverity/model.c +4 -0
+void __builtin_unreachable(void)
+{
+    __coverity_panic__();
+}

And (for those of us without intimate knowledge of Coverity) __coverity_panic__() does what? By its name I would conclude it terminates the current scan altogether...

Quoted 2 lines

Jan

__coverity_panic__() is a coverity modelling function defined as "ending the current execution path". (See https://scan.coverity.com/tune which might be behind a login)

Its naming is somewhat unfortunate.

~Andrew