chiark / gitweb /
macro: introduce a nice macro for disabling -Wformat-nonliteral temporarily
[elogind.git] / src / shared / log.c
index ee20921f7843845e3479a04cb2400b43f8f1cc5b..8d1067c63bf7f894589fefc1bf9adeca8f4197eb 100644 (file)
@@ -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.");
@@ -927,10 +926,18 @@ void log_show_color(bool b) {
         show_color = b;
 }
 
+bool log_get_show_color(void) {
+        return show_color;
+}
+
 void log_show_location(bool b) {
         show_location = b;
 }
 
+bool log_get_show_location(void) {
+        return show_location;
+}
+
 int log_show_color_from_string(const char *e) {
         int t;