From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=51854 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PctsH-0008BS-Nq for qemu-devel@nongnu.org; Wed, 12 Jan 2011 01:08:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PctsG-0007rD-7i for qemu-devel@nongnu.org; Wed, 12 Jan 2011 01:08:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PctsF-0007r4-TP for qemu-devel@nongnu.org; Wed, 12 Jan 2011 01:08:00 -0500 Date: Wed, 12 Jan 2011 11:37:45 +0530 From: Amit Shah Subject: Re: [Qemu-devel] [PATCH 1/5] char: Add a QemuChrHandlers struct to initialise chardev handlers Message-ID: <20110112060743.GB12381@amit-x200.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Gerd Hoffmann , qemu list , Paul Brook On (Tue) Jan 11 2011 [17:13:15], Blue Swirl wrote: > > +static QemuChrHandlers gdb_handlers =3D { > > + =A0 =A0.fd_can_read =3D gdb_chr_can_receive, > > + =A0 =A0.fd_read =3D gdb_chr_receive, > > + =A0 =A0.fd_event =3D gdb_chr_event, > > +}; >=20 > These structures should be const. Hm, I had that but looks like it got lost in some rebase. Added again. > > @@ -190,15 +190,19 @@ void qemu_chr_send_event(CharDriverState *s, in= t event) > > =A0 =A0 =A0 =A0 s->chr_send_event(s, event); > > =A0} > > > > +static QemuChrHandlers null_handlers =3D { > > + =A0 =A0/* All handlers are initialised to NULL */ > > +}; > > + > > =A0void qemu_chr_add_handlers(CharDriverState *s, > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IOCanReadHandle= r *fd_can_read, > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IOReadHandler *= fd_read, > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IOEventHandler = *fd_event, > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 void *opaque) > > -{ > > - =A0 =A0s->chr_can_read =3D fd_can_read; > > - =A0 =A0s->chr_read =3D fd_read; > > - =A0 =A0s->chr_event =3D fd_event; > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 QemuChrHandlers= *handlers, void *opaque) > > +{ >=20 > Here we could also check if (!s) and return if so. This would simplify > the callers a bit. Simplified in what way? Amit