From: Kitae Kim Date: Fri, 12 Jul 2013 06:17:56 +0000 (+0900) Subject: qemu: modified wrong return value and source clean-up. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~900^2~6^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f0a29f4fd617e0182fdc3f0a6791e7fbe0a4f94;p=sdk%2Femulator%2Fqemu.git qemu: modified wrong return value and source clean-up. Changed position of variable declaration because it causes compile warnings. Change-Id: I5473f5806ceac48087d0e213f3c9b21f6f734d89 Signed-off-by: Kitae Kim --- diff --git a/block/raw-win32.c b/block/raw-win32.c index 0a28e406cd..ed50a6f4e2 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -31,6 +31,9 @@ #include "qemu/iov.h" #include #include +#ifdef CONFIG_MARU +#include +#endif #define FTYPE_FILE 0 #define FTYPE_CD 1 @@ -243,6 +246,9 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags) Error *local_err = NULL; const char *filename; int ret; +#ifdef CONFIG_MARU + int open_flags; +#endif s->type = FTYPE_FILE; @@ -282,41 +288,38 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags) goto fail; } #else -#include - int open_flags; - - open_flags = O_BINARY & ~O_ACCMODE; - if (flags & BDRV_O_RDWR) { - open_flags |= O_RDWR; - } else { - open_flags |= O_RDONLY; - } + open_flags = O_BINARY & ~O_ACCMODE; + if (flags & BDRV_O_RDWR) { + open_flags |= O_RDWR; + } else { + open_flags |= O_RDONLY; + } - /* Use O_DSYNC for write-through caching, no flags for write-back caching, + /* Use O_DSYNC for write-through caching, no flags for write-back caching, * and O_DIRECT for no caching. */ - /* - if ((flags & BDRV_O_NOCACHE)) { - open_flags |= O_DIRECT; - } - if (!(flags & BDRV_O_CACHE_WB)) { - open_flags |= O_DSYNC; - } - */ + /* + if ((flags & BDRV_O_NOCACHE)) { + open_flags |= O_DIRECT; + } + if (!(flags & BDRV_O_CACHE_WB)) { + open_flags |= O_DSYNC; + } + */ + + if ((flags & BDRV_O_NATIVE_AIO) && aio == NULL) { + aio = win32_aio_init(); + if (aio == NULL) { + ret = -EINVAL; + goto fail; + } + } - if ((flags & BDRV_O_NATIVE_AIO) && aio == NULL) { - aio = win32_aio_init(); - if (aio == NULL) { - ret = -EINVAL; - goto fail; - } - } - - ret = qemu_open(filename, open_flags, 0644); - if (ret < 0) { - error_report("raw_open failed(%d) \n", ret); - return -errno; - } - s->hfile = (HANDLE)_get_osfhandle(ret); + ret = qemu_open(filename, open_flags, 0644); + if (ret < 0) { + error_report("raw_open failed(%d) \n", ret); + return -errno; + } + s->hfile = (HANDLE)_get_osfhandle(ret); #endif if (flags & BDRV_O_NATIVE_AIO) { @@ -575,6 +578,9 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags) DWORD overlapped; char device_name[64]; const char *filename = qdict_get_str(options, "filename"); +#ifdef CONFIG_MARU + int open_flags, ret; +#endif if (strstart(filename, "/dev/cdrom", NULL)) { if (find_cdrom(device_name, sizeof(device_name)) < 0) @@ -613,33 +619,30 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags) FILE_SHARE_READ, NULL, create_flags, overlapped, NULL); */ -#include - - int open_flags = O_BINARY; - open_flags &= ~O_ACCMODE; - if (flags & BDRV_O_RDWR) { - open_flags |= O_RDWR; - } else { - open_flags |= O_RDONLY; - } + open_flags = (O_BINARY & ~O_ACCMODE); + if (flags & BDRV_O_RDWR) { + open_flags |= O_RDWR; + } else { + open_flags |= O_RDONLY; + } - /* Use O_DSYNC for write-through caching, no flags for write-back caching, + /* Use O_DSYNC for write-through caching, no flags for write-back caching, * and O_DIRECT for no caching. */ - /* - if ((flags & BDRV_O_NOCACHE)) { - open_flags |= O_DIRECT; - } - if (!(flags & BDRV_O_CACHE_WB)) { - open_flags |= O_DSYNC; - } - */ + /* + if ((flags & BDRV_O_NOCACHE)) { + open_flags |= O_DIRECT; + } + if (!(flags & BDRV_O_CACHE_WB)) { + open_flags |= O_DSYNC; + } + */ - int ret = qemu_open(filename, open_flags, 0644); - if (ret < 0) { - error_report("raw_open failed(%d) \n", ret); - return -errno; - } - s->hfile = (HANDLE)_get_osfhandle(ret); + ret = qemu_open(filename, open_flags, 0644); + if (ret < 0) { + error_report("raw_open failed(%d) \n", ret); + return -errno; + } + s->hfile = (HANDLE)_get_osfhandle(ret); #endif return 0; } diff --git a/qemu-char.c b/qemu-char.c index 3c83444d47..62e1a85e7f 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1631,6 +1631,9 @@ static int win_chr_init(CharDriverState *chr, const char *filename) COMSTAT comstat; DWORD size; DWORD err; +#ifdef CONFIG_MARU + int open_flags, ret; +#endif s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL); if (!s->hsend) { @@ -1647,16 +1650,15 @@ static int win_chr_init(CharDriverState *chr, const char *filename) GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); #else - int open_flags = O_BINARY | O_RDWR; - // TODO : FILE_FLAG_OVERLAPPED - - int ret = qemu_open(filename, open_flags, 0644); - if (ret < 0) { - error_report("win_chr_init failed(%d) \n", ret); - return -errno; - } - s->hcom = (HANDLE)_get_osfhandle(ret); + open_flags = O_BINARY | O_RDWR; + // TODO : FILE_FLAG_OVERLAPPED + ret = qemu_open(filename, open_flags, 0644); + if (ret < 0) { + fprintf(stderr, "win_chr_init failed(%d)\n", ret); + goto fail; + } + s->hcom = (HANDLE)_get_osfhandle(ret); #endif if (s->hcom == INVALID_HANDLE_VALUE) { fprintf(stderr, "Failed CreateFile (%lu)\n", GetLastError()); @@ -3514,6 +3516,9 @@ QemuOptsList qemu_chardev_opts = { static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp) { HANDLE out; +#ifdef CONFIG_MARU + int open_flags, ret; +#endif if (file->in) { error_setg(errp, "input file not supported"); @@ -3524,15 +3529,13 @@ static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp) out = CreateFile(file->out, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); #else - int open_flags, ret; - - open_flags = O_BINARY | O_RDWR | O_CREAT | O_TRUNC; - ret = qemu_open(file->out, open_flags, 0644); - if (ret < 0) { - error_report("qemu_chr_open_win_file_out failed(%d) \n", ret); - return -errno; - } - out = (HANDLE)_get_osfhandle(ret); + open_flags = O_BINARY | O_RDWR | O_CREAT | O_TRUNC; + ret = qemu_open(file->out, open_flags, 0644); + if (ret < 0) { + error_setg(errp, "qemu_chr_open_win_file_out failed(%d)", ret); + return NULL; + } + out = (HANDLE)_get_osfhandle(ret); #endif if (out == INVALID_HANDLE_VALUE) { error_setg(errp, "open %s failed", file->out);