diff options
author | Werner Koch <[email protected]> | 2016-04-29 09:04:04 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-04-29 09:04:04 +0000 |
commit | 9740dff9f4d18ba764dc7173d4902e94e3f0c2e8 (patch) | |
tree | 3fb4d6c799e410af9b52f0efc02238230ec66f62 /common/logging.c | |
parent | scd: Fix error return path. (diff) | |
download | gnupg-9740dff9f4d18ba764dc7173d4902e94e3f0c2e8.tar.gz gnupg-9740dff9f4d18ba764dc7173d4902e94e3f0c2e8.zip |
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 <[email protected]>
Diffstat (limited to '')
-rw-r--r-- | common/logging.c | 29 |
1 files changed, 24 insertions, 5 deletions
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*/ |