glib/gmessages.h: Unify log messages

...Under various compilers when !G_DISABLE_CHECKS.  Previously, the
messages that are logged differ depending whether GLib was built with GCC
or not.  To simplify test cases, make all builds use a single output format
for g_return_if_fail(), g_return_val_if_fail(), g_return_if_reached(), and
g_return_val_if_reached(), by using the GCC-style format and replaceing
__PRETTY_FUNCTION__ with G_STRFUNC, so that it will work across various
compilers.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
This commit is contained in:
Chun-wei Fan 2013-11-05 12:45:38 +08:00
parent fff14a5b7c
commit 172aaa3a01

View File

@ -334,13 +334,11 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func);
#else /* !G_DISABLE_CHECKS */
#ifdef __GNUC__
#define g_return_if_fail(expr) G_STMT_START{ \
if G_LIKELY(expr) { } else \
{ \
g_return_if_fail_warning (G_LOG_DOMAIN, \
__PRETTY_FUNCTION__, \
G_STRFUNC, \
#expr); \
return; \
}; }G_STMT_END
@ -349,7 +347,7 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func);
if G_LIKELY(expr) { } else \
{ \
g_return_if_fail_warning (G_LOG_DOMAIN, \
__PRETTY_FUNCTION__, \
G_STRFUNC, \
#expr); \
return (val); \
}; }G_STMT_END
@ -360,7 +358,7 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func);
"file %s: line %d (%s): should not be reached", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__); \
G_STRFUNC); \
return; }G_STMT_END
#define g_return_val_if_reached(val) G_STMT_START{ \
@ -369,53 +367,9 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func);
"file %s: line %d (%s): should not be reached", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__); \
G_STRFUNC); \
return (val); }G_STMT_END
#else /* !__GNUC__ */
#define g_return_if_fail(expr) G_STMT_START{ \
if (expr) { } else \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d: assertion '%s' failed", \
__FILE__, \
__LINE__, \
#expr); \
return; \
}; }G_STMT_END
#define g_return_val_if_fail(expr, val) G_STMT_START{ \
if (expr) { } else \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d: assertion '%s' failed", \
__FILE__, \
__LINE__, \
#expr); \
return (val); \
}; }G_STMT_END
#define g_return_if_reached() G_STMT_START{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d: should not be reached", \
__FILE__, \
__LINE__); \
return; }G_STMT_END
#define g_return_val_if_reached(val) G_STMT_START{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d: should not be reached", \
__FILE__, \
__LINE__); \
return (val); }G_STMT_END
#endif /* !__GNUC__ */
#endif /* !G_DISABLE_CHECKS */
G_END_DECLS