diff options
author | Marc-André Lureau | 2022-03-23 16:57:24 +0100 |
---|---|---|
committer | Paolo Bonzini | 2022-04-06 14:31:43 +0200 |
commit | 73dab893b569b0103c28634d7c33575d3602f51f (patch) | |
tree | 9b1a3899eff5b5003bbae7317296b38fddb5bafd /util | |
parent | qga: replace deprecated g_get_current_time() (diff) | |
download | qemu-73dab893b569b0103c28634d7c33575d3602f51f.tar.gz qemu-73dab893b569b0103c28634d7c33575d3602f51f.tar.xz qemu-73dab893b569b0103c28634d7c33575d3602f51f.zip |
error-report: replace deprecated g_get_current_time() with glib >= 2.62
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-14-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/qemu-error.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/util/qemu-error.c b/util/qemu-error.c index 7769aee8e7..71ce3ee700 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -180,6 +180,19 @@ static void print_loc(void) } } +static char * +real_time_iso8601(void) +{ +#if GLIB_CHECK_VERSION(2, 62, 0) + g_autoptr(GDateTime) dt = g_date_time_new_from_unix_utc(g_get_real_time()); + return g_date_time_format_iso8601(dt); +#else + GTimeVal tv; + g_get_current_time(&tv); + return g_time_val_to_iso8601(&tv); +#endif +} + /* * Print a message to current monitor if we have one, else to stderr. * @report_type is the type of message: error, warning or informational. @@ -189,12 +202,10 @@ static void print_loc(void) */ static void vreport(report_type type, const char *fmt, va_list ap) { - GTimeVal tv; gchar *timestr; if (message_with_timestamp && !monitor_cur()) { - g_get_current_time(&tv); - timestr = g_time_val_to_iso8601(&tv); + timestr = real_time_iso8601(); error_printf("%s ", timestr); g_free(timestr); } |