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:03:16 -0600	[thread overview]
Message-ID: <b93f21cf-5cd4-a6d0-7005-e19a3de211c8@redhat.com> (raw)
In-Reply-To: <20180130150435.2553-1-berto@igalia.com>

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

On 01/30/2018 09:04 AM, Alberto Garcia wrote:
> The align_offset() function is equivalent to the ROUND_UP() macro so
> there's no need to use the former. The ROUND_UP() name is also a bit
> more explicit.
> 
> This patch uses ROUND_UP() instead of the slower QEMU_ALIGN_UP()
> because align_offset() already requires that the second parameter is a
> power of two.

(Presumably, for the cases where the second argument is a compile-time
constant, the compiler emits the same code for either macro - but I
agree that QEMU_ALIGN_UP can be slower where the compiler can't see it
is a power of 2)

> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
> +++ b/block/qcow2-bitmap.c
> @@ -413,7 +413,7 @@ static inline void bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry)
>  
>  static inline int calc_dir_entry_size(size_t name_size, size_t extra_data_size)
>  {
> -    return align_offset(sizeof(Qcow2BitmapDirEntry) +
> +    return ROUND_UP(sizeof(Qcow2BitmapDirEntry) +
>                          name_size + extra_data_size, 8);

Indentation alignment is now off.


> +++ b/block/qcow2.c

> @@ -3681,7 +3681,7 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,
>      has_backing_file = !!optstr;
>      g_free(optstr);
>  
> -    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);

and again.

With the whitespace fixed,
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
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:03 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 [this message]
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
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=b93f21cf-5cd4-a6d0-7005-e19a3de211c8@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).