qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] block: Use QEMU_IS_ALIGNED instead of reinventi


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH] block: Use QEMU_IS_ALIGNED instead of reinventing it
Date: Tue, 20 Aug 2019 21:50:53 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 17.08.19 19:53, Nir Soffer wrote:
> Replace instances of:
> 
>     (n & (BDRV_SECTOR_SIZE - 1)) == 0)
> 
> With:
> 
>     QEMU_IS_ALIGNED(n, BDRV_SECTOR_SIZE)
> 
> Which reveals the intent of the code better, and makes it easier to
> locate the code checking alignment.
> 
> QEMU_IS_ALIGNED is implemented using %, which may be less efficient but
> it is used only in assert() except one instance, so it should not
> matter.
> 
> Signed-off-by: Nir Soffer <address@hidden>
> ---
>  block/bochs.c | 4 ++--
>  block/cloop.c | 4 ++--
>  block/dmg.c   | 4 ++--
>  block/io.c    | 8 ++++----
>  block/qcow2.c | 4 ++--
>  block/vvfat.c | 8 ++++----
>  qemu-img.c    | 2 +-
>  7 files changed, 17 insertions(+), 17 deletions(-)

Because John was speaking about a magical incantation, I found
BDRV_SECTOR_MASK.  There are two places in block/qcow2-cluster.c that
use that to check alignment, I think those should be amended as well.

Max

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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