1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-04-29 11:04:04 +02:00
parent cb4fee8bb6
commit 9740dff9f4
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
2 changed files with 39 additions and 15 deletions

View file

@ -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*/