From patchwork Sat Apr 17 09:49:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 50378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6AA06B7D00 for ; Sat, 17 Apr 2010 19:52:39 +1000 (EST) Received: from localhost ([127.0.0.1]:33999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O34fk-0001Sm-8F for incoming@patchwork.ozlabs.org; Sat, 17 Apr 2010 05:50:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O34dt-0001ST-DV for qemu-devel@nongnu.org; Sat, 17 Apr 2010 05:48:49 -0400 Received: from [140.186.70.92] (port=59499 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O34dr-0001S8-1J for qemu-devel@nongnu.org; Sat, 17 Apr 2010 05:48:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O34dn-0003Ta-TD for qemu-devel@nongnu.org; Sat, 17 Apr 2010 05:48:46 -0400 Received: from mtagate2.uk.ibm.com ([194.196.100.162]:44010) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O34dn-0003TM-LB for qemu-devel@nongnu.org; Sat, 17 Apr 2010 05:48:43 -0400 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o3H9mgEb016675 for ; Sat, 17 Apr 2010 09:48:42 GMT Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3H9mgIh1245268 for ; Sat, 17 Apr 2010 10:48:42 +0100 Received: from d06av04.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o3H9mfxq007224 for ; Sat, 17 Apr 2010 10:48:42 +0100 Received: from localhost.localdomain (sig-9-145-161-33.de.ibm.com [9.145.161.33]) by d06av04.portsmouth.uk.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o3H9meNa007210; Sat, 17 Apr 2010 10:48:41 +0100 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Sat, 17 Apr 2010 10:49:07 +0100 Message-Id: <1271497747-4463-2-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1271497747-4463-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1271497747-4463-1-git-send-email-stefanha@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Kevin Wolf , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 2/2] qcow2: Avoid shadowing variable in alloc_clusters_noref() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The i loop iterator is shadowed by the next free cluster index. Both using the variable name 'i' makes the code harder to read. Signed-off-by: Stefan Hajnoczi --- block/qcow2-refcount.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 47c9978..088d96d 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -554,8 +554,8 @@ static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size) nb_clusters = size_to_clusters(s, size); retry: for(i = 0; i < nb_clusters; i++) { - int64_t i = s->free_cluster_index++; - if (get_refcount(bs, i) != 0) + int64_t next_cluster_index = s->free_cluster_index++; + if (get_refcount(bs, next_cluster_index) != 0) goto retry; } #ifdef DEBUG_ALLOC2