]> git.baikalelectronics.ru Git - uboot.git/commit
env: Make return value of env_get_f() behave like sprintf() on success
authorMarek Behún <marek.behun@nic.cz>
Sun, 17 Oct 2021 15:36:35 +0000 (17:36 +0200)
committerSimon Glass <sjg@chromium.org>
Thu, 21 Oct 2021 18:50:48 +0000 (12:50 -0600)
commitb5f07a800b55eb76678e2c83352c7a2e57c5ecb8
treee7527ddf9d7a128ed80c75a27a58ab5fc2e19a65
parentafae4233e629ea2c532336dab1b6ab6826153890
env: Make return value of env_get_f() behave like sprintf() on success

Currently the env_get_f() function's return value behaves weirdly: it
returns the number of bytes written into `buf`, but whether this is
excluding the terminating NULL-byte or including it depends on whether
there was enough space in `buf`.

Change the function to always return the actual length of the value of
the environment variable (excluding the terminating NULL-byte) on
success. This makes it behave like sprintf().

All users of this function in U-Boot are compatible with this change.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/nvedit.c
include/env.h