error-report: Fix GDateTime usage
PATCH 1/1 error-report: Fix GDateTime usage
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.
--- util/error-report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util/error-report.c +1 -1
@@ -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"
Signature · 1 line
2.32.0
Hi
Quoted 7 lines · Eric Farman
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
Quoted 9 lines
Rather than convert the latter with
G_USECS_PER_SEC, use the convenientg_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 <[email protected]>
Same patch as:
https://patchew.org/QEMU/[email protected]/
thanks
---
Quoted 23 lines
util/error-report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)util/error-report.c +1
-1@@ -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
Signature · 1 line
Marc-André Lureau