[glib] Make g_assert and g_assert_not_reached use the same entry point
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Make g_assert and g_assert_not_reached use the same entry point
- Date: Sat, 17 Aug 2013 21:28:28 +0000 (UTC)
commit a32c9c7e9c9500f151ccae602d92f88e43d8df45
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Feb 2 12:47:54 2013 -0500
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
glib/gtestutils.c | 6 +++++-
glib/gtestutils.h | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index e74d11e..f1116a5 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -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);
}
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 30e07ca..ba8aa4b 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]