From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXXJA-0007Cl-SH for qemu-devel@nongnu.org; Wed, 20 Jan 2010 04:57:04 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXXJ6-0007B4-Sh for qemu-devel@nongnu.org; Wed, 20 Jan 2010 04:57:04 -0500 Received: from [199.232.76.173] (port=45489 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXXJ6-0007Av-L9 for qemu-devel@nongnu.org; Wed, 20 Jan 2010 04:57:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27867) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NXXJ6-00023G-8u for qemu-devel@nongnu.org; Wed, 20 Jan 2010 04:57:00 -0500 Message-ID: <4B56D32A.2090800@redhat.com> Date: Wed, 20 Jan 2010 10:55:54 +0100 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 08/10] qcow2: Allow updating no refcounts References: <1263816696-24122-1-git-send-email-kwolf@redhat.com> <1263816696-24122-9-git-send-email-kwolf@redhat.com> <20100119185328.GB31526@lst.de> In-Reply-To: <20100119185328.GB31526@lst.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: qemu-devel@nongnu.org Am 19.01.2010 19:53, schrieb Christoph Hellwig: >> #endif >> - if (length <= 0) >> + if (length < 0) { >> return -EINVAL; >> + } >> + >> start = offset & ~(s->cluster_size - 1); >> last = (offset + length - 1) & ~(s->cluster_size - 1); >> for(cluster_offset = start; cluster_offset <= last; > > So for legnth = 0, last will equal start and we'll never go through > the loop. But should we really bother with all the other work in the > function or just return 0 early on? I'm not a big fan of special-casing for no real reason ("all the other work" basically is calculating start and last and skipping two ifs - and length = 0 is an unusual case anyway), but if you really mind we can change it. Kevin