From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92283C433EF for ; Mon, 7 Feb 2022 09:13:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2309083B99; Mon, 7 Feb 2022 10:12:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="PSFdoQ6F"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EBA2383C84; Mon, 7 Feb 2022 10:12:56 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 63F4F801EA for ; Mon, 7 Feb 2022 10:12:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4BE326118C; Mon, 7 Feb 2022 09:12:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90C9DC004E1; Mon, 7 Feb 2022 09:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644225171; bh=Ht1Yq9cMrTR8U1tz5RjVnPVpGatTOgJxuFgOaH3tLVk=; h=From:To:Cc:Subject:Date:From; b=PSFdoQ6Ff2KhnTD8D8HRkjQNKRu781uoPLYQYpl70ifyWDhFCRWn3eZAGOCrdEpVf OluHLwRsQM2oTEdfkTn51Eja+9jEERaVcfWm5ZOOvd20UvmAHyFw5/32RdQyK7Uoez c2a+CP8zKPXGUL+ss/Nz9vsRlLwfu6LFJ0RXOH03kl/k6anArWgnajIsvV2NDQWMWe KdAyS6EMf6a0PwA1rrscJr4S7bgdGJMHWygKspQjrXrO+vaFmwspK3FcikcoML5Mlt wiAb36MsTRbWgKEKg7lvCMyQ9FtYezmb5dg66gsAFQj8i/97OAMlAGEBB7K5E3WndW pXNr1oVpbi0bQ== Received: by pali.im (Postfix) id 98E6FC34; Mon, 7 Feb 2022 10:12:49 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: =?UTF-8?q?Marek=20Beh=C3=BAn?= , Stefan Roese , Marcel Ziswiler Cc: u-boot@lists.denx.de Subject: [PATCH] tools: kwboot: Allow to use -b without image path as the last getopt() option Date: Mon, 7 Feb 2022 10:12:24 +0100 Message-Id: <20220207091224.10390-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Currently it is possible to call "kwboot -b -t /dev/ttyUSB0" but not to call "kwboot -b /dev/ttyUSB0". Fix it by not trying to process the last argv[], which is non-getopt() option (tty path) as the image path for -b. Fixes: c513fe47dca2 ("tools: kwboot: Allow to use option -b without image path") Reported-by: Marcel Ziswiler Signed-off-by: Pali Rohár Reviewed-by: Marcel Ziswiler Tested-by: Marcel Ziswiler --- tools/kwboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index 7737188f0d0a..68c0ef1f1b07 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -1770,7 +1770,7 @@ main(int argc, char **argv) bootmsg = kwboot_msg_boot; if (prev_optind == optind) goto usage; - if (argv[optind] && argv[optind][0] != '-') + if (optind < argc - 1 && argv[optind] && argv[optind][0] != '-') imgpath = argv[optind++]; break; -- 2.20.1