[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qcow2: Replace align_offset() with ROUND_UP()
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] qcow2: Replace align_offset() with ROUND_UP() |
Date: |
Tue, 30 Jan 2018 10:46:47 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 |
On 01/30/2018 10:22 AM, Alberto Garcia wrote:
> On Tue 30 Jan 2018 05:17:47 PM CET, Eric Blake wrote:
>> On 01/30/2018 10:08 AM, Alberto Garcia wrote:
>>> On Tue 30 Jan 2018 05:03:16 PM CET, Eric Blake wrote:
>>>
>>>>> - virtual_size = align_offset(qemu_opt_get_size_del(opts,
>>>>> BLOCK_OPT_SIZE, 0),
>>>>> + virtual_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE,
>>>>> 0),
>>>>> cluster_size);
>>>
>>> I just realized that the first parameter here is a function call with
>>> side effects, it it safe to use ROUND_UP() in this case?
>>>
>>> #define ROUND_UP(n, d) (((n) + (d) - 1) & -(0 ? (n) : (d)))
>>
>> Oh, good catch. No, we need a temporary variable to hold the result
>> of the function call
>
> ...which is what align_offset() was doing in the first place. I can
> still modify that function to use the macro internally.
Nah. I think the ROUND_UP naming is enough to remind us to be careful,
and since this was the only affected spot in your conversion, it's nicer
to drop align_offset() and just do:
virtual_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
virtual_size = ROUND_UP(virtual_size, cluster_size);
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature