qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Farman <farman@linux.ibm.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eric Farman <farman@linux.ibm.com>,
	qemu-devel@nongnu.org, Matthew Rosato <mjrosato@linux.ibm.com>
Subject: [PATCH] error-report: Fix GDateTime usage
Date: Mon, 25 Apr 2022 22:41:36 +0200	[thread overview]
Message-ID: <20220425204136.2370585-1-farman@linux.ibm.com> (raw)

According to the glib manual:

 - g_date_time_new_from_unix_utc() takes a parameter of the number of
   SECONDS since the unix epoch
 - g_get_real_time() returns the number of MICROSECONDS since the
   unix epoch

Rather than convert the latter with G_USECS_PER_SEC, use the convenient
g_date_time_new_now_utc() routine to create the GDateTime object.
This fixes a userspace fault seen when messages get sent to monitor,
such as when a guest is destroyed.

Fixes: 73dab893b569 ("error-report: replace deprecated g_get_current_time() with glib >= 2.62")
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
 util/error-report.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/error-report.c b/util/error-report.c
index dbadaf206d..5edb2e6040 100644
--- a/util/error-report.c
+++ b/util/error-report.c
@@ -173,7 +173,7 @@ 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());
+    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
     /* ignore deprecation warning, since GLIB_VERSION_MAX_ALLOWED is 2.56 */
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-- 
2.32.0



             reply	other threads:[~2022-04-25 20:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25 20:41 Eric Farman [this message]
2022-04-26  6:41 ` [PATCH] error-report: Fix GDateTime usage Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220425204136.2370585-1-farman@linux.ibm.com \
    --to=farman@linux.ibm.com \
    --cc=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).