qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH (trivial)] no need to use bdrv_pread() in format guessing code when we can use bdrv_read() directly
Date: Wed, 14 Mar 2012 09:25:08 +0000	[thread overview]
Message-ID: <CAJSP0QVctUdf2aPjma2k=brCN8p=Py9JrExVmwvPyX=nyA-aYQ@mail.gmail.com> (raw)
In-Reply-To: <1331655771-10868-1-git-send-email-mjt@msgid.tls.msk.ru>

On Tue, Mar 13, 2012 at 4:22 PM, Michael Tokarev <mjt@tls.msk.ru> wrote:
> [Sorry - sent the wrong patch, should have been
> BDRV_SECTOR_SIZE, not BDRV_BLOCK_SIZE....]
>
> block.c:find_image_format() calls bdrv_pread() to read first 2048
> bytes from the device to guess its format.  This function can use
> bdrv_read() directly since the the read is done on sector boundary.
>
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  block.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/block.c b/block.c
> index b88ee90..b3af1f6 100644
> --- a/block.c
> +++ b/block.c
> @@ -469,7 +469,7 @@ static int find_image_format(const char *filename, BlockDriver **pdrv)
>         return ret;
>     }
>
> -    ret = bdrv_pread(bs, 0, buf, sizeof(buf));
> +    ret = bdrv_read(bs, 0, buf, sizeof(buf) / BDRV_SECTOR_SIZE);

Why do this?  The code is nicer to read without the sector division
and there's no real difference at execution time.

Stefan

      reply	other threads:[~2012-03-14  9:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-13 16:18 [Qemu-devel] [PATCH (trivial)] no need to use bdrv_pread() in format guessing code when we can use bdrv_read() directly Michael Tokarev
2012-03-13 16:22 ` Michael Tokarev
2012-03-14  9:25   ` Stefan Hajnoczi [this message]

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='CAJSP0QVctUdf2aPjma2k=brCN8p=Py9JrExVmwvPyX=nyA-aYQ@mail.gmail.com' \
    --to=stefanha@gmail.com \
    --cc=mjt@tls.msk.ru \
    --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).