From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XR07t-00025n-7t for qemu-devel@nongnu.org; Mon, 08 Sep 2014 10:41:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XR07k-00006v-7A for qemu-devel@nongnu.org; Mon, 08 Sep 2014 10:41:05 -0400 Received: from mail-pd0-x230.google.com ([2607:f8b0:400e:c02::230]:37203) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XR07j-00006k-US for qemu-devel@nongnu.org; Mon, 08 Sep 2014 10:40:56 -0400 Received: by mail-pd0-f176.google.com with SMTP id y13so3164573pdi.35 for ; Mon, 08 Sep 2014 07:40:54 -0700 (PDT) From: Xiaodong Gong Date: Mon, 8 Sep 2014 22:40:44 +0800 Message-Id: <1410187244-8266-1-git-send-email-gordon@localhost.localdomain> Subject: [Qemu-devel] [PATCH] Fix improper usage of cpu_to_be32 in vpc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kwolf@redhat.com Cc: qemu-devel@nongnu.org, stefanha@redhat.com, Xiaodong Gong From: Xiaodong Gong cpu_to_be32() is wrong since vhd_type is an enum constant (just a regular CPU-endian integer). Signed-off-by: Xiaodong Gong --- block/vpc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 055efc4..c024b4c 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -489,7 +489,7 @@ static int vpc_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) BDRVVPCState *s = (BDRVVPCState *)bs->opaque; VHDFooter *footer = (VHDFooter *) s->footer_buf; - if (cpu_to_be32(footer->type) != VHD_FIXED) { + if (be32_to_cpu(footer->type) != VHD_FIXED) { bdi->cluster_size = s->block_size; } @@ -506,7 +506,7 @@ static int vpc_read(BlockDriverState *bs, int64_t sector_num, int64_t sectors, sectors_per_block; VHDFooter *footer = (VHDFooter *) s->footer_buf; - if (cpu_to_be32(footer->type) == VHD_FIXED) { + if (be32_to_cpu(footer->type) == VHD_FIXED) { return bdrv_read(bs->file, sector_num, buf, nb_sectors); } while (nb_sectors > 0) { @@ -555,7 +555,7 @@ static int vpc_write(BlockDriverState *bs, int64_t sector_num, int ret; VHDFooter *footer = (VHDFooter *) s->footer_buf; - if (cpu_to_be32(footer->type) == VHD_FIXED) { + if (be32_to_cpu(footer->type) == VHD_FIXED) { return bdrv_write(bs->file, sector_num, buf, nb_sectors); } while (nb_sectors > 0) { @@ -857,7 +857,7 @@ static int vpc_has_zero_init(BlockDriverState *bs) BDRVVPCState *s = bs->opaque; VHDFooter *footer = (VHDFooter *) s->footer_buf; - if (cpu_to_be32(footer->type) == VHD_FIXED) { + if (be32_to_cpu(footer->type) == VHD_FIXED) { return bdrv_has_zero_init(bs->file); } else { return 1; -- 1.8.3.1