From patchwork Mon Feb 5 16:27:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 10200925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CB161602CA for ; Mon, 5 Feb 2018 16:33:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC97E28714 for ; Mon, 5 Feb 2018 16:33:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF71228769; Mon, 5 Feb 2018 16:33:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5056E28714 for ; Mon, 5 Feb 2018 16:33:14 +0000 (UTC) Received: from localhost ([::1]:60041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijhh-0004TR-Eg for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Feb 2018 11:33:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eijcb-0008Nz-3R for qemu-devel@nongnu.org; Mon, 05 Feb 2018 11:28:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eijca-00026g-4W for qemu-devel@nongnu.org; Mon, 05 Feb 2018 11:27:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46576) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eijcX-0001xT-Ax; Mon, 05 Feb 2018 11:27:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 715A97CB8B; Mon, 5 Feb 2018 16:27:52 +0000 (UTC) Received: from localhost (unknown [10.40.205.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA81D5EDE6; Mon, 5 Feb 2018 16:27:46 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 5 Feb 2018 17:27:45 +0100 Message-Id: <20180205162745.23650-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 05 Feb 2018 16:27:52 +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: Make resize error message more general 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 , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The issue: $ qemu-img resize -f qcow2 foo.qcow2 qemu-img: Expecting one image file name Try 'qemu-img --help' for more information So we gave an image file name, but we omitted the length. qemu-img thinks the last argument is always the size and removes it immediately from argv (by decrementing argc), and tries to verify that it is a valid size only at a later point. So we do not actually know whether that last argument we called "size" is indeed a size or whether the user instead forgot to specify that size but did give a file name. Therefore, the error message should be more general. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1523458 Signed-off-by: Max Reitz Reviewed-by: John Snow Reviewed-by: Eric Blake --- qemu-img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-img.c b/qemu-img.c index 68b375f998..2753b63514 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3468,7 +3468,7 @@ static int img_resize(int argc, char **argv) } } if (optind != argc - 1) { - error_exit("Expecting one image file name"); + error_exit("Expecting image file name and size"); } filename = argv[optind++];