qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH (trivial)] no need to use bdrv_pread() in format


From: Stefan Hajnoczi
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

On Tue, Mar 13, 2012 at 4:22 PM, Michael Tokarev <address@hidden> 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 <address@hidden>
> ---
>  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 via email to

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