From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ltem5-0004Di-JJ for qemu-devel@nongnu.org; Tue, 14 Apr 2009 05:17:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ltem0-0004Bf-AA for qemu-devel@nongnu.org; Tue, 14 Apr 2009 05:17:48 -0400 Received: from [199.232.76.173] (port=48791 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ltem0-0004BJ-0i for qemu-devel@nongnu.org; Tue, 14 Apr 2009 05:17:44 -0400 Received: from mx2.redhat.com ([66.187.237.31]:51892) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ltelx-00024k-GG for qemu-devel@nongnu.org; Tue, 14 Apr 2009 05:17:43 -0400 From: Kevin Wolf Date: Tue, 14 Apr 2009 11:16:22 +0200 Message-Id: <1239700582-5615-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH][RESEND] qemu-io: Fix handling of bdrv_is_allocated() return value Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , hch@lst.de 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 --- 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