qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, hch@lst.de
Subject: [Qemu-devel] [PATCH][RESEND] qemu-io: Fix handling of bdrv_is_allocated() return value
Date: Tue, 14 Apr 2009 11:16:22 +0200	[thread overview]
Message-ID: <1239700582-5615-1-git-send-email-kwolf@redhat.com> (raw)

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 <kwolf@redhat.com>
---
 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	other threads:[~2009-04-14  9:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-14  9:16 Kevin Wolf [this message]
2009-04-14 10:52 ` [Qemu-devel] [PATCH][RESEND] qemu-io: Fix handling of bdrv_is_allocated() return value Christoph Hellwig
2009-04-18 15:40 ` [Qemu-devel] " Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1239700582-5615-1-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=hch@lst.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).