From 4327b55f45269bde295b4c76cae82442dba36d4c Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 7 Oct 2021 03:10:28 +0300 Subject: [PATCH] lib: Change i_unreached() to be a function This allows overriding the function in a Coverity model, so it can understand that i_unreached() is intended to be unreachable code. --- src/lib/failures.c | 6 ++++++ src/lib/failures.h | 4 ++++ src/lib/macros.h | 3 --- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/failures.c b/src/lib/failures.c index 3364da6a33..42ce6d7d6f 100644 --- a/src/lib/failures.c +++ b/src/lib/failures.c @@ -983,3 +983,9 @@ void failures_deinit(void) i_free_and_null(log_stamp_format); i_free_and_null(log_stamp_format_suffix); } + +#undef i_unreached +void i_unreached(const char *source_filename, int source_linenum) +{ + i_panic("file %s: line %d: unreached", source_filename, source_linenum); +} diff --git a/src/lib/failures.h b/src/lib/failures.h index 1f901b32a6..afb4c6f4ee 100644 --- a/src/lib/failures.h +++ b/src/lib/failures.h @@ -63,6 +63,10 @@ void i_log_typev(const struct failure_context *ctx, const char *format, va_list args) ATTR_FORMAT(2, 0); void i_panic(const char *format, ...) ATTR_FORMAT(1, 2) ATTR_NORETURN ATTR_COLD; +void i_unreached(const char *source_filename, int source_linenum) + ATTR_NORETURN ATTR_COLD; +#define i_unreached() \ + i_unreached(__FILE__, __LINE__) void i_fatal(const char *format, ...) ATTR_FORMAT(1, 2) ATTR_NORETURN ATTR_COLD; void i_error(const char *format, ...) ATTR_FORMAT(1, 2) ATTR_COLD; void i_warning(const char *format, ...) ATTR_FORMAT(1, 2); diff --git a/src/lib/macros.h b/src/lib/macros.h index 56477ead34..7208d23f57 100644 --- a/src/lib/macros.h +++ b/src/lib/macros.h @@ -233,9 +233,6 @@ __func__, \ #expr); }STMT_END -#define i_unreached() \ - i_panic("file %s: line %d: unreached", __FILE__, __LINE__) - /* Convenience macros to test the versions of dovecot. */ #if defined DOVECOT_VERSION_MAJOR && defined DOVECOT_VERSION_MINOR # define DOVECOT_PREREQ(maj, min) \ -- 2.47.3