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 X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DB2FC11F65 for ; Wed, 30 Jun 2021 17:12:06 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3EB8861408 for ; Wed, 30 Jun 2021 17:12:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3EB8861408 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nic.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80B7D82D22; Wed, 30 Jun 2021 19:12:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="nTNXzIr4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 18DE882E0E; Wed, 30 Jun 2021 19:12:00 +0200 (CEST) Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (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 B8D0382BC7 for ; Wed, 30 Jun 2021 19:11:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 363F21422DA; Wed, 30 Jun 2021 19:11:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1625073116; bh=LLTo4t41Qp2c+b3gcFO6lnGE5vysMKZFSiYseHjplWw=; h=Date:From:To; b=nTNXzIr46Kr+tr0eXNue8IFhsNmMt8bne5/N4qeLjT1D7oEXO7wqU1D4CBiXfJ7ZW rTkDqQW4KYKG4m+LjvWLlmimsLLVS2VSrIGY68bRu4yAqW8FKhFWG10dLWi4cE6zFj zPLdbEkhcIUrh1U5q9Oc2RQUusfbg0dMZrl2veZE= Date: Wed, 30 Jun 2021 19:11:55 +0200 From: Marek =?UTF-8?B?QmVow7pu?= To: Sean Anderson Cc: Wolfgang Denk , Roland Gaudig , u-boot@lists.denx.de, Simon Glass , Roland Gaudig , Alex Nemirovsky , Bin Meng , Heinrich Schuchardt , Patrick Delaunay , Rayagonda Kokatanur , Robert Marko , Stefan Bosch , Weijie Gao Subject: Re: [PATCH 0/3] cmd: setexpr: add fmt format string operation Message-ID: <20210630191155.529f791a@dellmb> In-Reply-To: References: <20210628151750.572837-1-roland.gaudig-oss@weidmueller.com> <83741.1624955845@gemini.denx.de> <19b6eeea-2aad-972b-aeeb-8959aab17d7a@gmail.com> <103545.1624979613@gemini.denx.de> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Wed, 30 Jun 2021 12:17:47 -0400 Sean Anderson wrote: > On 6/29/21 11:13 AM, Wolfgang Denk wrote: > > Dear Sean, > > > > In message <19b6eeea-2aad-972b-aeeb-8959aab17d7a@gmail.com> you > > wrote: > >> > >> The issue with this is twofold. First, there is no portable way to > >> construct a va_list from C code. So the likely way to do this > >> would be to set an arbitrary limit, and then just pass the > >> arguments in. E.g. something like > > > > We already have an argument list: it's what's being passed to the > > "setexpr" command, minus the initial arguments. > > > >> snprintf(buf, sizeof(buf), argv[3], argc >= 4 ? argv[4] : > >> NULL, /* etc */); > > > > Why this test on argc? If it's less than 4, argv[4] should be NULL > > anyway. > > snprintf(buf, sizeof(buf), argv[3], argc >= 4 ? argv[4] : > NULL, argc >= 5 ? argv[5] : NULL, argc >= 6 ? argv[6] : NULL, /* etc > */); This is insane. The argv[]s are strings. What if I use "%08x" as format, and pass "123" as argument?? It would print pointer to the string. Clearly this needs its own implementation... Marek