From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=50063 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPXUI-0006f9-W1 for qemu-devel@nongnu.org; Mon, 06 Dec 2010 04:36:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPXUH-0008VI-Ig for qemu-devel@nongnu.org; Mon, 06 Dec 2010 04:36:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPXUH-0008Uv-Bv for qemu-devel@nongnu.org; Mon, 06 Dec 2010 04:36:01 -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 oB69Zx5r029766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 6 Dec 2010 04:36:00 -0500 Message-ID: <4CFCAEC1.3060900@redhat.com> Date: Mon, 06 Dec 2010 10:37:05 +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> <4CF8E2E4.7030901@redhat.com> <4CFC987D.4090104@redhat.com> In-Reply-To: <4CFC987D.4090104@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 Cc: qemu-devel@nongnu.org Am 06.12.2010 09:02, schrieb Jes Sorensen: > 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. That's what I thought at first, too. But then the break relates to the switch instead of the for, so it would have to become a goto to a new label. Probably not a big improvement... Kevin