From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NpjYq-00013h-KO for qemu-devel@nongnu.org; Thu, 11 Mar 2010 09:40:28 -0500 Received: from [199.232.76.173] (port=49310 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpjYq-00013N-3o for qemu-devel@nongnu.org; Thu, 11 Mar 2010 09:40:28 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NpjYo-0006hv-2h for qemu-devel@nongnu.org; Thu, 11 Mar 2010 09:40:27 -0500 Received: from mx20.gnu.org ([199.232.41.8]:38112) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NpjYm-0006hE-VQ for qemu-devel@nongnu.org; Thu, 11 Mar 2010 09:40:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NpjYk-0004dl-0k for qemu-devel@nongnu.org; Thu, 11 Mar 2010 09:40:22 -0500 Message-ID: <4B98FFF8.3060000@redhat.com> Date: Thu, 11 Mar 2010 15:36:40 +0100 From: Paolo Bonzini MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 1/7] Add support for generic notifier lists References: <1268239869-16058-1-git-send-email-aliguori@us.ibm.com> <201003111257.59828.paul@codesourcery.com> <4B98EF51.7040905@redhat.com> <4B98F32B.7070706@redhat.com> In-Reply-To: <4B98F32B.7070706@redhat.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org, Anthony Liguori , Gerd Hoffman , Paul Brook , Luiz Capitulino On 03/11/2010 02:42 PM, Avi Kivity wrote: > On 03/11/2010 03:25 PM, Paolo Bonzini wrote: >> I didn't understand the advantage of making QEMUNotifier a >> struct. Instead of using container_of, reusing QEMUBHFunc (renamed to >> QEMUCallbackFunc maybe?) in QEMUNotifierNode [...] >> seems cleaner. You would place the QEMUNotifierNode in VncState in >> order to do the removal later. > > I disagree. container_of() is both a little more type safe, and removes > the need for an extra pointer and memory object. > The caller will almost always have an object in which to embed the > notifier, best to make use of it. It doesn't remove the need for an extra memory object. Anthony's design embeds the Notifier but not the NotifierNode. Indeed, my design does have an extra pointer (in the NotifierNode, which grows from 3 to 4 words). I still don't like container_of much, but maybe I'll grow my appreciation of it with time. :-) Paolo