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=-5.8 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 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 944B2C11F66 for ; Tue, 29 Jun 2021 08:37:38 +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 D39C961DC8 for ; Tue, 29 Jun 2021 08:37:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D39C961DC8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de 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 B100583132; Tue, 29 Jun 2021 10:37:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1624955855; bh=4pTpG3q2tQs2K+yOhod+vvAUbYqBZvpCLBLGWNRIz98=; h=To:cc:From:Subject:In-reply-to:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fS+6+TKTTbmA5gaV3E4qHH86Z2x6Wlo1sZ5I1sY/78XTY7vAeXiCrK14gVYWuoZG7 a53DRzD1opu/4anxLfov2kkoAuyDCqMdDA9Q8Bc93kTJ9qlQi8/o2NLWyjSbvZSr8+ DoU2IR4YZnuA89qK0BYIaZvhlkQnjcveEJbv0URj61pbRq5ezTLsHQwtvQ+3vkRcUu b/CcdVNKN2TJqgVNGGeBIVn1kAvc2ueSv3yPWAPqtw6d95vza2OypAnZp3J89KRh3r CZSkxToiwCSjdDeJYDeE/ARKGnkaRKjp9kWpNh2+PNYWnJbsXmPDGGhlo4h0Kvopic YdRZ7epjHeq/w== Received: from janitor.denx.de (unknown [62.91.23.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: noc@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 72E6083120 for ; Tue, 29 Jun 2021 10:37:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1624955854; bh=4pTpG3q2tQs2K+yOhod+vvAUbYqBZvpCLBLGWNRIz98=; h=To:cc:From:Subject:In-reply-to:References:Date:From; b=u+R5zMHFen18BBqO180ldvDW67lkC7a351RqFCRGl1GT58CN/Gb0eyCT8rfCFZwOy n3qKvNHja1cKlCnvWq58wwmlFLxALvZWym1AIGauwaHL+tNz7HTRSr+fSZ7NfWvm2r PP4DCHZSD5T60GkbzmsEaCBN5szDippXXjcG76DMPjLv2aXihap4X3iUks+OAVvies 8jZkF9x2ickB/0h+PbqbjqJ0rt0HSiWLI8wwKyocvPRjwbHqJSPOFAeZ3nu/Ibv/XR vRnQXX78oyksBYgZYIdIuhnayzcUj8AxJ38B0k6u417dBGIUIrN+gZadJGPPPgmQKR TOG8d8IsIKs5A== Received: by janitor.denx.de (Postfix, from userid 108) id 2B032A02B9; Tue, 29 Jun 2021 10:37:34 +0200 (CEST) Received: from gemini.denx.de (gemini.denx.de [10.4.0.2]) by janitor.denx.de (Postfix) with ESMTPS id 7E4EDA0165; Tue, 29 Jun 2021 10:37:25 +0200 (CEST) Received: from gemini.denx.de (localhost [IPv6:::1]) by gemini.denx.de (Postfix) with ESMTP id 3D3CF1E1DD2; Tue, 29 Jun 2021 10:37:25 +0200 (CEST) To: Roland Gaudig cc: u-boot@lists.denx.de, Simon Glass , Roland Gaudig , Alex Nemirovsky , Bin Meng , Heinrich Schuchardt , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Patrick Delaunay , Rayagonda Kokatanur , Robert Marko , Sean Anderson , Stefan Bosch , Weijie Gao From: Wolfgang Denk Subject: Re: [PATCH 0/3] cmd: setexpr: add fmt format string operation MIME-Version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8bit In-reply-to: <20210628151750.572837-1-roland.gaudig-oss@weidmueller.com> References: <20210628151750.572837-1-roland.gaudig-oss@weidmueller.com> Comments: In-reply-to Roland Gaudig message dated "Mon, 28 Jun 2021 15:17:47 -0000." Date: Tue, 29 Jun 2021 10:37:25 +0200 Message-ID: <83741.1624955845@gemini.denx.de> 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 Dear Roland, In message <20210628151750.572837-1-roland.gaudig-oss@weidmueller.com> you wrote: > > > U-Boot uses almost everywhere hexadecimal numbers. But some bootargs > passed to Linux are expecting decimal numbers. As long as the values > are in the range 0 to 9 it is sufficient to just strip 0x from the > number. But for greater values a method for converting numbers to > decimal is needed. > > This patch adds C like format string capabilities to the setexpr > command. Here are some examples: Thanks! > In contrast to the original C format strings the number of parameters > is limited to one. As the get_arg() function returns unsigned long > type, the format string commands are limited to those which are > operating on unsigned long type. These are two pretty unfortunate restrictions. I guess it should not be too hard to avoid both of these. Can you please give it a try? I think it is reasonable to assume (and specify) that, when the "fmt" option is used, _all_ following arguments will be passed (unchanged) to the sprintf() function. This was actually one of my intentions when making this suggestion - to be able to construct any kind of data from pieces; say, for example: => setexpr foo fmt "%0x08x-%s-%d-%s" $a $b $c $d Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Never ascribe to malice that which can adequately be explained by stupidity.