All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 3/3] env: Provide programmatic equivalent to 'setenv -f'
Date: Thu, 30 Jan 2020 21:40:24 +0100	[thread overview]
Message-ID: <20200130204024.646A424065D@gemini.denx.de> (raw)
In-Reply-To: <0102016e8e614227-a8c99a21-6a99-4611-b510-a723bc021b52-000000@eu-west-1.amazonses.com>

Dear James,

In message <0102016e8e614227-a8c99a21-6a99-4611-b510-a723bc021b52-000000@eu-west-1.amazonses.com> you wrote:
> Add env_force_set() to provide an equivalent to 'setenv -f' that can be
> used programmatically.

env_set_forced() ?

> -int env_set(const char *varname, const char *varvalue)
> +static int do_programmatic_env_set(const char *varname, const char *varvalue,
> +				   int env_flag)
>  {
>  	/* before import into hashtable */
>  	if (!(gd->flags & GD_FLG_ENV_READY))
>  		return 1;
>  
>  	if (!varvalue || varvalue[0] == '\0')
> -		return do_env_remove(varname, H_PROGRAMMATIC);
> +		return do_env_remove(varname, H_PROGRAMMATIC | env_flag);
> +
> +	return do_env_update(varname, varvalue, H_PROGRAMMATIC | env_flag);
> +}
> +
> +int env_set(const char *varname, const char *varvalue)
> +{
> +	return do_programmatic_env_set(varname, varvalue, 0);
> +}
>  
> -	return do_env_update(varname, varvalue, H_PROGRAMMATIC);
> +int env_force_set(const char *varname, const char *varvalue)
> +{
> +	return do_programmatic_env_set(varname, varvalue, H_FORCE);
>  }

You add another level of function nesting and add more lines of code
than if just coppying the 3 C statements.

If possible, please also try not to come up with so awfully long
names like do_programmatic_env_set() - hey, this is allprogrammatic
what we're coding here, isn;t it?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The goal of science is to build better mousetraps. The goal of nature
is to build better mice.

      parent reply	other threads:[~2020-01-30 20:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191121143240.122610-1-james.byrne@origamienergy.com>
2019-11-21 14:32 ` [U-Boot] [PATCH v2 2/3] env: Tidy up some of the env code James Byrne
2019-11-27  5:52   ` AKASHI Takahiro
2019-11-27  9:39     ` James Byrne
2019-11-27  9:59       ` Simon Goldschmidt
2020-01-30 20:33       ` Wolfgang Denk
2020-01-30 20:51         ` Simon Goldschmidt
2020-01-31 13:47           ` Wolfgang Denk
2019-11-21 14:32 ` [U-Boot] [PATCH v2 3/3] env: Provide programmatic equivalent to 'setenv -f' James Byrne
2019-12-28  2:26   ` Simon Glass
2020-01-30 20:40   ` Wolfgang Denk [this message]

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=20200130204024.646A424065D@gemini.denx.de \
    --to=wd@denx.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.