From 7dacd8bd3d1f7eeb1850d5ad8e1898e6d314889f Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Tue, 13 Jun 2017 22:20:56 +0200 Subject: block/file-posix: Small fixes in raw_create() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Variables should be declared at the start of a block, and if a certain parameter value is not supported it may be better to return -ENOTSUP instead of -EINVAL. Signed-off-by: Max Reitz Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé Message-id: 20170613202107.10125-6-mreitz@redhat.com Signed-off-by: Max Reitz --- block/file-posix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'block/file-posix.c') diff --git a/block/file-posix.c b/block/file-posix.c index 4a40976d4c..3388def9b1 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1910,6 +1910,8 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) #endif case PREALLOC_MODE_FULL: { + int64_t num = 0, left = total_size; + /* * Knowing the final size from the beginning could allow the file * system driver to do less allocations and possibly avoid @@ -1921,7 +1923,6 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) goto out_close; } - int64_t num = 0, left = total_size; buf = g_malloc0(65536); while (left > 0) { @@ -1953,7 +1954,7 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) } break; default: - result = -EINVAL; + result = -ENOTSUP; error_setg(errp, "Unsupported preallocation mode: %s", PreallocMode_lookup[prealloc]); break; -- cgit v1.2.1