From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48122 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POUlU-00030N-7i for qemu-devel@nongnu.org; Fri, 03 Dec 2010 07:29:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POUlT-00033z-2D for qemu-devel@nongnu.org; Fri, 03 Dec 2010 07:29:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POUlS-00033k-Rl for qemu-devel@nongnu.org; Fri, 03 Dec 2010 07:29:27 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB3CTPGs018660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 3 Dec 2010 07:29:25 -0500 Message-ID: <4CF8E2E4.7030901@redhat.com> Date: Fri, 03 Dec 2010 13:30:28 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1291312009-24351-1-git-send-email-Jes.Sorensen@redhat.com> <1291312009-24351-4-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1291312009-24351-4-git-send-email-Jes.Sorensen@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 3/3] Fail if detecting an unknown option List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes.Sorensen@redhat.com Cc: qemu-devel@nongnu.org Am 02.12.2010 18:46, schrieb Jes.Sorensen@redhat.com: > From: Jes Sorensen > > This patch changes qemu-img to exit if an unknown option is detected, > instead of trying to continue with a set of arguments which may be > incorrect. > > Signed-off-by: Jes Sorensen > --- > qemu-img.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 48 insertions(+), 0 deletions(-) > > diff --git a/qemu-img.c b/qemu-img.c > index d0dc445..f2e1c94 100644 > --- a/qemu-img.c > +++ b/qemu-img.c > @@ -304,6 +304,12 @@ static int img_create(int argc, char **argv) > flags = 0; > for(;;) { > c = getopt(argc, argv, "F:b:f:he6o:"); > + /* > + * Fail if we detect an unknown argument > + */ > + if (c == '?') { > + return 1; > + } > if (c == -1) { > break; > } Why not making it another case in the switch statement below instead of an additional if? Kevin