Patchwork [1/2] qemu-nbd: Fix return value handling of bdrv_open

login
register
mail settings
Submitter Ryota OZAKI
Date March 20, 2010, 4:50 a.m.
Message ID <1269060643-3321-1-git-send-email-ozaki.ryota@gmail.com>
Download mbox | patch
Permalink /patch/48198/
State New
Headers show

Comments

Ryota OZAKI - March 20, 2010, 4:50 a.m.
bdrv_open may return -errno so we have to check
if the return value is '< 0', not '== -1'.
---
 qemu-nbd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/qemu-nbd.c b/qemu-nbd.c
index a393583..b89c361 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -333,7 +333,7 @@  int main(int argc, char **argv)
     if (bs == NULL)
         return 1;
 
-    if (bdrv_open(bs, argv[optind], flags) == -1)
+    if (bdrv_open(bs, argv[optind], flags) < 0)
         return 1;
 
     fd_size = bs->total_sectors * 512;