From 9740dff9f4d18ba764dc7173d4902e94e3f0c2e8 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 29 Apr 2016 11:04:04 +0200 Subject: common: Improve log_assert. * common/logging.c (bug_at): Do not i18n the string. (_log_assert): New. * common/logging.h (log_assert): Use new function and pass line information. Signed-off-by: Werner Koch --- common/logging.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'common/logging.c') diff --git a/common/logging.c b/common/logging.c index b7f141920..7c54d727f 100644 --- a/common/logging.c +++ b/common/logging.c @@ -919,18 +919,37 @@ log_clock (const char *string) } -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) +#ifdef GPGRT_HAVE_MACRO_FUNCTION void bug_at( const char *file, int line, const char *func ) { - log_log (GPGRT_LOG_BUG, ("... this is a bug (%s:%d:%s)\n"), file, line, func); + log_log (GPGRT_LOG_BUG, "... this is a bug (%s:%d:%s)\n", file, line, func); abort (); /* Never called; just to make the compiler happy. */ } -#else +#else /*!GPGRT_HAVE_MACRO_FUNCTION*/ void bug_at( const char *file, int line ) { - log_log (GPGRT_LOG_BUG, _("you found a bug ... (%s:%d)\n"), file, line); + log_log (GPGRT_LOG_BUG, "you found a bug ... (%s:%d)\n", file, line); abort (); /* Never called; just to make the compiler happy. */ } -#endif +#endif /*!GPGRT_HAVE_MACRO_FUNCTION*/ + + +#ifdef GPGRT_HAVE_MACRO_FUNCTION +void +_log_assert (const char *expr, const char *file, int line, const char *func) +{ + log_log (GPGRT_LOG_BUG, "Assertion \"%s\" in %s failed (%s:%d)\n", + expr, func, file, line); + abort (); /* Never called; just to make the compiler happy. */ +} +#else /*!GPGRT_HAVE_MACRO_FUNCTION*/ +void +_log_assert (const char *expr, const char *file, int line) +{ + log_log (GPGRT_LOG_BUG, "Assertion \"%s\" failed (%s:%d)\n", + file, line, func); + abort (); /* Never called; just to make the compiler happy. */ +} +#endif /*!GPGRT_HAVE_MACRO_FUNCTION*/ -- cgit