All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] cmd: setexpr: add fmt format string operation
@ 2021-06-28 15:17 Roland Gaudig
  2021-06-28 15:17 ` [PATCH 1/3] " Roland Gaudig
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Roland Gaudig @ 2021-06-28 15:17 UTC (permalink / raw)
  To: u-boot
  Cc: Simon Glass, Wolfgang Denk, Roland Gaudig, Alex Nemirovsky,
	Bin Meng, Heinrich Schuchardt, Marek Behún,
	Patrick Delaunay, Rayagonda Kokatanur, Robert Marko,
	Sean Anderson, Stefan Bosch, Weijie Gao

From: Roland Gaudig <roland.gaudig@weidmueller.com>


This patch series is the revised version of the previos proposal
[PATCH v1 0/1] cmd: setexpr: add dec operation for converting variable
to decimal

In contrast to version 1, the "dec" operator has been replaced by
a more flexible "fmt" operator to handle format strings.

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:

  => setexpr foo fmt %d 0x100
  => echo $foo
  256
  =>

  => setexpr foo fmt 0x%08x 63
  => echo $foo
  0x00000063
  =>

  => setexpr foo fmt %%%o 8
  => echo $foo
  %10
  =>

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.

Patman insisted adding a maintainer to for the doc/usage/setexpr.rst,
but I am not sure if chose the correct section and person.



Roland Gaudig (3):
  cmd: setexpr: add fmt format string operation
  doc: usage: add description for setexpr command
  test: cmd: setexpr: add tests for format string operations

 MAINTAINERS           |   6 ++
 cmd/setexpr.c         | 102 ++++++++++++++++++++++++++++++++-
 doc/usage/index.rst   |   1 +
 doc/usage/setexpr.rst | 130 ++++++++++++++++++++++++++++++++++++++++++
 test/cmd/setexpr.c    |  33 +++++++++++
 5 files changed, 271 insertions(+), 1 deletion(-)
 create mode 100644 doc/usage/setexpr.rst

-- 
2.25.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-07-05 15:32 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 15:17 [PATCH 0/3] cmd: setexpr: add fmt format string operation Roland Gaudig
2021-06-28 15:17 ` [PATCH 1/3] " Roland Gaudig
2021-06-28 17:39   ` Rasmus Villemoes
2021-06-29  8:44     ` Wolfgang Denk
2021-06-29  8:41   ` Wolfgang Denk
2021-06-28 15:17 ` [PATCH 2/3] doc: usage: add description for setexpr command Roland Gaudig
2021-07-05 15:29   ` Simon Glass
2021-06-28 15:17 ` [PATCH 3/3] test: cmd: setexpr: add tests for format string operations Roland Gaudig
2021-07-05 15:29   ` Simon Glass
2021-06-29  8:37 ` [PATCH 0/3] cmd: setexpr: add fmt format string operation Wolfgang Denk
2021-06-29  9:41   ` Roland Gaudig (OSS)
2021-06-29 10:34     ` Marek Behun
2021-06-29 10:40     ` Wolfgang Denk
2021-06-30  8:30       ` Roland Gaudig (OSS)
2021-06-29 13:57   ` Sean Anderson
2021-06-29 15:13     ` Wolfgang Denk
2021-06-30 16:17       ` Sean Anderson
2021-06-30 17:11         ` Marek Behún
2021-07-02 10:50         ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.