From nobody Tue Dec 16 13:08:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515502908174.24085552922827; Thu, 11 May 2017 08:11:42 -0700 (PDT) Received: from localhost ([::1]:48736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pkh-00030y-8U for importer@patchew.org; Thu, 11 May 2017 11:11:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pB1-0002uF-EI for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAv-00085h-D8 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAo-0007xf-R6; Thu, 11 May 2017 10:34:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5B1A64D94; Thu, 11 May 2017 14:34:33 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF6D37A407; Thu, 11 May 2017 14:34:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5B1A64D94 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C5B1A64D94 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:49 +0200 Message-Id: <1494513181-7900-47-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 May 2017 14:34:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 46/58] qcow2: Nicer variable names in qcow2_update_snapshot_refcount() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake In order to keep checkpatch happy when the next patch changes indentation, we first have to shorten some long lines. The easiest approach is to use a new variable in place of 'offset & L2E_OFFSET_MASK', except that 'offset' is the best name for that variable. Change '[old_]offset' to '[old_]entry' to make room. While touching things, also fix checkpatch warnings about unusual 'for' statements. Suggested by Max Reitz Signed-off-by: Eric Blake Message-id: 20170507000552.20847-2-eblake@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 4efca7e..db0af2c 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1059,9 +1059,9 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, int64_t l1_table_offset, int l1_size, int addend) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, refcount; + uint64_t *l1_table, *l2_table, l2_offset, entry, l1_size2, refcount; bool l1_allocated =3D false; - int64_t old_offset, old_l2_offset; + int64_t old_entry, old_l2_offset; int i, j, l1_modified =3D 0, nb_csectors; int ret; =20 @@ -1089,15 +1089,16 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, goto fail; } =20 - for(i =3D 0;i < l1_size; i++) + for (i =3D 0; i < l1_size; i++) { be64_to_cpus(&l1_table[i]); + } } else { assert(l1_size =3D=3D s->l1_size); l1_table =3D s->l1_table; l1_allocated =3D false; } =20 - for(i =3D 0; i < l1_size; i++) { + for (i =3D 0; i < l1_size; i++) { l2_offset =3D l1_table[i]; if (l2_offset) { old_l2_offset =3D l2_offset; @@ -1117,20 +1118,22 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, goto fail; } =20 - for(j =3D 0; j < s->l2_size; j++) { + for (j =3D 0; j < s->l2_size; j++) { uint64_t cluster_index; + uint64_t offset; =20 - offset =3D be64_to_cpu(l2_table[j]); - old_offset =3D offset; - offset &=3D ~QCOW_OFLAG_COPIED; + entry =3D be64_to_cpu(l2_table[j]); + old_entry =3D entry; + entry &=3D ~QCOW_OFLAG_COPIED; + offset =3D entry & L2E_OFFSET_MASK; =20 - switch (qcow2_get_cluster_type(offset)) { + switch (qcow2_get_cluster_type(entry)) { case QCOW2_CLUSTER_COMPRESSED: - nb_csectors =3D ((offset >> s->csize_shift) & + nb_csectors =3D ((entry >> s->csize_shift) & s->csize_mask) + 1; if (addend !=3D 0) { ret =3D update_refcount(bs, - (offset & s->cluster_offset_mask) & ~511, + (entry & s->cluster_offset_mask) & ~511, nb_csectors * 512, abs(addend), addend < 0, QCOW2_DISCARD_SNAPSHOT); if (ret < 0) { @@ -1143,18 +1146,17 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, =20 case QCOW2_CLUSTER_NORMAL: case QCOW2_CLUSTER_ZERO: - if (offset_into_cluster(s, offset & L2E_OFFSET_MAS= K)) { + if (offset_into_cluster(s, offset)) { qcow2_signal_corruption(bs, true, -1, -1, "Dat= a " - "cluster offset %#llx " - "unaligned (L2 offset:= %#" + "cluster offset %#" PR= Ix64 + " unaligned (L2 offset= : %#" PRIx64 ", L2 index: %#= x)", - offset & L2E_OFFSET_MA= SK, - l2_offset, j); + offset, l2_offset, j); ret =3D -EIO; goto fail; } =20 - cluster_index =3D (offset & L2E_OFFSET_MASK) >> s-= >cluster_bits; + cluster_index =3D offset >> s->cluster_bits; if (!cluster_index) { /* unallocated */ refcount =3D 0; @@ -1184,14 +1186,14 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, } =20 if (refcount =3D=3D 1) { - offset |=3D QCOW_OFLAG_COPIED; + entry |=3D QCOW_OFLAG_COPIED; } - if (offset !=3D old_offset) { + if (entry !=3D old_entry) { if (addend > 0) { qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache); } - l2_table[j] =3D cpu_to_be64(offset); + l2_table[j] =3D cpu_to_be64(entry); qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); } --=20 1.8.3.1