]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qga: replace deprecated g_get_current_time()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 23 Mar 2022 15:57:23 +0000 (19:57 +0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 6 Apr 2022 08:50:38 +0000 (10:50 +0200)
According to GLib API:
g_get_current_time has been deprecated since version 2.62 and should not
be used in newly-written code. GTimeVal is not year-2038-safe. Use
g_get_real_time() instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220323155743.1585078-13-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qga/main.c

index b9dd19918e47934480b42903725723afc9229621..1deb0ee2fbfed5f57f60868e78c7e94344798973 100644 (file)
@@ -314,7 +314,6 @@ static void ga_log(const gchar *domain, GLogLevelFlags level,
                    const gchar *msg, gpointer opaque)
 {
     GAState *s = opaque;
-    GTimeVal time;
     const char *level_str = ga_log_level_str(level);
 
     if (!ga_logging_enabled(s)) {
@@ -329,9 +328,11 @@ static void ga_log(const gchar *domain, GLogLevelFlags level,
 #else
     if (level & s->log_level) {
 #endif
-        g_get_current_time(&time);
+        gint64 t = g_get_real_time();
         fprintf(s->log_file,
-                "%lu.%lu: %s: %s\n", time.tv_sec, time.tv_usec, level_str, msg);
+                "%" G_GINT64_FORMAT ".%" G_GINT64_FORMAT
+                ": %s: %s\n", t / G_USEC_PER_SEC, t % G_USEC_PER_SEC,
+                level_str, msg);
         fflush(s->log_file);
     }
 }