From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrYtK-0003wd-Bg for qemu-devel@nongnu.org; Tue, 16 Mar 2010 11:41:10 -0400 Received: from [199.232.76.173] (port=41137 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrYtJ-0003wB-UF for qemu-devel@nongnu.org; Tue, 16 Mar 2010 11:41:09 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NrYtI-0006p3-P7 for qemu-devel@nongnu.org; Tue, 16 Mar 2010 11:41:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16031) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NrYtI-0006oz-Cn for qemu-devel@nongnu.org; Tue, 16 Mar 2010 11:41:08 -0400 Date: Tue, 16 Mar 2010 17:37:39 +0200 From: "Michael S. Tsirkin" Message-ID: <20100316153739.GA13674@redhat.com> References: <36c10281d19b4c845444363273657c4709210e35.1267636215.git.mst@redhat.com> <20100305181911.GA24686@amit-x200.redhat.com> <20100306190635.GB12235@redhat.com> <20100308062023.GD8436@amit-x200.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100308062023.GD8436@amit-x200.redhat.com> Subject: [Qemu-devel] Re: [PATCHv4 09/12] vhost: vhost net support List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: quintela@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com On Mon, Mar 08, 2010 at 11:50:23AM +0530, Amit Shah wrote: > On (Sat) Mar 06 2010 [21:06:35], Michael S. Tsirkin wrote: > > > > > > + r = vhost_virtqueue_set_addr(dev, vq, idx, dev->log_enabled); > > > > + if (r < 0) { > > > > + r = -errno; > > > > + goto fail_alloc; > > > > + } > > > > + if (!vdev->binding->guest_notifier || !vdev->binding->host_notifier) { > > > > + fprintf(stderr, "binding does not support irqfd/queuefd\n"); > > > > + r = -ENOSYS; > > > > + goto fail_alloc; > > > > + } > > > > > > This could be checked much earlier on in the function; so that we avoid > > > doing all that stuff above and the cleanup. > > > > Whatever order we put checks in, we'll have to undo stuff > > done beforehand on error. > > Not if you do this check before any ioctls or allocations. > !vdev->binding->guest_notifier is not dependent on anything you do above > it in this function, so just checking for this first thing in the > function will not need any cleanup. > > > Amit Yes, but I think it's clearer to do check function just before calling it. No?