qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Nir Soffer <nirsof@gmail.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
	Nir Soffer <nsoffer@redhat.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] block: Use QEMU_IS_ALIGNED instead of reinventing it
Date: Tue, 20 Aug 2019 21:50:53 +0200	[thread overview]
Message-ID: <0d8c2c6a-55ef-3517-b93c-05d9a04e5d26@redhat.com> (raw)
In-Reply-To: <20190817175346.12518-1-nsoffer@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 971 bytes --]

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 <nsoffer@redhat.com>
> ---
>  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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2019-08-20 19:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-17 17:53 [Qemu-devel] [PATCH] block: Use QEMU_IS_ALIGNED instead of reinventing it Nir Soffer
2019-08-20 19:27 ` [Qemu-devel] [Qemu-block] " John Snow
2019-08-20 20:28   ` Nir Soffer
2019-08-20 19:50 ` Max Reitz [this message]
2019-08-20 20:46   ` [Qemu-devel] " Nir Soffer

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=0d8c2c6a-55ef-3517-b93c-05d9a04e5d26@redhat.com \
    --to=mreitz@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=nirsof@gmail.com \
    --cc=nsoffer@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).