qemu-devel
[Top][All Lists]
Advanced

[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:03:16 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

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 <address@hidden>
> ---
> +++ 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 <address@hidden>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]