From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS4mE-0000N2-Qv for qemu-devel@nongnu.org; Mon, 24 Mar 2014 09:19:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WS4fR-00077A-64 for qemu-devel@nongnu.org; Mon, 24 Mar 2014 09:11:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS4fQ-00076z-Tt for qemu-devel@nongnu.org; Mon, 24 Mar 2014 09:11:53 -0400 Message-ID: <53302F14.2030108@redhat.com> Date: Mon, 24 Mar 2014 07:11:48 -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> <532B7160.9020201@redhat.com> <532F81ED.7010309@gmail.com> In-Reply-To: <532F81ED.7010309@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="72o2Pff2sWnCNwVlfwr796HD8q9ireR47" 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 Cc: mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --72o2Pff2sWnCNwVlfwr796HD8q9ireR47 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/23/2014 06:53 PM, Wenchao Xia wrote: > =E4=BA=8E 2014/3/21 6:53, Eric Blake =E5=86=99=E9=81=93: >> 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/ >> >>> + >>> +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? > No other fields will be added in this series, it allow different emit= > function hooked. > Do you mean remove it and put it into generated qapi-event.c? Keeping accessor functions is still a bit nicer than directly making a global variable; but my point is that your accessors can just directly access a static variable instead of wrapping things in a pointless struct= : static QMPEventFuncEmit qmp_emit; void qmp_event_set_func_emit(QMPEventFuncEmit emit) { qmp_emit =3D emit; } QMPEventFuncEmit qmp_event_get_func_emit(void) { return qmp_emit; } --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --72o2Pff2sWnCNwVlfwr796HD8q9ireR47 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/ iQEcBAEBCAAGBQJTMC8UAAoJEKeha0olJ0NqBvAH/2LBq1eUoL4zYSFhCVC3ElZS +JXdURxtqmPrHVPYsJsP4EXXk22E/vlMjHScJJM6UQ2mDa63wJI40xFg52NHUfBw T3qOZH0Cm4VBuE0Fnl5VWzcwk43cFbCRtLbNg6cg2ZObU0wLIqwr46uZmw3IBCj1 WgNUMIgMFJIx+1i80LwwhsvpASeDqzYzlFB8H84Y0oVLx+eqRcvSXnAMimhrLqLF l/AAL/Z5Pvv2CF/0Qtnx4RXScuh32oJul76jRf+nO7wgqqcVhEX54ClU9r1vuEcj oFHMGFiMUfdCYg5znbG09xuu97h6e6q7utLzIEBCPToITarskPIUEWYryB7eG4c= =/0VE -----END PGP SIGNATURE----- --72o2Pff2sWnCNwVlfwr796HD8q9ireR47--