From cd6bc944f908c90b80d6ccbae79ae58811e796e9 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Wed, 22 Jul 2020 12:44:02 +0200 Subject: [PATCH] check: Always mark _ck_assert_failed as noreturn So that we can use `fail` like `g_assert_not_reached`. The comment is apparently wrong or outdated, as GCC considers it legal for noreturn-marked functions to return using longjmp. See the thread at https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/merge_requests/59#note_576422 Part-of: --- libs/gst/check/libcheck/check.c | 7 +++---- libs/gst/check/libcheck/check.h.in | 10 ---------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/libs/gst/check/libcheck/check.c b/libs/gst/check/libcheck/check.c index 3bf7bfe..28eca52 100644 --- a/libs/gst/check/libcheck/check.c +++ b/libs/gst/check/libcheck/check.c @@ -384,13 +384,12 @@ _ck_assert_failed (const char *file, int line, const char *expr, ...) va_end (ap); send_failure_info (to_send); - if (cur_fork_status () == CK_FORK) { #if defined(HAVE_FORK) && HAVE_FORK==1 + if (cur_fork_status () == CK_FORK) { _exit (1); -#endif /* HAVE_FORK */ - } else { - longjmp (error_jmp_buffer, 1); } +#endif /* HAVE_FORK */ + longjmp (error_jmp_buffer, 1); } SRunner * diff --git a/libs/gst/check/libcheck/check.h.in b/libs/gst/check/libcheck/check.h.in index 754de91..d52abc5 100644 --- a/libs/gst/check/libcheck/check.h.in +++ b/libs/gst/check/libcheck/check.h.in @@ -422,20 +422,10 @@ static void __testname (int _i CK_ATTRIBUTE_UNUSED)\ /* * This is called whenever an assertion fails. - * Note that it only has the noreturn modifier when - * using fork. If fork is unavailable, the function - * calls longjmp() when a test assertion fails. Marking - * the function as noreturn causes gcc to make assumptions - * which are not valid, as longjmp() is like a return. */ -#if @HAVE_FORK@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed (const char *file, int line, const char *expr, ...) CK_ATTRIBUTE_NORETURN; -#else -CK_DLL_EXP void CK_EXPORT _ck_assert_failed (const char *file, int line, - const char *expr, ...); -#endif /** * Fail the test if expression is false -- 2.7.4