[PATCH 1/4] globalvar: add set_single function

Sascha Hauer s.hauer at pengutronix.de
Mon Sep 14 05:13:02 EDT 2020


Hi Rouven,

On Sat, Sep 12, 2020 at 09:12:37AM +0200, Rouven Czerwinski wrote:
> Instead of overwriting the whole hierarchy beneath a globalvar, the
> set_single function only sets the specific globalvar.
> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski at pengutronix.de>
> ---
>  common/globalvar.c  | 11 +++++++++++
>  include/globalvar.h |  1 +
>  2 files changed, 12 insertions(+)
> 
> diff --git a/common/globalvar.c b/common/globalvar.c
> index 98a028a68a..848a7d6832 100644
> --- a/common/globalvar.c
> +++ b/common/globalvar.c
> @@ -399,6 +399,17 @@ void globalvar_set_match(const char *match, const char *val)
>  	}
>  }
>  
> +void globalvar_set_single(const char *match, const char *val)
> +{
> +	struct param_d *param;
> +
> +	list_for_each_entry(param, &global_device.parameters, list) {
> +		if (!strncmp(match, param->name, strlen(match))
> +		    && strlen(match) == strlen(param->name))

What's the difference between this construct and plain strcmp()?

> +			dev_set_param(&global_device, param->name, val);

And then, why not call dev_set_param directly with "match" as argument?

I would rename "match" to "name" as it describes a single variable name.
Also "globalvar_set" is IMO enough as a function name.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list