From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vtja8-0006Lv-Kf for qemu-devel@nongnu.org; Thu, 19 Dec 2013 14:48:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VtjZt-0005A2-Jq for qemu-devel@nongnu.org; Thu, 19 Dec 2013 14:48:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtjZt-00059t-Cf for qemu-devel@nongnu.org; Thu, 19 Dec 2013 14:48:13 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBJJmCxA023712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 19 Dec 2013 14:48:12 -0500 From: Max Reitz Date: Thu, 19 Dec 2013 20:47:21 +0100 Message-Id: <1387482443-10633-21-git-send-email-mreitz@redhat.com> In-Reply-To: <1387482443-10633-1-git-send-email-mreitz@redhat.com> References: <1387482443-10633-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v6 20/22] qemu-io: Make filename optional List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , Max Reitz Giving a filename is actually not essential, since it can be specified through the options as well - on the contrary: Sometimes a filename must not be given. Signed-off-by: Max Reitz Reviewed-by: Kevin Wolf --- qemu-io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index f180813..a0e0e22 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -160,11 +160,13 @@ static int open_f(BlockDriverState *bs, int argc, char **argv) flags |= BDRV_O_RDWR; } - if (optind != argc - 1) { + if (optind == argc - 1) { + return openfile(argv[optind], flags, growable, opts); + } else if (optind == argc) { + return openfile(NULL, flags, growable, opts); + } else { return qemuio_command_usage(&open_cmd); } - - return openfile(argv[optind], flags, growable, opts); } static int quit_f(BlockDriverState *bs, int argc, char **argv) -- 1.8.5.1