History log of /u-boot/cmd/printf.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 175e4b01 21-Aug-2023 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: setexpr: fix printf_str()

If vsnprintf() returns a negative number, (i >= remaining) will
possibly be true:

'i' is of type signed int and 'remaining' is of the unsigned type size_t.
The C language will convert i to an unsigned type before the comparison.

This can result in the wrong error type being indicated.

Checking for negative i should be done first.

Fixes: f4f8d8bb1abc ("cmd: setexpr: add format string handling")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f4f8d8bb 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

cmd: setexpr: add format string handling

Add format string handling operator to the setexpr command.
It allows to use C or Bash like format string expressions to be
evaluated with the result being stored inside the environment variable
name.

setexpr <name> fmt <format> [value]...

The following example

setexpr foo fmt "%d, 0x%x" 0x100 ff

will result in $foo being set to "256, 0xff".

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 6244cda4 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

cmd: printf: add helper functions from busybox

Import the following helper functions from Busybox-1.33.1 which are
required by printf.c:

process_escape_sequence from libbb/process_escape_sequence.c,
skip_whitespace from libbb/skip_whitespace.c,
overlapping_strcpy from libbb/safe_strncpy.c

src-url: https://git.busybox.net/busybox/
commit bcc5b0e6caca6c7602a6a41f "Bump version to 1.33.1"
version: 1.33.1

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>

# 9571f1ac 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

cmd: printf: import busybox-1.33.1 printf.c

Import printf.c from the Busybox project, which provides Bash like
format string handling.

src-url: https://git.busybox.net/busybox/
commit bcc5b0e6caca6c7602a6a41f "Bump version to 1.33.1"
version: 1.33.1

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>

# f4f8d8bb 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

cmd: setexpr: add format string handling

Add format string handling operator to the setexpr command.
It allows to use C or Bash like format string expressions to be
evaluated with the result being stored inside the environment variable
name.

setexpr <name> fmt <format> [value]...

The following example

setexpr foo fmt "%d, 0x%x" 0x100 ff

will result in $foo being set to "256, 0xff".

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 6244cda4 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

cmd: printf: add helper functions from busybox

Import the following helper functions from Busybox-1.33.1 which are
required by printf.c:

process_escape_sequence from libbb/process_escape_sequence.c,
skip_whitespace from libbb/skip_whitespace.c,
overlapping_strcpy from libbb/safe_strncpy.c

src-url: https://git.busybox.net/busybox/
commit bcc5b0e6caca6c7602a6a41f "Bump version to 1.33.1"
version: 1.33.1

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>

# 9571f1ac 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

cmd: printf: import busybox-1.33.1 printf.c

Import printf.c from the Busybox project, which provides Bash like
format string handling.

src-url: https://git.busybox.net/busybox/
commit bcc5b0e6caca6c7602a6a41f "Bump version to 1.33.1"
version: 1.33.1

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>