浏览代码

glib-compat: isolate g_date_time_format_iso8601 version-bypass

The solution was discussed with Markus Armbruster during the review:
https://patchew.org/QEMU/20220323155743.1585078-1-marcandre.lureau@redhat.com/20220323155743.1585078-14-marcandre.lureau@redhat.com/

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20220420132624.2439741-3-marcandre.lureau@redhat.com>
Marc-André Lureau 3 年之前
父节点
当前提交
951cc9df88
共有 2 个文件被更改,包括 5 次插入11 次删除
  1. 0 10
      include/glib-compat.h
  2. 5 1
      util/error-report.c

+ 0 - 10
include/glib-compat.h

@@ -145,16 +145,6 @@ qemu_g_test_slow(void)
 #define g_test_thorough() qemu_g_test_slow()
 #define g_test_thorough() qemu_g_test_slow()
 #define g_test_quick() (!qemu_g_test_slow())
 #define g_test_quick() (!qemu_g_test_slow())
 
 
-#if GLIB_CHECK_VERSION(2,62,0)
-static inline gchar *
-g_date_time_format_iso8601_compat(GDateTime *datetime)
-{
-    return g_date_time_format_iso8601(datetime);
-}
-
-#define g_date_time_format_iso8601 g_date_time_format_iso8601_compat
-#endif
-
 #pragma GCC diagnostic pop
 #pragma GCC diagnostic pop
 
 
 #endif
 #endif

+ 5 - 1
util/error-report.c

@@ -183,9 +183,13 @@ static void print_loc(void)
 static char *
 static char *
 real_time_iso8601(void)
 real_time_iso8601(void)
 {
 {
-#if GLIB_CHECK_VERSION(2, 62, 0)
+#if GLIB_CHECK_VERSION(2,62,0)
     g_autoptr(GDateTime) dt = g_date_time_new_from_unix_utc(g_get_real_time());
     g_autoptr(GDateTime) dt = g_date_time_new_from_unix_utc(g_get_real_time());
+    /* ignore deprecation warning, since GLIB_VERSION_MAX_ALLOWED is 2.56 */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
     return g_date_time_format_iso8601(dt);
     return g_date_time_format_iso8601(dt);
+#pragma GCC diagnostic pop
 #else
 #else
     GTimeVal tv;
     GTimeVal tv;
     g_get_current_time(&tv);
     g_get_current_time(&tv);