From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48440 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdGS6-0005cQ-IY for qemu-devel@nongnu.org; Thu, 13 Jan 2011 01:14:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PdGS5-0004qi-Eb for qemu-devel@nongnu.org; Thu, 13 Jan 2011 01:14:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PdGS5-0004qe-5q for qemu-devel@nongnu.org; Thu, 13 Jan 2011 01:14:29 -0500 Date: Thu, 13 Jan 2011 11:44:15 +0530 From: Amit Shah Subject: Re: [Qemu-devel] [PATCH 1/5] char: Add a QemuChrHandlers struct to initialise chardev handlers Message-ID: <20110113061415.GA8372@amit-x200.redhat.com> References: <20110112060743.GB12381@amit-x200.redhat.com> <4D2DEC5F.6050708@linux.vnet.ibm.com> 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: qemu list , Paul Brook , Michael Roth , Gerd Hoffmann On (Wed) Jan 12 2011 [19:03:58], Blue Swirl wrote: > >>>> +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 IOCanReadHan= dler *fd_can_read, > >>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IOReadHandle= r *fd_read, > >>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IOEventHandl= er *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 QemuChrHandl= ers *handlers, void *opaque) > >>>> +{ > >>> > >>> Here we could also check if (!s) and return if so. This would simpl= ify > >>> the callers a bit. > >> > >> Simplified in what way? > > > > I assume for reducing the need to have to check s->chr !=3D NULL ever= ytime > > beforehand. It's safer and would save a lot on repetitive code as wel= l. >=20 > Yes, that's what I meant. OK, can be added, but I'm wondering if it makes sense (i.e., if an assert would be better than return). Amit