diff mbox

[v3,06/10] block: Use bdrv_nb_sectors() in img_convert()

Message ID 1401473631-10724-7-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster May 30, 2014, 6:13 p.m. UTC
Instead of bdrv_getlength().  Replace variable output_length by
output_sectors.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 qemu-img.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Benoît Canet June 2, 2014, 3:02 p.m. UTC | #1
The Friday 30 May 2014 à 20:13:47 (+0200), Markus Armbruster wrote :
> Instead of bdrv_getlength().  Replace variable output_length by
> output_sectors.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  qemu-img.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index 1ad899e..8d996ba 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1478,13 +1478,13 @@ static int img_convert(int argc, char **argv)
>      buf = qemu_blockalign(out_bs, bufsectors * BDRV_SECTOR_SIZE);
>  
>      if (skip_create) {
> -        int64_t output_length = bdrv_getlength(out_bs);
> -        if (output_length < 0) {
> +        int64_t output_sectors = bdrv_nb_sectors(out_bs);
> +        if (output_sectors < 0) {
>              error_report("unable to get output image length: %s\n",
> -                         strerror(-output_length));
> +                         strerror(-output_sectors));
>              ret = -1;
>              goto out;
> -        } else if (output_length < total_sectors << BDRV_SECTOR_BITS) {
> +        } else if (output_sectors < total_sectors) {
>              error_report("output file is smaller than input file");
>              ret = -1;
>              goto out;
> -- 
> 1.9.3
> 
> 

Reviewed-by: Benoit Canet <benoit@irqsave.net>
diff mbox

Patch

diff --git a/qemu-img.c b/qemu-img.c
index 1ad899e..8d996ba 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1478,13 +1478,13 @@  static int img_convert(int argc, char **argv)
     buf = qemu_blockalign(out_bs, bufsectors * BDRV_SECTOR_SIZE);
 
     if (skip_create) {
-        int64_t output_length = bdrv_getlength(out_bs);
-        if (output_length < 0) {
+        int64_t output_sectors = bdrv_nb_sectors(out_bs);
+        if (output_sectors < 0) {
             error_report("unable to get output image length: %s\n",
-                         strerror(-output_length));
+                         strerror(-output_sectors));
             ret = -1;
             goto out;
-        } else if (output_length < total_sectors << BDRV_SECTOR_BITS) {
+        } else if (output_sectors < total_sectors) {
             error_report("output file is smaller than input file");
             ret = -1;
             goto out;