Skip to content

Commit

Permalink
error-report: fix g_date_time_format assertion
Browse files Browse the repository at this point in the history
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: 73dab89 ("error-report: replace deprecated g_get_current_time() with glib >= 2.62")
Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220424105036.291370-1-haiyue.wang@intel.com>
  • Loading branch information
haiyuewa authored and taylorsimpson committed May 9, 2022
1 parent 9c97e69 commit 6b61107
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util/error-report.c
Expand Up @@ -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"
Expand Down

0 comments on commit 6b61107

Please sign in to comment.