qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
	"aliguori@us.ibm.com" <aliguori@us.ibm.com>,
	"mtosatti@redhat.com" <mtosatti@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"armbru@redhat.com" <armbru@redhat.com>,
	"dle-develop@lists.sourceforge.net"
	<dle-develop@lists.sourceforge.net>,
	Tomoki Sekiyama <tomoki.sekiyama@hds.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"lcapitulino@redhat.com" <lcapitulino@redhat.com>,
	"lersek@redhat.com" <lersek@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v5] Add timestamp to error_report()
Date: Wed, 3 Jul 2013 11:10:48 +0200	[thread overview]
Message-ID: <20130703091048.GC17614@stefanha-thinkpad.muc.redhat.com> (raw)
In-Reply-To: <A5ED84D3BB3A384992CBB9C77DEDA4D443E15626@USINDEM103.corp.hds.com>

On Tue, Jul 02, 2013 at 02:09:24PM +0000, Seiji Aguchi wrote:
> > > diff --git a/util/qemu-time.c b/util/qemu-time.c
> > > new file mode 100644
> > > index 0000000..3862788
> > > --- /dev/null
> > > +++ b/util/qemu-time.c
> > > @@ -0,0 +1,26 @@
> > > +/*
> > > + * Time handling
> > > + *
> > > + * Copyright (C) 2013 Hitachi Data Systems Corp.
> > > + *
> > > + * Authors:
> > > + *  Seiji Aguchi <seiji.aguchi@hds.com>
> > > + *
> > > + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> > > + * See the COPYING file in the top-level directory.
> > > + */
> > > +#include "qemu/time.h"
> > > +
> > > +void qemu_get_timestamp_str(char *timestr, size_t len)
> > > +{
> > > +    GTimeVal tv;
> > > +    gchar *tmp_str = NULL;
> > > +
> > > +    /* Size of len should be at least TIMESTAMP_LEN to avoid truncation */
> > > +    assert(len >= TIMESTAMP_LEN);
> > > +
> > > +    g_get_current_time(&tv);
> > > +    tmp_str = g_time_val_to_iso8601(&tv);
> > > +    g_strlcpy((gchar *)timestr, tmp_str, len);
> > > +    g_free(tmp_str);
> > > +}
> > 
> > Why strcpy into a fixed-size buffer when glib gives us a heap-allocated
> > string?
> > 
> > This patch would be simpler by dropping qemu-time.c/time.h 
> 
> I plan to introduce timestamp to monitor_printf() and fprintf()
> near future.
> 
> In this case, it is better from a maintenance POV to keep time-handling
>  functionality  in a file that's separate from the qemu error file, so it can be reused
> elsewhere in QEMU if needed.
> 
> It is suggested by Daniel.
> http://marc.info/?l=qemu-devel&m=136741113218944&w=2

Daniel's statement was about the code you copied from libvirt.  It was
not about using the glib function, which simplifies things greatly and
avoids the need for a test suite.

Patches need to make sense today, please do not add extra code with
potential future use in mind:

1. Other developers must be able to read and modify the current codebase
   on its own.  They do not know what potential future changes you were
   thinking about.

2. You may never end up submitting or getting the future stuff upstream.
   Then we'd be left with extra layers that are never used.

Stefan

  reply	other threads:[~2013-07-03  9:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01 18:54 [Qemu-devel] [PATCH v5] Add timestamp to error_report() Seiji Aguchi
2013-07-02  6:47 ` Laszlo Ersek
2013-07-02  9:09 ` Stefan Hajnoczi
2013-07-02 14:09   ` Seiji Aguchi
2013-07-03  9:10     ` Stefan Hajnoczi [this message]
2013-07-04  2:57       ` Seiji Aguchi
2013-07-03  9:13     ` Stefan Hajnoczi
2013-07-04  2:57       ` Seiji Aguchi
2013-07-04  8:49         ` 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=20130703091048.GC17614@stefanha-thinkpad.muc.redhat.com \
    --to=stefanha@gmail.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seiji.aguchi@hds.com \
    --cc=tomoki.sekiyama@hds.com \
    /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).