summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/log.c5
-rw-r--r--src/shared/macro.h4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/shared/log.c b/src/shared/log.c
index 3e48b3ccc2..8d1067c63b 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -703,22 +703,21 @@ int log_meta_object(
return r;
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
static void log_assert(int level, const char *text, const char *file, int line, const char *func, const char *format) {
static char buffer[LINE_MAX];
if (_likely_(LOG_PRI(level) > log_max_level))
return;
+ DISABLE_WARNING_FORMAT_NONLITERAL;
snprintf(buffer, sizeof(buffer), format, text, file, line, func);
+ REENABLE_WARNING;
char_array_0(buffer);
log_abort_msg = buffer;
log_dispatch(level, file, line, func, NULL, NULL, buffer);
}
-#pragma GCC diagnostic pop
noreturn void log_assert_failed(const char *text, const char *file, int line, const char *func) {
log_assert(LOG_CRIT, text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 959a9f7fb1..1941f0e651 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -51,6 +51,10 @@
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wdeclaration-after-statement\"")
+#define DISABLE_WARNING_FORMAT_NONLITERAL \
+ _Pragma("GCC diagnostic push"); \
+ _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
+
#define REENABLE_WARNING \
_Pragma("GCC diagnostic pop")