[PATCH v2 11/13] env: Make return value of env_get_f() behave like sprintf() on success
Simon Glass
sjg at chromium.org
Thu Oct 14 17:11:18 CEST 2021
On Wed, 13 Oct 2021 at 09:46, Marek Behún <kabel at kernel.org> wrote:
>
> From: Marek Behún <marek.behun at nic.cz>
>
> 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 at nic.cz>
> ---
> cmd/nvedit.c | 8 +++++---
> include/env.h | 6 ++----
> 2 files changed, 7 insertions(+), 7 deletions(-)
Reviewed-by: Simon Glass <sjg at chromium.org>
More information about the U-Boot
mailing list