mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-05 00:46:16 +01:00
Make g_assert and g_assert_not_reached use the same entry point
These two assertion macros are commonly used outside tests, so we can't repurpose them, as we are going to do with the other assertion macros in the following commits. This change is in preparation for that. https://bugzilla.gnome.org/show_bug.cgi?id=692125
This commit is contained in:
parent
19aafc4ca4
commit
a32c9c7e9c
@ -2218,7 +2218,11 @@ g_assertion_message_expr (const char *domain,
|
||||
const char *func,
|
||||
const char *expr)
|
||||
{
|
||||
char *s = g_strconcat ("assertion failed: (", expr, ")", NULL);
|
||||
char *s;
|
||||
if (!expr)
|
||||
s = g_strdup ("code should not be reached");
|
||||
else
|
||||
s = g_strconcat ("assertion failed: (", expr, ")", NULL);
|
||||
g_assertion_message (domain, file, line, func, s);
|
||||
g_free (s);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ typedef void (*GTestFixtureFunc) (gpointer fixture,
|
||||
#define g_assert_not_reached() do { (void) 0; } while (0)
|
||||
#define g_assert(expr) do { (void) 0; } while (0)
|
||||
#else /* !G_DISABLE_ASSERT */
|
||||
#define g_assert_not_reached() do { g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0)
|
||||
#define g_assert_not_reached() do { g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0)
|
||||
#define g_assert(expr) do { if G_LIKELY (expr) ; else \
|
||||
g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||
#expr); } while (0)
|
||||
|
Loading…
Reference in New Issue
Block a user