Skip to contentSkip to conversation

qemu-io: Fix return value handling of bdrv_open

PATCH Applied Ryota Ozaki 3 participants 3 messages Mar 20, 2010 – Mar 27, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-io: Fix return value handling of bdrv_open

bdrv_open may return -errno so we have to check
if the return value is '< 0', not '== -1'.

---
 qemu-io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-io.c +1 -1
index b2f2f5a..2f195bf 100644
@@ -1284,7 +1284,7 @@ static int openfile(char *name, int flags, int growable)
 		flags |= BDRV_O_FILE;
 	}
 
-	if (bdrv_open(bs, name, flags) == -1) {
+	if (bdrv_open(bs, name, flags) < 0) {
 		fprintf(stderr, "%s: can't open device %s\n", progname, name);
 		bs = NULL;
 		return 1;
Signature · 1 line
1.6.5.2
#1 lore raw
Quoted 2 lines · Ryota Ozaki

bdrv_open may return -errno so we have to check
if the return value is '< 0', not '== -1'.

Looks good, thanks!

#2 lore raw
In reply to Ryota Ozaki
Quoted 2 lines · Ryota Ozaki

bdrv_open may return -errno so we have to check
if the return value is '< 0', not '== -1'.

Thanks, applied.

Quoted 24 lines
---
 qemu-io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-io.c +1 -1
index b2f2f5a..2f195bf 100644
@@ -1284,7 +1284,7 @@ static int openfile(char *name, int flags, int growable)
 		flags |= BDRV_O_FILE;
 	}
 
-	if (bdrv_open(bs, name, flags) == -1) {
+	if (bdrv_open(bs, name, flags) < 0) {
 		fprintf(stderr, "%s: can't open device %s\n", progname, name);
 		bs = NULL;
 		return 1;
Signature · 1 line
1.6.5.2
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net