[PATCH v2 10/13] env: Use better name for variable in env_get_f()

Simon Glass sjg at chromium.org
Fri Oct 15 02:40:08 CEST 2021


Hi Marek,

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>
>
> The `nxt` variable actually points to the terminating null-byte of the
> current env var, and the next env var is at `nxt + 1`, not `nxt`. So a
> better name for this variable is `end`.
>
> Signed-off-by: Marek Behún <marek.behun at nic.cz>
> ---
>  cmd/nvedit.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> index 6eabd51209..08288fad10 100644
> --- a/cmd/nvedit.c
> +++ b/cmd/nvedit.c
> @@ -724,7 +724,7 @@ static const char *matching_name_get_value(const char *p, const char *name)
>   */
>  int env_get_f(const char *name, char *buf, unsigned len)
>  {
> -       const char *env, *p, *nxt;
> +       const char *env, *p, *end;
>
>         if (name == NULL || *name == '\0')
>                 return -1;
> @@ -734,12 +734,12 @@ int env_get_f(const char *name, char *buf, unsigned len)
>         else
>                 env = (const char *)gd->env_addr;
>
> -       for (p = env; *p != '\0'; p = nxt + 1) {
> +       for (p = env; *p != '\0'; p = end + 1) {
>                 const char *value;
>                 int n;
>
> -               for (nxt = p; *nxt != '\0'; ++nxt)
> -                       if (nxt - env >= CONFIG_ENV_SIZE)
> +               for (end = p; *end != '\0'; ++end)
> +                       if (end - env >= CONFIG_ENV_SIZE)
>                                 return -1;
>
>                 value = matching_name_get_value(p, name);
> --
> 2.32.0
>


More information about the U-Boot mailing list