From: Max Reitz Date: Fri, 11 Oct 2013 12:30:16 +0000 (+0200) Subject: block/raw-win32: Always use -errno in hdev_open X-Git-Tag: v1.7.0-rc0~52^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=45d57f6e718e44e55780bcf1d09fa140dce7ec08;p=thirdparty%2Fqemu.git 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. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- diff --git a/block/raw-win32.c b/block/raw-win32.c index c3e4c62d53a..676b5701db6 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -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; }