[Mesa-stable] [PATCH mesa] util: enforce unreachable() semantic

Eric Engestrom eric.engestrom at imgtec.com
Mon Jul 10 15:08:03 UTC 2017


No implementation of unreachable() should allow code execution to
keep going past it.

We can discuss whether we should have a dead loop, abort(), or do
something else, but the current "meh, let's just keep going" is
just wrong.

Cc: mesa-stable at lists.freedesktop.org
Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
 src/util/macros.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/util/macros.h b/src/util/macros.h
index a10f1de814..16682bf6e8 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -84,7 +84,11 @@ do {                        \
    __assume(0);             \
 } while (0)
 #else
-#define unreachable(str) assert(!str)
+#define unreachable(str)    \
+do {                        \
+   assert(!str);            \
+   while(1);                \
+} while (0)
 #endif
 
 /**
-- 
Cheers,
  Eric



More information about the mesa-stable mailing list