}
noreturn static void
-library_fatal_error(const char *file, int line, const char *format,
- va_list args) ISC_FORMAT_PRINTF(3, 0);
+library_fatal_error(const char *file, int line, const char *func,
+ const char *format, va_list args) ISC_FORMAT_PRINTF(3, 0);
static void
-library_fatal_error(const char *file, int line, const char *format,
- va_list args) {
+library_fatal_error(const char *file, int line, const char *func,
+ const char *format, va_list args) {
/*
* Handle isc_error_fatal() calls from our libraries.
*/
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
- "%s:%d: fatal error:", file, line);
+ "%s:%d:%s(): fatal error: ", file, line, func);
isc_log_vwrite(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL, format,
args);
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
"exiting (due to fatal error in library)");
} else {
- fprintf(stderr, "%s:%d: fatal error: ", file, line);
+ fprintf(stderr, "%s:%d:%s(): fatal error: ", file, line, func);
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
fflush(stderr);
}
static void
-library_unexpected_error(const char *file, int line, const char *format,
- va_list args) ISC_FORMAT_PRINTF(3, 0);
+library_unexpected_error(const char *file, int line, const char *func,
+ const char *format, va_list args)
+ ISC_FORMAT_PRINTF(3, 0);
static void
-library_unexpected_error(const char *file, int line, const char *format,
- va_list args) {
+library_unexpected_error(const char *file, int line, const char *func,
+ const char *format, va_list args) {
/*
* Handle isc_error_unexpected() calls from our libraries.
*/
if (named_g_lctx != NULL) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_MAIN, ISC_LOG_ERROR,
- "%s:%d: unexpected error:", file, line);
+ "%s:%d:%s(): unexpected error: ", file, line,
+ func);
isc_log_vwrite(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_MAIN, ISC_LOG_ERROR, format,
args);
} else {
- fprintf(stderr, "%s:%d: fatal error: ", file, line);
+ fprintf(stderr, "%s:%d:%s(): fatal error: ", file, line, func);
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
fflush(stderr);
UNUSED(db);
UNUSED(callbacks);
- fatal_error("current implementation should never call beginload()");
+ FATAL_ERROR("current implementation should never call beginload()");
/* Not reached */
return (ISC_R_SUCCESS);
UNUSED(db);
UNUSED(callbacks);
- fatal_error("current implementation should never call endload()");
+ FATAL_ERROR("current implementation should never call endload()");
/* Not reached */
return (ISC_R_SUCCESS);
UNUSED(filename);
UNUSED(masterformat);
- fatal_error("current implementation should never call dump()");
+ FATAL_ERROR("current implementation should never call dump()");
/* Not reached */
return (ISC_R_SUCCESS);
#include <dns/log.h>
-#define fatal_error(...) isc_error_fatal(__FILE__, __LINE__, __VA_ARGS__)
-
#define log_error_r(fmt, ...) \
log_error(fmt ": %s", ##__VA_ARGS__, isc_result_totext(result))
break;
default:
- fatal_error("unsupported address type 0x%x", rdata->type);
+ FATAL_ERROR("unsupported address type 0x%x", rdata->type);
break;
}
/*% Default unexpected callback. */
static void
-default_unexpected_callback(const char *, int, const char *, va_list)
- ISC_FORMAT_PRINTF(3, 0);
+default_unexpected_callback(const char *, int, const char *, const char *,
+ va_list) ISC_FORMAT_PRINTF(4, 0);
/*% Default fatal callback. */
static void
-default_fatal_callback(const char *, int, const char *, va_list)
+default_fatal_callback(const char *, int, const char *, const char *, va_list)
ISC_FORMAT_PRINTF(3, 0);
/*% unexpected_callback */
}
void
-isc_error_unexpected(const char *file, int line, const char *format, ...) {
+isc_error_unexpected(const char *file, int line, const char *func,
+ const char *format, ...) {
va_list args;
va_start(args, format);
- (unexpected_callback)(file, line, format, args);
+ (unexpected_callback)(file, line, func, format, args);
va_end(args);
}
void
-isc_error_fatal(const char *file, int line, const char *format, ...) {
+isc_error_fatal(const char *file, int line, const char *func,
+ const char *format, ...) {
va_list args;
va_start(args, format);
- (fatal_callback)(file, line, format, args);
+ (fatal_callback)(file, line, func, format, args);
va_end(args);
abort();
}
-void
-isc_error_runtimecheck(const char *file, int line, const char *expression) {
- isc_error_fatal(file, line, "RUNTIME_CHECK(%s) failed", expression);
-}
-
static void
-default_unexpected_callback(const char *file, int line, const char *format,
- va_list args) {
- fprintf(stderr, "%s:%d: ", file, line);
+default_unexpected_callback(const char *file, int line, const char *func,
+ const char *format, va_list args) {
+ fprintf(stderr, "%s:%d:%s(): ", file, line, func);
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
fflush(stderr);
}
static void
-default_fatal_callback(const char *file, int line, const char *format,
- va_list args) {
- fprintf(stderr, "%s:%d: fatal error: ", file, line);
+default_fatal_callback(const char *file, int line, const char *func,
+ const char *format, va_list args) {
+ fprintf(stderr, "%s:%d:%s(): fatal error: ", file, line, func);
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
fflush(stderr);
ISC_LANG_BEGINDECLS
-typedef void (*isc_errorcallback_t)(const char *, int, const char *, va_list);
+typedef void (*isc_errorcallback_t)(const char *, int, const char *,
+ const char *, va_list);
/*% set unexpected error */
void isc_error_setunexpected(isc_errorcallback_t);
/*% unexpected error */
void
-isc_error_unexpected(const char *, int, const char *, ...)
- ISC_FORMAT_PRINTF(3, 4);
+isc_error_unexpected(const char *, int, const char *, const char *, ...)
+ ISC_FORMAT_PRINTF(4, 5);
/*% fatal error */
noreturn void
-isc_error_fatal(const char *, int, const char *, ...) ISC_FORMAT_PRINTF(3, 4);
-
-/*% runtimecheck error */
-noreturn void
-isc_error_runtimecheck(const char *, int, const char *);
+isc_error_fatal(const char *, int, const char *, const char *, ...)
+ ISC_FORMAT_PRINTF(4, 5);
ISC_LANG_ENDDECLS
#include <isc/strerr.h> /* for ISC_STRERRORSIZE */
#define UNEXPECTED_ERROR(...) \
- isc_error_unexpected(__FILE__, __LINE__, __VA_ARGS__)
+ isc_error_unexpected(__FILE__, __LINE__, __func__, __VA_ARGS__)
-#define FATAL_ERROR(...) isc_error_fatal(__FILE__, __LINE__, __VA_ARGS__)
+#define FATAL_ERROR(...) \
+ isc_error_fatal(__FILE__, __LINE__, __func__, __VA_ARGS__)
-#define REPORT_SYSERROR(report, err, fmt, ...) \
- { \
- char _strerr[ISC_STRERRORSIZE]; \
- strerror_r(err, _strerr, sizeof(_strerr)); \
- report(__FILE__, __LINE__, fmt ": %s (%d)", ##__VA_ARGS__, \
- _strerr, err); \
+#define REPORT_SYSERROR(report, err, fmt, ...) \
+ { \
+ char strerr[ISC_STRERRORSIZE]; \
+ strerror_r(err, strerr, sizeof(strerr)); \
+ report(__FILE__, __LINE__, __func__, fmt ": %s (%d)", \
+ ##__VA_ARGS__, strerr, err); \
}
#define UNEXPECTED_SYSERROR(err, ...) \
#else /* UNIT_TESTING */
#define RUNTIME_CHECK(cond) \
- ((cond) ? (void)0 : isc_error_runtimecheck(__FILE__, __LINE__, #cond))
+ ((cond) ? (void)0 : FATAL_ERROR("RUNTIME_CHECK(%s) failed", #cond))
#endif /* UNIT_TESTING */
* Runtime check which logs the error value returned by a POSIX Threads
* function and the error string that corresponds to it
*/
-#define PTHREADS_RUNTIME_CHECK(func, ret) \
- if ((ret) != 0) { \
- FATAL_SYSERROR(ret, "%s(): %s()", __func__, #func); \
+#define PTHREADS_RUNTIME_CHECK(func, ret) \
+ if ((ret) != 0) { \
+ FATAL_SYSERROR(ret, "%s()", #func); \
}
/*%
#endif
if (mpctx->allocated > 0) {
- UNEXPECTED_ERROR(
- "isc_mempool_destroy(): mempool %s leaked memory",
- mpctx->name);
+ UNEXPECTED_ERROR("mempool %s leaked memory", mpctx->name);
}
REQUIRE(mpctx->allocated == 0);