From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Haiyue Wang <haiyue.wang@intel.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v2] error-report: fix g_date_time_format assertion
Date: Mon, 25 Apr 2022 11:30:40 +0100 [thread overview]
Message-ID: <YmZ4UA5xe8dhUqZu@redhat.com> (raw)
In-Reply-To: <20220424105036.291370-1-haiyue.wang@intel.com>
On Sun, Apr 24, 2022 at 06:50:35PM +0800, Haiyue Wang wrote:
> The 'g_get_real_time' returns the number of microseconds since January
> 1, 1970 UTC, but 'g_date_time_new_from_unix_utc' needs the number of
> seconds, so it will cause the invalid time input:
>
> (process:279642): GLib-CRITICAL (recursed) **: g_date_time_format: assertion 'datetime != NULL' failed
>
> Call function 'g_date_time_new_now_utc' instead, it has the same result
> as 'g_date_time_new_from_unix_utc(g_get_real_time() / G_USEC_PER_SEC)';
>
> Fixes: 73dab893b569 ("error-report: replace deprecated g_get_current_time() with glib >= 2.62")
> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> ---
> v2: use 'g_date_time_new_now_utc' directly, which handles the time
> zone reference correctly.
> ---
> 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"
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Always nice when the bug fix is simpler than the original code too :-)
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2022-04-25 10:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-24 10:31 [PATCH v1] error-report: fix g_date_time_format assertion Haiyue Wang
2022-04-24 10:50 ` [PATCH v2] " Haiyue Wang
2022-04-24 12:32 ` Marc-André Lureau
2022-04-25 10:30 ` Daniel P. Berrangé [this message]
2022-04-26 7:46 ` Paolo Bonzini
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=YmZ4UA5xe8dhUqZu@redhat.com \
--to=berrange@redhat.com \
--cc=haiyue.wang@intel.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).