From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnNIp-00026o-AX for qemu-devel@nongnu.org; Mon, 02 Dec 2013 01:48:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnNIg-0008Rx-DY for qemu-devel@nongnu.org; Mon, 02 Dec 2013 01:48:19 -0500 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:34549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnNIf-0008Rp-OK for qemu-devel@nongnu.org; Mon, 02 Dec 2013 01:48:10 -0500 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Dec 2013 12:18:04 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id F333B394003F for ; Mon, 2 Dec 2013 12:18:02 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rB26lwwH66322480 for ; Mon, 2 Dec 2013 12:17:59 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rB26m1kY032641 for ; Mon, 2 Dec 2013 12:18:01 +0530 Message-ID: <529C2D21.80502@linux.vnet.ibm.com> Date: Mon, 02 Dec 2013 14:48:01 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1384307094-5836-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1384307094-5836-3-git-send-email-xiawenc@linux.vnet.ibm.com> <20131127194830.6715cc72@redhat.com> <5296EDB8.9040904@linux.vnet.ibm.com> <20131128093135.2ef9e21f@redhat.com> In-Reply-To: <20131128093135.2ef9e21f@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 2/3] qapi script: add support of event List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mdroth@linux.vnet.ibm.com >> >>>> + >>>> + if (!qapi_event_functions.emit) { >>> >>> Better to return an error here instead of silently failing. >>> >> >> The purpose is allowing emit=NULL and skip event code in that case. > > But the code will do nothing and the caller won't know that. > Now the caller also won't know that useless code will be executed, when qemu-img link with stub of monitor_event functions. :) > Actually, I wonder if the code should even abort() in such a case, > as emit=NULL would be a programming today. > I am not sure why the code should always do something. The code may actually take CPU resource to do nothing meanful, such as build up a qdict and release it later, when emit is not a valid function. So I did this as an improvement: check emit function ahead to escape useless work.