qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] qemu-io: Fix handling of bdrv_is_allocated() return


From: Kevin Wolf
Subject: [Qemu-devel] [PATCH] qemu-io: Fix handling of bdrv_is_allocated() return value
Date: Thu, 9 Apr 2009 15:05:27 +0200

bdrv_is_allocated() returns a boolean which indicates if the offset is
allocated, not 0 on success and everything else is an error.

Signed-off-by: Kevin Wolf <address@hidden>
---
 qemu-io.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/qemu-io.c b/qemu-io.c
index 466d22c..3e5c444 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -794,6 +794,7 @@ alloc_f(int argc, char **argv)
        char s1[64];
        int num;
        int ret;
+       const char *retstr;
 
        offset = cvtnum(argv[1]);
        if (offset & 0x1ff) {
@@ -808,18 +809,15 @@ alloc_f(int argc, char **argv)
                nb_sectors = 1;
 
        ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num);
-       if (ret) {
-               printf("is_allocated: %s", strerror(ret));
-               return 0;
-       }
 
        cvtstr(offset, s1, sizeof(s1));
 
+       retstr = ret ? "allocated" : "not allocated";
        if (nb_sectors == 1)
-               printf("sector allocated at offset %s\n", s1);
+               printf("sector %s at offset %s\n", retstr, s1);
        else
-               printf("%d/%d sectors allocated at offset %s\n",
-                       num, nb_sectors, s1);
+               printf("%d/%d sectors %s at offset %s\n",
+                       num, nb_sectors, retstr, s1);
        return 0;
 }
 
-- 
1.6.0.6





reply via email to

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