no need to use bdrv_pread() in format guessing code when we can use bdrv_read() directly
PATCH 1/1 no need to use bdrv_pread() in format guessing code when we can use bdrv_read() directly
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.
--- block.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
block.c +1 -1
@@ -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_BLOCK_SIZE );bdrv_delete (bs);if (ret <0 ) { *pdrv =NULL ;
Signature · 1 line
1.7.9.1
PATCH 1/1 no need to use bdrv_pread() in format guessing code when we can use bdrv_read() directly
[Sorry - sent the wrong patch, should have beenBDRV_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.
--- block.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
block.c +1 -1
@@ -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 );bdrv_delete (bs);if (ret <0 ) { *pdrv =NULL ;
Signature · 1 line
1.7.9.1
Quoted 17 lines · Michael Tokarev
[Sorry - sent the wrong patch, should have been
BDRV_SECTOR_SIZE, notBDRV_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 usebdrv_read()directly since the the read is done on sector boundary.Signed-off-by Michael Tokarev <[email protected]>---
block.c | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)block.c +0
-0
block.c static int find_image_format(const char *filename, BlockDriver **pdrv) · line 472
Quoted 5 lines
block.c +1
-1@@ -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