Skip to contentSkip to conversation

block/raw-win32: Always use -errno in hdev_open

PATCH Applied Max Reitz 3 participants 3 messages Oct 11, 2013 – Oct 17, 2013 Block layer

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 block/raw-win32: Always use -errno in hdev_open

On one occasion, hdev_open() returned -1 in case of an unknown error instead of a proper -errno value. Adjust this to match the behavior of raw_open() (in raw-win32), which is to return -EINVAL in this case. Also, change the call to error_setg*() to match the one in raw_open() as well.

---
Follow-up to (as suggested by Eric):
- block/raw-win32: Employ error parameter
(3/5 from the "block: Employ error parameter" series)

---
 block/raw-win32.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
block/raw-win32.c +2 -3
index c3e4c62..676b570 100644
@@ -590,12 +590,11 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
         int err = GetLastError();
 
         if (err == ERROR_ACCESS_DENIED) {
-            error_setg_errno(errp, EACCES, "Could not open device");
             ret = -EACCES;
         } else {
-            error_setg(errp, "Could not open device");
-            ret = -1;
+            ret = -EINVAL;
         }
+        error_setg_errno(errp, -ret, "Could not open device");
         goto done;
     }
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Max Reitz

On one occasion, hdev_open() returned -1 in case of an unknown error instead of a proper -errno value. Adjust this to match the behavior of raw_open() (in raw-win32), which is to return -EINVAL in this case. Also, change the call to error_setg*() to match the one in raw_open() as well.

Quoted 8 lines

---
Follow-up to (as suggested by Eric):
- block/raw-win32: Employ error parameter
(3/5 from the "block: Employ error parameter" series)

---
 block/raw-win32.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
In reply to Max Reitz
Quoted 6 lines · Max Reitz

On one occasion, hdev_open() returned -1 in case of an unknown error instead of a proper -errno value. Adjust this to match the behavior of raw_open() (in raw-win32), which is to return -EINVAL in this case. Also, change the call to error_setg*() to match the one in raw_open() as well.

Quoted 8 lines

---
Follow-up to (as suggested by Eric):
- block/raw-win32: Employ error parameter
(3/5 from the "block: Employ error parameter" series)

---
 block/raw-win32.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan