qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qcow2: Replace align_offset() with ROUND_UP()
Date: Tue, 30 Jan 2018 10:46:47 -0600	[thread overview]
Message-ID: <0127ca7d-958b-40cc-e714-bb7b61871502@redhat.com> (raw)
In-Reply-To: <w51372nuxj9.fsf@maestria.local.igalia.com>

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

  reply	other threads:[~2018-01-30 16:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-30 15:04 [Qemu-devel] [PATCH] qcow2: Replace align_offset() with ROUND_UP() Alberto Garcia
2018-01-30 16:03 ` Eric Blake
2018-01-30 16:08   ` Alberto Garcia
2018-01-30 16:17     ` Eric Blake
2018-01-30 16:22       ` Alberto Garcia
2018-01-30 16:46         ` Eric Blake [this message]
2018-01-31 10:55       ` Alberto Garcia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0127ca7d-958b-40cc-e714-bb7b61871502@redhat.com \
    --to=eblake@redhat.com \
    --cc=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).