From patchwork Thu Jun 16 16:06:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9181307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A8F86075D for ; Thu, 16 Jun 2016 16:07:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BC3A2835D for ; Thu, 16 Jun 2016 16:07:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10A5628362; Thu, 16 Jun 2016 16:07:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 600832835D for ; Thu, 16 Jun 2016 16:06:59 +0000 (UTC) Received: from localhost ([::1]:50490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDZon-0007WR-TO for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Jun 2016 12:06:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDZoK-0007U5-QD for qemu-devel@nongnu.org; Thu, 16 Jun 2016 12:06:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDZoI-0006Tt-M4 for qemu-devel@nongnu.org; Thu, 16 Jun 2016 12:06:27 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:57819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDZoI-0006T3-D3 for qemu-devel@nongnu.org; Thu, 16 Jun 2016 12:06:26 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bDZo9-0007Vx-Nr; Thu, 16 Jun 2016 17:06:17 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 16 Jun 2016 17:06:17 +0100 Message-Id: <1466093177-17890-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w() 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: Kevin Wolf , Max Reitz , qemu-block@nongnu.org, patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Don't use the cpu_to_*w() functions, which we are trying to deprecate. Instead either just use cpu_to_*() to do the byteswap, or use st*_be_p() if we need to do the store somewhere other than to a variable that's already the correct type. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake --- block/qcow2-cluster.c | 2 +- block/qcow2-refcount.c | 11 +++++------ block/qcow2.c | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index b04bfaf..4acf0e3 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -117,7 +117,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, /* set new table */ BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE); - cpu_to_be32w((uint32_t*)data, new_l1_size); + stl_be_p(data, new_l1_size); stq_be_p(data + 4, new_l1_table_offset); ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, l1_size), data, sizeof(data)); diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 66f187a..088c00f 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -565,8 +565,8 @@ static int alloc_refcount_block(BlockDriverState *bs, uint64_t d64; uint32_t d32; } data; - cpu_to_be64w(&data.d64, table_offset); - cpu_to_be32w(&data.d32, table_clusters); + data.d64 = cpu_to_be64(table_offset); + data.d32 = cpu_to_be32(table_clusters); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE); ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, refcount_table_offset), @@ -2158,10 +2158,9 @@ write_refblocks: } /* Enter new reftable into the image header */ - cpu_to_be64w(&reftable_offset_and_clusters.reftable_offset, - reftable_offset); - cpu_to_be32w(&reftable_offset_and_clusters.reftable_clusters, - size_to_clusters(s, reftable_size * sizeof(uint64_t))); + reftable_offset_and_clusters.reftable_offset = cpu_to_be64(reftable_offset); + reftable_offset_and_clusters.reftable_clusters = + cpu_to_be32(size_to_clusters(s, reftable_size * sizeof(uint64_t))); ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, refcount_table_offset), &reftable_offset_and_clusters, diff --git a/block/qcow2.c b/block/qcow2.c index 6f5fb81..860d7b7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2686,9 +2686,9 @@ static int make_completely_empty(BlockDriverState *bs) /* "Create" an empty reftable (one cluster) directly after the image * header and an empty L1 table three clusters after the image header; * the cluster between those two will be used as the first refblock */ - cpu_to_be64w(&l1_ofs_rt_ofs_cls.l1_offset, 3 * s->cluster_size); - cpu_to_be64w(&l1_ofs_rt_ofs_cls.reftable_offset, s->cluster_size); - cpu_to_be32w(&l1_ofs_rt_ofs_cls.reftable_clusters, 1); + l1_ofs_rt_ofs_cls.l1_offset = cpu_to_be64(3 * s->cluster_size); + l1_ofs_rt_ofs_cls.reftable_offset = cpu_to_be64(s->cluster_size); + l1_ofs_rt_ofs_cls.reftable_clusters = cpu_to_be32(1); ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, l1_table_offset), &l1_ofs_rt_ofs_cls, sizeof(l1_ofs_rt_ofs_cls)); if (ret < 0) {