From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzOi1-0005WA-Eg for qemu-devel@nongnu.org; Thu, 09 Aug 2012 05:07:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzOhx-0004I8-5R for qemu-devel@nongnu.org; Thu, 09 Aug 2012 05:07:13 -0400 Received: from paradis.irqsave.net ([109.190.18.76]:37831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzOhw-0004Gz-Tq for qemu-devel@nongnu.org; Thu, 09 Aug 2012 05:07:09 -0400 Date: Thu, 9 Aug 2012 11:07:00 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20120809090700.GA2928@irqsave.net> References: <1344347073-7773-1-git-send-email-benoit@irqsave.net> <1344347073-7773-6-git-send-email-benoit@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [RFC V2 05/10] quorum: Add quorum_getlength(). List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, =?iso-8859-1?Q?Beno=EEt?= Canet , stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org, blauwirbel@gmail.com, anthony@codemonkey.ws, pbonzini@redhat.com, eblake@redhat.com, afaerber@suse.de > > +static int64_t quorum_getlength(BlockDriverState *bs) > > +{ > > + BDRVQuorumState *s = bs->opaque; > > + int i; > > + int64_t ret; > > + > > + /* return the length of the first available quorum file */ > > + for (i = 0, ret = bdrv_getlength(s->bs[i]); > > + ret == -ENOMEDIUM && i <= 2; > > + i++, ret = bdrv_getlength(s->bs[i])) { > > + } > > Why is -ENOMEDIUM an expected error value? I put the -ENOMEDIUM test because of the following piece of code. /** * Length of a file in bytes. Return < 0 if error or unknown. */ int64_t bdrv_getlength(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (!drv) return -ENOMEDIUM; Still I am not sure it's needed. What is your stance on this ? > > IMO a for loop with a body or a do while loop would make this easier to read. > Ok