From nobody Thu Nov 6 13:51:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489388171019729.5613691021019; Sun, 12 Mar 2017 23:56:11 -0700 (PDT) Received: from localhost ([::1]:50554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnJtp-0003dR-TU for importer@patchew.org; Mon, 13 Mar 2017 02:56:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnJt1-0003bv-5y for qemu-devel@nongnu.org; Mon, 13 Mar 2017 02:55:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnJsx-0004Rk-9z for qemu-devel@nongnu.org; Mon, 13 Mar 2017 02:55:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnJsx-0004Re-4V for qemu-devel@nongnu.org; Mon, 13 Mar 2017 02:55:15 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A187C05AA41 for ; Mon, 13 Mar 2017 06:55:14 +0000 (UTC) Received: from localhost (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2D6tBe6021733; Mon, 13 Mar 2017 02:55:13 -0400 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Mon, 13 Mar 2017 13:11:08 +0800 Message-Id: <20170313051108.26811-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 13 Mar 2017 06:55:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qemu-img: show help for invalid global options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The qemu-img sub-command executes regardless of invalid global options: $ qemu-img --foo info test.img qemu-img: unrecognized option '--foo' image: test.img ... The unrecognized option warning may be missed by the user. This can hide incorrect command-lines in scripts and confuse users. This patch prints the help information and terminates instead of executing the sub-command. Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- qemu-img.c | 1 + 1 file changed, 1 insertion(+) diff --git a/qemu-img.c b/qemu-img.c index 98b836b..ce293a4 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -4339,6 +4339,7 @@ int main(int argc, char **argv) while ((c =3D getopt_long(argc, argv, "+hVT:", long_options, NULL)) != =3D -1) { switch (c) { case 'h': + case '?': help(); return 0; case 'V': --=20 2.9.3