aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Matlack <dmatlack@google.com>2022-09-29 11:12:05 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2022-09-30 06:39:35 -0400
commit62ece2c5a95cc989648c39155173d3bae27e89a3 (patch)
treece08c23b4c9b228ac84f8b448c16baab246f353a
parentRevert "KVM: selftests: Fix nested SVM tests when built with clang" (diff)
downloadlinux-dev-62ece2c5a95cc989648c39155173d3bae27e89a3.tar.xz
linux-dev-62ece2c5a95cc989648c39155173d3bae27e89a3.zip
KVM: selftests: Tell the compiler that code after TEST_FAIL() is unreachable
Add __builtin_unreachable() to TEST_FAIL() so that the compiler knows that any code after a TEST_FAIL() is unreachable. Signed-off-by: David Matlack <dmatlack@google.com> Message-Id: <20220929181207.2281449-2-dmatlack@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--tools/testing/selftests/kvm/include/test_util.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h
index 5c5a88180b6c..befc754ce9b3 100644
--- a/tools/testing/selftests/kvm/include/test_util.h
+++ b/tools/testing/selftests/kvm/include/test_util.h
@@ -63,8 +63,10 @@ void test_assert(bool exp, const char *exp_str,
#a, #b, #a, (unsigned long) __a, #b, (unsigned long) __b); \
} while (0)
-#define TEST_FAIL(fmt, ...) \
- TEST_ASSERT(false, fmt, ##__VA_ARGS__)
+#define TEST_FAIL(fmt, ...) do { \
+ TEST_ASSERT(false, fmt, ##__VA_ARGS__); \
+ __builtin_unreachable(); \
+} while (0)
size_t parse_size(const char *size);