From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3NdX-00087P-93 for qemu-devel@nongnu.org; Wed, 15 Jan 2014 05:23:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3NdR-0000vO-AA for qemu-devel@nongnu.org; Wed, 15 Jan 2014 05:23:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3NdR-0000vD-16 for qemu-devel@nongnu.org; Wed, 15 Jan 2014 05:23:45 -0500 From: Kevin Wolf Date: Wed, 15 Jan 2014 11:22:50 +0100 Message-Id: <1389781375-11774-38-git-send-email-kwolf@redhat.com> In-Reply-To: <1389781375-11774-1-git-send-email-kwolf@redhat.com> References: <1389781375-11774-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 37/42] qemu-io: Make filename optional List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: 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 Signed-off-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 bfb773e..d669028 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -163,11 +163,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.1.4