All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Michael Roth <michael.roth@amd.com>, QEMU <qemu-devel@nongnu.org>
Subject: Re: [PATCH 12/32] qga: replace deprecated g_get_current_time()
Date: Thu, 7 Apr 2022 15:19:35 +0400	[thread overview]
Message-ID: <CAJ+F1CJHffP=Qa=7_=V37gaTnfw4S22h=Rkjmt9gLL5siVFDmA@mail.gmail.com> (raw)
In-Reply-To: <878rshla33.fsf@pond.sub.org>

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

Hi

On Thu, Apr 7, 2022 at 9:54 AM Markus Armbruster <armbru@redhat.com> wrote:

> marcandre.lureau@redhat.com writes:
>
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > According to GLib API:
> > g_get_current_time has been deprecated since version 2.62 and should not
> > be used in newly-written code. GTimeVal is not year-2038-safe. Use
> > g_get_real_time() instead.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  qga/main.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/qga/main.c b/qga/main.c
> > index b9dd19918e47..1deb0ee2fbfe 100644
> > --- a/qga/main.c
> > +++ b/qga/main.c
> > @@ -314,7 +314,6 @@ static void ga_log(const gchar *domain,
> GLogLevelFlags level,
> >                     const gchar *msg, gpointer opaque)
> >  {
> >      GAState *s = opaque;
> > -    GTimeVal time;
> >      const char *level_str = ga_log_level_str(level);
> >
> >      if (!ga_logging_enabled(s)) {
> > @@ -329,9 +328,11 @@ static void ga_log(const gchar *domain,
> GLogLevelFlags level,
> >  #else
> >      if (level & s->log_level) {
> >  #endif
> > -        g_get_current_time(&time);
> > +        gint64 t = g_get_real_time();
> >          fprintf(s->log_file,
> > -                "%lu.%lu: %s: %s\n", time.tv_sec, time.tv_usec,
> level_str, msg);
>
> The old code is kind of wrong.  Say it's 1649309843.000001 seconds past
> the epoch.  Prints "1649309843.1".  9us later, it prints
> "1649309843.10".  Should really use %06lu for the microseconds part.
>

good idea


> Whether you want to fix this in this patch, or just note it for later in
> the commit message, or ignore it alltogether is up to you.
>
> > +                "%" G_GINT64_FORMAT ".%" G_GINT64_FORMAT
>
> This gives me flashbacks to the 90s.  Please use PRId64 like we do
> everywhere else.
>
> I'd ditch gint64_t for int64_t, too.
>

ack, ack


>
> > +                ": %s: %s\n", t / G_USEC_PER_SEC, t % G_USEC_PER_SEC,
> > +                level_str, msg);
> >          fflush(s->log_file);
> >      }
> >  }
>
>
>

-- 
Marc-André Lureau

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

  reply	other threads:[~2022-04-07 11:21 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23 15:57 [PATCH 00/32] Misc cleanups marcandre.lureau
2022-03-23 15:57 ` [PATCH 01/32] meson: use chardev_ss dependencies marcandre.lureau
2022-03-23 15:57 ` [PATCH 02/32] meson: add util dependency for oslib-posix on freebsd marcandre.lureau
2022-03-23 15:57 ` [PATCH 03/32] meson: remove unneeded py3 marcandre.lureau
2022-03-23 15:57 ` [PATCH 04/32] meson: remove test-qdev-global-props dependency on testqapi marcandre.lureau
2022-03-23 15:57 ` [PATCH 05/32] char: move qemu_openpty_raw from util/ to char/ marcandre.lureau
2022-03-23 15:57 ` [PATCH 06/32] Replace config-time define HOST_WORDS_BIGENDIAN marcandre.lureau
2022-03-23 15:57   ` marcandre.lureau
2022-03-23 17:10   ` Richard Henderson
2022-03-23 17:16   ` Richard Henderson
2022-03-23 15:57 ` [PATCH 07/32] Replace TARGET_WORDS_BIGENDIAN marcandre.lureau
2022-03-23 15:57   ` marcandre.lureau
2022-03-23 17:12   ` Richard Henderson
2022-03-23 15:57 ` [PATCH 08/32] osdep: poison {HOST,TARGET}_WORDS_BIGENDIAN marcandre.lureau
2022-03-23 17:14   ` Richard Henderson
2022-03-23 15:57 ` [PATCH 09/32] include/qapi: add g_autoptr support for qobject types marcandre.lureau
2022-03-23 18:11   ` Richard Henderson
2022-03-24 16:00   ` Markus Armbruster
2022-03-23 15:57 ` [PATCH 10/32] tests: replace free_all() usage with g_auto marcandre.lureau
2022-03-23 18:13   ` Richard Henderson
2022-03-23 15:57 ` [PATCH 11/32] Replace qemu_real_host_page variables with inlined functions marcandre.lureau
2022-03-23 15:57   ` marcandre.lureau
2022-03-25  8:34   ` Juan Quintela
2022-03-25  8:34     ` Juan Quintela
2022-03-23 15:57 ` [PATCH 12/32] qga: replace deprecated g_get_current_time() marcandre.lureau
2022-04-06 14:53   ` Damien Hedde
2022-04-07  5:46   ` Markus Armbruster
2022-04-07 11:19     ` Marc-André Lureau [this message]
2022-03-23 15:57 ` [PATCH 13/32] error-report: replace deprecated g_get_current_time() with glib >= 2.62 marcandre.lureau
2022-04-06  9:07   ` Markus Armbruster
2022-04-06  9:35     ` Marc-André Lureau
2022-04-06  9:40       ` Marc-André Lureau
2022-04-06 10:38         ` Markus Armbruster
2022-03-23 15:57 ` [PATCH 14/32] util: rename qemu-error.c to match its header name marcandre.lureau
2022-03-23 18:23   ` Richard Henderson
2022-04-07  5:49   ` Markus Armbruster
2022-03-23 15:57 ` [PATCH 15/32] error-report: use error_printf() for program prefix marcandre.lureau
2022-04-07  5:50   ` Markus Armbruster
2022-03-23 15:57 ` [PATCH 16/32] include: move TFR to osdep.h marcandre.lureau
2022-03-23 15:57 ` [PATCH 17/32] include: move qemu_write_full() declaration " marcandre.lureau
2022-03-23 15:57 ` [PATCH 18/32] include: move qemu_pipe() " marcandre.lureau
2022-03-23 15:57 ` [PATCH 19/32] include: move coroutine IO functions to coroutine.h marcandre.lureau
2022-03-23 15:57 ` [PATCH 20/32] include: move dump_in_progress() to runstate.h marcandre.lureau
2022-04-06  8:45   ` Markus Armbruster
2022-03-23 15:57 ` [PATCH 21/32] include: move C/util-related declarations to cutils.h marcandre.lureau
2022-03-23 15:57 ` [PATCH 22/32] include: move cpu_exec* declarations to cpu-common.h marcandre.lureau
2022-03-23 15:57 ` [PATCH 23/32] include: move target page bits declaration to page-vary.h marcandre.lureau
2022-03-23 18:29   ` Richard Henderson
2022-03-23 15:57 ` [PATCH 24/32] include: move progress API to qemu-progress.h marcandre.lureau
2022-03-23 18:30   ` Richard Henderson
2022-03-23 15:57 ` [PATCH 25/32] include: move qemu_get_vm_name() to sysemu.h marcandre.lureau
2022-03-23 15:57 ` [PATCH 26/32] include: move os_*() to os-foo.h marcandre.lureau
2022-03-23 18:31   ` Richard Henderson
2022-03-23 21:11   ` Philippe Mathieu-Daudé
2022-03-23 15:57 ` [PATCH 27/32] include: move page_size_init() to include/hw/core/cpu.h marcandre.lureau
2022-03-23 15:57 ` [PATCH 28/32] Move CPU softfloat unions to cpu-float.h marcandre.lureau
2022-03-23 15:57   ` marcandre.lureau
2022-03-25  8:16   ` Juan Quintela
2022-03-25  8:16     ` Juan Quintela
2022-03-23 15:57 ` [PATCH 29/32] Move fcntl_setfl() to oslib-posix marcandre.lureau
2022-03-23 18:34   ` Richard Henderson
2022-03-23 15:57 ` [PATCH 30/32] qga: remove explicit environ argument from exec/spawn marcandre.lureau
2022-03-23 18:36   ` Richard Henderson
2022-03-23 15:57 ` [PATCH 31/32] RFC: Simplify softmmu/main.c marcandre.lureau
2022-03-23 20:56   ` Akihiko Odaki
2022-03-24  7:51   ` Paolo Bonzini
2022-04-20  7:57     ` Marc-André Lureau
2022-04-20 10:48       ` Akihiko Odaki
2022-03-23 15:57 ` [PATCH 32/32] Remove qemu-common.h include from most units marcandre.lureau
2022-03-23 15:57   ` marcandre.lureau
2022-04-05 15:02   ` Ani Sinha
2022-04-05 15:02     ` Ani Sinha
2022-04-06 10:45     ` Markus Armbruster
2022-04-06 10:45       ` Markus Armbruster
2022-04-06 11:14       ` Peter Maydell
2022-04-06 11:14         ` Peter Maydell
2022-04-05 15:24   ` Warner Losh
2022-04-05 15:24     ` Warner Losh
2022-03-24  9:26 ` [PATCH 00/32] Misc cleanups Stefan Hajnoczi

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='CAJ+F1CJHffP=Qa=7_=V37gaTnfw4S22h=Rkjmt9gLL5siVFDmA@mail.gmail.com' \
    --to=marcandre.lureau@gmail.com \
    --cc=armbru@redhat.com \
    --cc=michael.roth@amd.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 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.