From: Kever Yang <kever.yang@rock-chips.com>
To: Quentin Schulz <foss+uboot@0leil.net>,
Joe Hershberger <joe.hershberger@ni.com>,
Klaus Goger <klaus.goger@theobroma-systems.com>,
Simon Glass <sjg@chromium.org>,
Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: u-boot@lists.denx.de, Heiko Stuebner <heiko@sntech.de>,
Quentin Schulz <quentin.schulz@theobroma-systems.com>
Subject: Re: [PATCH 1/6] env: allow to copy value from default environment into a buffer
Date: Thu, 9 Nov 2023 11:33:30 +0800 [thread overview]
Message-ID: <ff2d9fe1-e0aa-405e-864d-43134493a597@rock-chips.com> (raw)
In-Reply-To: <20231108-env_default_theobroma-v1-1-cb493bfdeffd@theobroma-systems.com>
On 2023/11/8 22:20, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
>
> env_get_default suffers from a particular issue int that it can only
> return a value truncated to gd->env_buf (32) characters. This may be
> enough for most variables but it isn't for others, so let's allow users
> to provide a preallocated buffer to copy the value into instead,
> allowing for more control, though it'll still be truncated if the value
> size is bigger than the preallocated buffer.
>
> Cc: Quentin Schulz <foss+uboot@0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Thanks,
- Kever
> ---
> env/common.c | 8 ++++++++
> include/env.h | 10 ++++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/env/common.c b/env/common.c
> index eb1a9137953..307003099dd 100644
> --- a/env/common.c
> +++ b/env/common.c
> @@ -254,6 +254,14 @@ char *env_get_default(const char *name)
> return NULL;
> }
>
> +/*
> + * Look up the variable from the default environment and store its value in buf
> + */
> +int env_get_default_into(const char *name, char *buf, unsigned int len)
> +{
> + return env_get_from_linear(default_environment, name, buf, len);
> +}
> +
> void env_set_default(const char *s, int flags)
> {
> if (s) {
> diff --git a/include/env.h b/include/env.h
> index 430c4fa94a4..9a406de3781 100644
> --- a/include/env.h
> +++ b/include/env.h
> @@ -348,6 +348,16 @@ int env_import_redund(const char *buf1, int buf1_read_fail,
> */
> char *env_get_default(const char *name);
>
> +/**
> + * env_get_default_into() - Look up a variable from the default environment and
> + * copy its value in buf.
> + *
> + * @name: Variable to look up
> + * Return: actual length of the variable value excluding the terminating
> + * NULL-byte, or -1 if the variable is not found
> + */
> +int env_get_default_into(const char *name, char *buf, unsigned int len);
> +
> /* [re]set to the default environment */
> void env_set_default(const char *s, int flags);
>
>
next prev parent reply other threads:[~2023-11-09 3:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-08 14:20 [PATCH 0/6] rockchip: puma-rk3399/ringneck-px30: fix check against value in default environment variable Quentin Schulz
2023-11-08 14:20 ` [PATCH 1/6] env: allow to copy value from default environment into a buffer Quentin Schulz
2023-11-09 3:33 ` Kever Yang [this message]
2023-11-09 21:22 ` Tom Rini
2023-11-08 14:20 ` [PATCH 2/6] env: migrate env_get_default to call env_get_default_into Quentin Schulz
2023-11-09 3:33 ` Kever Yang
2023-11-09 21:24 ` Tom Rini
2023-11-08 14:20 ` [PATCH 3/6] rockchip: puma-rk3399: only declare functions in U-Boot proper Quentin Schulz
2023-11-09 3:33 ` Kever Yang
2023-11-09 21:26 ` Tom Rini
2023-11-08 14:20 ` [PATCH 4/6] rockchip: ringneck-px30: " Quentin Schulz
2023-11-09 3:33 ` Kever Yang
2023-11-09 21:26 ` Tom Rini
2023-11-08 14:20 ` [PATCH 5/6] rockchip: puma-rk3399: fix modified boot_targets detection Quentin Schulz
2023-11-09 3:34 ` Kever Yang
2023-11-08 14:20 ` [PATCH 6/6] rockchip: ringneck-px30: " Quentin Schulz
2023-11-09 3:34 ` Kever Yang
2023-11-09 21:28 ` Tom Rini
2023-11-10 10:53 ` Quentin Schulz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ff2d9fe1-e0aa-405e-864d-43134493a597@rock-chips.com \
--to=kever.yang@rock-chips.com \
--cc=foss+uboot@0leil.net \
--cc=heiko@sntech.de \
--cc=joe.hershberger@ni.com \
--cc=klaus.goger@theobroma-systems.com \
--cc=philipp.tomsich@vrull.eu \
--cc=quentin.schulz@theobroma-systems.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox