From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40120 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPW1T-0000r4-Qg for qemu-devel@nongnu.org; Mon, 06 Dec 2010 03:02:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPW1P-0003gW-He for qemu-devel@nongnu.org; Mon, 06 Dec 2010 03:02:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPW1P-0003gG-Aj for qemu-devel@nongnu.org; Mon, 06 Dec 2010 03:02:07 -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.13.8/8.13.8) with ESMTP id oB6826sW014074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 6 Dec 2010 03:02:06 -0500 Message-ID: <4CFC987D.4090104@redhat.com> Date: Mon, 06 Dec 2010 09:02:05 +0100 From: Jes Sorensen 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> <4CF8E2E4.7030901@redhat.com> In-Reply-To: <4CF8E2E4.7030901@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: Kevin Wolf Cc: qemu-devel@nongnu.org On 12/03/10 13:30, Kevin Wolf wrote: > Am 02.12.2010 18:46, schrieb Jes.Sorensen@redhat.com: >> 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? There is a perfectly logical explanation for that. Doing that would require for me to have clue, which is a bit much to expect :) That said, we should really do the same for the c == -1 case as well. Fixed in next version. Cheers, Jes