From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQlq6-00017E-BL for qemu-devel@nongnu.org; Thu, 20 Mar 2014 18:53:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQlq1-0007cJ-FS for qemu-devel@nongnu.org; Thu, 20 Mar 2014 18:53:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11208) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQlq1-0007cF-7i for qemu-devel@nongnu.org; Thu, 20 Mar 2014 18:53:25 -0400 Message-ID: <532B7160.9020201@redhat.com> Date: Thu, 20 Mar 2014 16:53:20 -0600 From: Eric Blake MIME-Version: 1.0 References: <1395206201-22999-1-git-send-email-wenchaoqemu@gmail.com> <1395206201-22999-3-git-send-email-wenchaoqemu@gmail.com> In-Reply-To: <1395206201-22999-3-git-send-email-wenchaoqemu@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nlKQ1T333er6pouUedWp6joFxDmVodB95" Subject: Re: [Qemu-devel] [RFC PATCH V3 2/5] qapi: add event helper functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia , qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com, armbru@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --nlKQ1T333er6pouUedWp6joFxDmVodB95 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/18/2014 11:16 PM, Wenchao Xia wrote: > This file hold some functions that do not need to be generated. s/hold/holds/ >=20 > Signed-off-by: Wenchao Xia > --- > include/qapi/qmp-event.h | 25 ++++++++++++++++ > qapi/Makefile.objs | 1 + > qapi/qmp-event.c | 71 ++++++++++++++++++++++++++++++++++++++= ++++++++ > 3 files changed, 97 insertions(+), 0 deletions(-) > create mode 100644 include/qapi/qmp-event.h > create mode 100644 qapi/qmp-event.c >=20 > diff --git a/include/qapi/qmp-event.h b/include/qapi/qmp-event.h > new file mode 100644 > index 0000000..fdf1a7f > --- /dev/null > +++ b/include/qapi/qmp-event.h > @@ -0,0 +1,25 @@ > +/* > + * QMP Event related > + * > + * Authors: > + * Wenchao Xia > + * > + * This work is licensed under the terms of the GNU LGPL, version 2.1 = or later. > + * See the COPYING.LIB file in the top-level directory. For the [L]GPL to work, someone must assert copyright. > +++ b/qapi/qmp-event.c > @@ -0,0 +1,71 @@ > +/* > + * QMP Event related > + * > + * Authors: > + * Wenchao Xia > + * > + * This work is licensed under the terms of the GNU LGPL, version 2.1 = or later. > + * See the COPYING.LIB file in the top-level directory. Again, missing an actual use of the word "Copyright". > + > +typedef struct QMPEventFunctions { > + QMPEventFuncEmit emit; > +} QMPEventFunctions; > + > +QMPEventFunctions qmp_event_functions; > + > +void qmp_event_set_func_emit(QMPEventFuncEmit emit) > +{ > + qmp_event_functions.emit =3D emit; > +} > + > +QMPEventFuncEmit qmp_event_get_func_emit(void) > +{ > + return qmp_event_functions.emit; > +} Is this struct a bit overkill, or do you extend it to include other fields later? > + err =3D qemu_gettimeofday(&tv); > + if (err < 0) { > + /* Put -1 to indicate failure of getting host time */ > + tv.tv_sec =3D tv.tv_usec =3D -1; Believe it or not, this is NOT portable. Let's consider what happens when tv_sec is int64_t and tv_usec is uint32_t. Assignments happen right to left, so tv_usec gets the unsigned value 0xffffffff, then since all uint32_t values fit in int64_t, integer promotion says that the value is 0-extended (not sign-extended), and tv_sec is NOT assigned -1. Solution: break this into two separate statements: tv.tv_sec =3D -1; tv.tv_usec =3D -1; > + } > + > + obj =3D qobject_from_jsonf("{ 'seconds': %" PRId64 ", " > + "'microseconds': %" PRId64 " }", > + (int64_t) tv.tv_sec, (int64_t) tv.tv_u= sec); Indentation is odd, but that's cosmetic. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --nlKQ1T333er6pouUedWp6joFxDmVodB95 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTK3FgAAoJEKeha0olJ0NqsOoH/RFMcmGeHyZWrw70q4xOEHd4 ZkOHrDTSq/d1/atG+HInr9plWXl36vlV13wzrhNpN7JQsAWRNLprhj01yNgAb3Qn rs8nLh2e8p3WWLdO5GvGmK1tpfzMJrZi/CkFVEgMdCPbqQYJaJGmkEciOTnlucgR +FZIpRbGeVQypd57CSrfEjoid59Gtg/bQ8bh69CzNDLAEkAX5CfNc+bqz3RjFCjT Jt4lTjRxzW459tkUEF8TpoZnuAipciS7+oCENbAL7+L33bxyxdzdt5TEYXMtMUVQ dgNEX5VCCr7e/Oj6BGolTQbJeF1BNBFRkvk/5sYgVPsVmmbdnI3ZqQsKw8f/x7I= =sO55 -----END PGP SIGNATURE----- --nlKQ1T333er6pouUedWp6joFxDmVodB95--