[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/12] vhdx: Simplify vhdx_set_shift_bits()
From: |
Jeff Cody |
Subject: |
[Qemu-devel] [PULL 07/12] vhdx: Simplify vhdx_set_shift_bits() |
Date: |
Mon, 29 Feb 2016 15:08:47 -0500 |
From: Max Reitz <address@hidden>
For values which are powers of two (and we do assume all of these to
be), sizeof(x) * 8 - 1 - clz(x) == ctz(x). Therefore, use ctz().
Signed-off-by: Max Reitz <address@hidden>
Message-id: address@hidden
Signed-off-by: Jeff Cody <address@hidden>
---
block/vhdx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/vhdx.c b/block/vhdx.c
index 1e7e03e..9a51428 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -264,10 +264,10 @@ static void vhdx_region_unregister_all(BDRVVHDXState *s)
static void vhdx_set_shift_bits(BDRVVHDXState *s)
{
- s->logical_sector_size_bits = 31 - clz32(s->logical_sector_size);
- s->sectors_per_block_bits = 31 - clz32(s->sectors_per_block);
- s->chunk_ratio_bits = 63 - clz64(s->chunk_ratio);
- s->block_size_bits = 31 - clz32(s->block_size);
+ s->logical_sector_size_bits = ctz32(s->logical_sector_size);
+ s->sectors_per_block_bits = ctz32(s->sectors_per_block);
+ s->chunk_ratio_bits = ctz64(s->chunk_ratio);
+ s->block_size_bits = ctz32(s->block_size);
}
/*
--
1.9.3
- [Qemu-devel] [PULL 00/12] Block patches, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 02/12] sheepdog: allow to delete snapshot, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 01/12] block/nfs: add support for setting debug level, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 04/12] curl: add support for HTTP authentication parameters, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 05/12] iscsi: add support for getting CHAP password via QCryptoSecret API, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 07/12] vhdx: Simplify vhdx_set_shift_bits(),
Jeff Cody <=
- [Qemu-devel] [PULL 03/12] rbd: add support for getting password from QCryptoSecret object, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 09/12] mirror: Add mirror_wait_for_io, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 06/12] vhdx: DIV_ROUND_UP() in vhdx_calc_bat_entries(), Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 12/12] iotests/124: Add cluster_size mismatch test, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 11/12] block/backup: avoid copying less than full target clusters, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 08/12] mirror: Rewrite mirror_iteration, Jeff Cody, 2016/02/29
- [Qemu-devel] [PULL 10/12] block/backup: make backup cluster size configurable, Jeff Cody, 2016/02/29