[PATCH v2 09/13] env: Use string pointer instead of indexes in env_get_f()

Marek Behún kabel at kernel.org
Fri Oct 15 15:20:42 CEST 2021


Hi Simon,

On Thu, 14 Oct 2021 18:40:02 -0600
Simon Glass <sjg at chromium.org> wrote:

> > -static int env_match(const char *env, const char *s1, int i2)
> > +static const char *matching_name_get_value(const char *p, const
> > char *name)  
> 
> OK so this is the function where I would like a nice comment, please.

Now that I look at it, I notice that it also works for cases when name
is "abc=def" (it matches just "abc"). This was the purpose of
env_match() before, but env_get_f() does not use it that way, and this
functionality can now be removed.

This would simplify the code to something like
  len = strlen(name);
  if (p[len] == '=' && !strncmp(p, name, len))
    return &p[len + 1];
  return NULL;

And this is simple enough to be inlined into env_get_f().

I will refactor this and send v3.

Marek


More information about the U-Boot mailing list