From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLbkA-0007yP-9L for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:29:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLbk0-0005H8-RQ for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:29:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLbk0-0005GX-IP for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:29:04 -0400 Message-ID: <507442BB.7060502@redhat.com> Date: Tue, 09 Oct 2012 17:28:59 +0200 From: Avi Kivity MIME-Version: 1.0 References: <1349280245-16341-1-git-send-email-avi@redhat.com> <1349280245-16341-9-git-send-email-avi@redhat.com> <87pq4yib8y.fsf@codemonkey.ws> <506D9D5E.70303@redhat.com> <87391nn0dj.fsf@codemonkey.ws> In-Reply-To: <87391nn0dj.fsf@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v1 08/22] memory: provide defaults for MemoryListener operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Blue Swirl , Paolo Bonzini , "Michael S. Tsirkin" , qemu-devel@nongnu.org, liu ping fan On 10/09/2012 05:14 PM, Anthony Liguori wrote: >>> >>> I think it'd be nicer to check for NULL when invoking the functions in >>> the memory core. >>> >>> Then you avoid the exported stub functions entirely. >> >> Yes, that's the common style, but I happen not to like the extra check, >> both from a performance point of view (doesn't apply here of course) and >> from a readability point of view. > > The trouble with your approach is that it introduced a subtle behavior > based on ordering. IOW: > > MemoryListenerOps foo = { > MEMORY_LISTENER_DEFAULT_OPS, > .log_sync = ..., > }; > > vs. > > MemoryListenerOps foo = { > .log_sync = ..., > MEMORY_LISTENER_DEFAULT_OPS, > }; > > Both compile fine but have potentially difficult to debug differences. > Relying on zero-initialization eliminates the possibility of this problem. > I don't think this is likely (esp. as the bad behaviour would be the code not working at all) but i will update this for the next version. -- error compiling committee.c: too many arguments to function