diff options
author | Max Reitz <mreitz@redhat.com> | 2015-12-18 16:04:26 +0100 |
---|---|---|
committer | Jeff Cody <jcody@redhat.com> | 2016-02-29 14:54:31 -0500 |
commit | 04a3615860d693cbf5da015ee136a313628a42be (patch) | |
tree | d410443d0614124021420fc4686fcd551ab3c174 /block | |
parent | 939901dcd2093a5d6b40420314d1af8b185ec43c (diff) |
vhdx: Simplify vhdx_set_shift_bits()
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 <mreitz@redhat.com>
Message-id: 1450451066-13335-3-git-send-email-mreitz@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/vhdx.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/block/vhdx.c b/block/vhdx.c index 1e7e03ebed..9a51428317 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); } /* |