]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Change i_unreached() to be a function
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 7 Oct 2021 00:10:28 +0000 (03:10 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 7 Oct 2021 07:23:08 +0000 (07:23 +0000)
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
src/lib/failures.h
src/lib/macros.h

index 3364da6a331e733c49879e3c93b7c5b925c1847d..42ce6d7d6f1c9ecfadfa3d7b1e752a72706e09fd 100644 (file)
@@ -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);
+}
index 1f901b32a66e0ad9bea5bfd334cbc82d917ddd2d..afb4c6f4ee1312cec74f4461f0577f88b55cc1ff 100644 (file)
@@ -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);
index 56477ead3474f352597e4e2e0e8e2eee6e475e54..7208d23f572a262002535ea00d6155518132d12c 100644 (file)
                __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) \