From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqoFs-0002FJ-BT for qemu-devel@nongnu.org; Wed, 11 Dec 2013 13:11:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VqoFm-0002Lu-Ce for qemu-devel@nongnu.org; Wed, 11 Dec 2013 13:11:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqoFm-0002Lo-4d for qemu-devel@nongnu.org; Wed, 11 Dec 2013 13:11:22 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBBIBLVi022250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 11 Dec 2013 13:11:21 -0500 From: Max Reitz Date: Wed, 11 Dec 2013 19:11:12 +0100 Message-Id: <1386785473-26157-21-git-send-email-mreitz@redhat.com> In-Reply-To: <1386785473-26157-1-git-send-email-mreitz@redhat.com> References: <1386785473-26157-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v3 20/21] 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 --- 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