From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xorcu-0007Tn-J9 for qemu-devel@nongnu.org; Thu, 13 Nov 2014 05:27:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xorco-0007cn-Ey for qemu-devel@nongnu.org; Thu, 13 Nov 2014 05:27:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51203) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xorco-0007cj-39 for qemu-devel@nongnu.org; Thu, 13 Nov 2014 05:27:38 -0500 Message-ID: <54648791.5010302@redhat.com> Date: Thu, 13 Nov 2014 11:27:29 +0100 From: Max Reitz MIME-Version: 1.0 References: <1415873823-13844-1-git-send-email-armbru@redhat.com> <1415873823-13844-5-git-send-email-armbru@redhat.com> In-Reply-To: <1415873823-13844-5-git-send-email-armbru@redhat.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 4/4] raw-posix: Clean up around raw_co_get_block_status() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, tony@bakeyournoodle.com, stefanha@redhat.com, pbonzini@redhat.com On 2014-11-13 at 11:17, Markus Armbruster wrote: > try_seek_hole() doesn't really seek to a hole, it tries to find out > whether its argument is in a hole or not, and where the hole or > non-hole ends. Rename to find_allocation() and add a proper function > comment. > > Using arguments passed by reference like local variables is a bad > habit. Only assign to them right before return. > > Avoid nesting of conditionals. > > When find_allocation() fails, don't make up a range that'll get mapped > to nb_sectors, simply set *pnum = nb_sectors directly. > > Don't repeat BDRV_BLOCK_OFFSET_VALID | start. > > Drop a pointless assertion, add some meaningful ones. > > Signed-off-by: Markus Armbruster > --- > block/raw-posix.c | 62 +++++++++++++++++++++++++++++++++---------------------- > 1 file changed, 37 insertions(+), 25 deletions(-) > > diff --git a/block/raw-posix.c b/block/raw-posix.c > index 2a12a50..ea5b3b8 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -1478,28 +1478,43 @@ out: > return result; > } > > -static int try_seek_hole(BlockDriverState *bs, off_t start, off_t *data, > - off_t *hole) > +/* > + * Find allocation range in @bs around offset @start. > + * If @start is in a hole, store @start in @hole and the end of the > + * hole in @data, and return 0. > + * If @start is in a data, store @start to @data, and the end of the "is in a data" sounds funny enough I'd even like to keep it. Probably should be "data extent" or something similar. > + * data to @hole, and return 0. Here, too. With or without that changed: Reviewed-by: Max Reitz