From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O9f8T-0006UK-9y for qemu-devel@nongnu.org; Wed, 05 May 2010 09:59:37 -0400 Received: from [140.186.70.92] (port=53125 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9f8R-0006OW-3r for qemu-devel@nongnu.org; Wed, 05 May 2010 09:59:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O9f8J-0000dm-Op for qemu-devel@nongnu.org; Wed, 05 May 2010 09:59:32 -0400 Received: from mail-yw0-f198.google.com ([209.85.211.198]:44855) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9f8J-0000dW-Lf for qemu-devel@nongnu.org; Wed, 05 May 2010 09:59:27 -0400 Received: by ywh36 with SMTP id 36so2212477ywh.4 for ; Wed, 05 May 2010 06:59:26 -0700 (PDT) Message-ID: <4BE179BA.4000103@codemonkey.ws> Date: Wed, 05 May 2010 08:59:22 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1273009170-17530-1-git-send-email-amit.shah@redhat.com> <1273009170-17530-2-git-send-email-amit.shah@redhat.com> <1273009170-17530-3-git-send-email-amit.shah@redhat.com> <4BE16F16.5030601@codemonkey.ws> <20100505132520.GC27194@amit-x200.redhat.com> In-Reply-To: <20100505132520.GC27194@amit-x200.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH v7 2/6] char: Add a QemuChrHandlers struct to initialise chardev handlers List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: Paul Brook , Juan Quintela , qemu list , Gerd Hoffmann On 05/05/2010 08:25 AM, Amit Shah wrote: > On (Wed) May 05 2010 [08:13:58], Anthony Liguori wrote: > >> On 05/04/2010 04:39 PM, Amit Shah wrote: >> >>> Instead of passing each handler in the qemu_add_handlers() function, >>> create a struct of handlers that can be passed to the function instead. >>> >>> Signed-off-by: Amit Shah >>> > > >>> - qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive, >>> - gdb_chr_event, NULL); >>> + qemu_chr_add_handlers(chr,&gdb_handlers, NULL); >>> } >>> >>> >> This sort of change isn't a bad one but if we're making this change, we >> should change the signature of these functions to also take a >> QemuChrHandlers *. >> > What do you mean? > -typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); +typedef void IOReadHandler(QemuChrHandlers *handler, const uint8_t *buf, int size); Then you can embed the structure in the state structure and use container_of to get the state. It's more type safe and it avoids adding a global variable. >> Also, let's drop the qemu_ and Qemu prefixes while we're at it. >> > In a later series, please. -ETOOMANYRESENDS already.. > It's part of CODING_STYLE... I think it's important to change the signatures so a new series will be required. Regards, Anthony Liguori > Amit >