All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] error-report: fix g_date_time_format assertion
@ 2022-04-24 10:31 Haiyue Wang
  2022-04-24 10:50 ` [PATCH v2] " Haiyue Wang
  0 siblings, 1 reply; 5+ messages in thread
From: Haiyue Wang @ 2022-04-24 10:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Haiyue Wang, Marc-André Lureau, Richard Henderson,
	Daniel P. Berrangé,
	Paolo Bonzini

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 'g_date_time_new_now' with UTC time zone, it has the same result as
'g_date_time_new_from_unix_utc(g_get_real_time()/1e6)';

Fixes: 73dab893b569 ("error-report: replace deprecated g_get_current_time() with glib >= 2.62")
Signed-off-by: Haiyue Wang <haiyue.wang@intel.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..4000fff14a 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(g_time_zone_new_utc());
     /* ignore deprecation warning, since GLIB_VERSION_MAX_ALLOWED is 2.56 */
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-- 
2.36.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2] error-report: fix g_date_time_format assertion
  2022-04-24 10:31 [PATCH v1] error-report: fix g_date_time_format assertion Haiyue Wang
@ 2022-04-24 10:50 ` Haiyue Wang
  2022-04-24 12:32   ` Marc-André Lureau
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Haiyue Wang @ 2022-04-24 10:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Haiyue Wang, Marc-André Lureau, Richard Henderson,
	Daniel P. Berrangé,
	Paolo Bonzini

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"
-- 
2.36.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] error-report: fix g_date_time_format assertion
  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é
  2022-04-26  7:46   ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Marc-André Lureau @ 2022-04-24 12:32 UTC (permalink / raw)
  To: Haiyue Wang
  Cc: Daniel P. Berrangé, Richard Henderson, QEMU, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1630 bytes --]

On Sun, Apr 24, 2022 at 3:27 PM Haiyue Wang <haiyue.wang@intel.com> 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>
>

Thanks, my bad
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.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"
> --
> 2.36.0
>
>
>

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 2447 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] error-report: fix g_date_time_format assertion
  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é
  2022-04-26  7:46   ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Daniel P. Berrangé @ 2022-04-25 10:30 UTC (permalink / raw)
  To: Haiyue Wang
  Cc: Marc-André Lureau, Richard Henderson, qemu-devel, Paolo Bonzini

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 :|



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] error-report: fix g_date_time_format assertion
  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é
@ 2022-04-26  7:46   ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2022-04-26  7:46 UTC (permalink / raw)
  To: Haiyue Wang
  Cc: Marc-André Lureau, Daniel P . Berrangé,
	Richard Henderson, qemu-devel

Queued, thanks.

Paolo




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-26  7:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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é
2022-04-26  7:46   ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.