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 68448C433F5 for ; Tue, 8 Mar 2022 19:22:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5597483923; Tue, 8 Mar 2022 20:22:51 +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="JFryxDC5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3090F83927; Tue, 8 Mar 2022 20:22:49 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::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 A2F7B83921 for ; Tue, 8 Mar 2022 20:22:45 +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 ams.source.kernel.org (Postfix) with ESMTPS id 51C61B81865; Tue, 8 Mar 2022 19:22:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB59FC340EF; Tue, 8 Mar 2022 19:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646767362; bh=2tO618WGvSd7m4XtImIgM1Oy1OpIO7pZ3D6SHniZ/FA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JFryxDC5yR/xz+rY6YJts0tjqqa1wtLkeoS50n5YmbXaHrfXCldgmWIQHky/4kTrY 53wqAuNtXhFUclwQsRm2tFXhsQ6hMi/pgV1VrMZuUw/Ufshf7Yx35oHocAdvc2Z6Ko SB+vCwe2RsPREIMlOyudQqqwYK30ZVd8i9KrROyZR8lUU2m0W1I50uGfIzcOSlwOex h9uJXxQtKUHDH5Yzrjqs5SE6Evte70fY7NWknU6UxeJUcw4iN1eGHaEMSV3+N9Ew5s cBCxqZyPsmesmk93/Hk1kpVk8B6Rqy7VgJ3/0mpwyjXQoy5vYXRZsXOE5hbgfYpWHC 3hNV46aNYnGBQ== Received: by pali.im (Postfix) id B22FF1655; Tue, 8 Mar 2022 20:22:38 +0100 (CET) Date: Tue, 8 Mar 2022 20:22:38 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Tony Dinh Cc: Stefan Roese , Marek =?utf-8?B?QmVow7pu?= , Marcel Ziswiler , U-Boot Mailing List Subject: Re: [PATCH v2 3/3] tools: kwboot: Allow to mix positional arguments with option -b Message-ID: <20220308192238.mqrx2rb5irfvxny6@pali> References: <20220307180309.31275-1-pali@kernel.org> <20220307180309.31275-3-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 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 On Monday 07 March 2022 21:23:29 Tony Dinh wrote: > Hi Pali, > > I've tested this patch series and it's all working fine! Perfect! Stefan, I think that this change should go into 2022.04 as it is fixing regression introduced during 2022.04 development. Could you do more checks/testing of kwboot if everything is also working fine for you? > Thanks, > Tony > > Tested-by: Tony Dinh > > > On Mon, Mar 7, 2022 at 10:04 AM Pali Rohár wrote: > > > > Commit 9e6d71d2b55f ("tools: kwboot: Allow to use -b without image path as > > the last getopt() option") broke usage of kwboot with following arguments: > > > > kwboot -t -B 115200 /dev/ttyUSB0 -b u-boot-spl.kwb > > > > Fix parsing of option -b with optional argument again. > > > > Fixes: 9e6d71d2b55f ("tools: kwboot: Allow to use -b without image path as the last getopt() option") > > Signed-off-by: Pali Rohár > > Reported-by: Tony Dinh > > --- > > Tony and Marcel, could you test this change if all your kwboot use cases > > still work correctly? > > --- > > tools/kwboot.c | 18 ++++++++++++++---- > > 1 file changed, 14 insertions(+), 4 deletions(-) > > > > diff --git a/tools/kwboot.c b/tools/kwboot.c > > index 3b45e19a30aa..9f2dd2de4ef5 100644 > > --- a/tools/kwboot.c > > +++ b/tools/kwboot.c > > @@ -2073,7 +2073,8 @@ main(int argc, char **argv) > > bootmsg = 1; > > if (prev_optind == optind) > > goto usage; > > - if (optind < argc - 1 && argv[optind] && argv[optind][0] != '-') > > + /* Option -b could have optional argument which specify image path */ > > + if (optind < argc && argv[optind] && argv[optind][0] != '-') > > imgpath = argv[optind++]; > > break; > > > > @@ -2128,10 +2129,19 @@ main(int argc, char **argv) > > if (!bootmsg && !term && !debugmsg && !imgpath) > > goto usage; > > > > - ttypath = argv[optind++]; > > - > > - if (optind != argc) > > + /* > > + * If there is no remaining argument but optional imgpath was parsed > > + * then it means that optional imgpath was eaten by getopt parser. > > + * Reassing imgpath to required ttypath argument. > > + */ > > + if (optind == argc && imgpath) { > > + ttypath = imgpath; > > + imgpath = NULL; > > + } else if (optind + 1 == argc) { > > + ttypath = argv[optind]; > > + } else { > > goto usage; > > + } > > > > /* boot and debug message use baudrate 115200 */ > > if (((bootmsg && !imgpath) || debugmsg) && baudrate != 115200) { > > -- > > 2.20.1 > >