diff mbox series

[3/5] env: make env_set_default_vars() return void

Message ID 20201110202603.20944-4-rasmus.villemoes@prevas.dk
State Superseded
Delegated to: Tom Rini
Headers show
Series allow default environment to be amended from dtb | expand

Commit Message

Rasmus Villemoes Nov. 10, 2020, 8:26 p.m. UTC
Unlike most other functions declared in env.h, the return value of
this one also isn't documented. It only has a single caller, which
ignores the return value. And the companion, env_set_default(),
already has void as return type.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 env/common.c  | 4 ++--
 include/env.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Wolfgang Denk Nov. 12, 2020, 7:51 p.m. UTC | #1
Dear Rasmus,

In message <20201110202603.20944-4-rasmus.villemoes@prevas.dk> you wrote:
> Unlike most other functions declared in env.h, the return value of
> this one also isn't documented. It only has a single caller, which
> ignores the return value. And the companion, env_set_default(),
> already has void as return type.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>

Naked-by: Wolfgang Denk <wd@denx.de>

This is not a good idea.  himport_r() can run into problems, and
then it returns an error code. Ignoring errors is never correct.

Instead, the caller should be fixed to add proper error handling.

env_set_default() at least prints a proper error message.

Best regards,

Wolfgang Denk
diff mbox series

Patch

diff --git a/env/common.c b/env/common.c
index 6c32a9b479..7363da849b 100644
--- a/env/common.c
+++ b/env/common.c
@@ -94,14 +94,14 @@  void env_set_default(const char *s, int flags)
 
 
 /* [re]set individual variables to their value in the default environment */
-int env_set_default_vars(int nvars, char * const vars[], int flags)
+void env_set_default_vars(int nvars, char * const vars[], int flags)
 {
 	/*
 	 * Special use-case: import from default environment
 	 * (and use \0 as a separator)
 	 */
 	flags |= H_NOCLEAR | H_DEFAULT;
-	return himport_r(&env_htab, (const char *)default_environment,
+	himport_r(&env_htab, (const char *)default_environment,
 				sizeof(default_environment), '\0',
 				flags, 0, nvars, vars);
 }
diff --git a/include/env.h b/include/env.h
index c15339a93f..5bff6c4d72 100644
--- a/include/env.h
+++ b/include/env.h
@@ -256,7 +256,7 @@  void env_fix_drivers(void);
  * @vars: List of variables to set/reset
  * @flags: Flags controlling matching (H_... - see search.h)
  */
-int env_set_default_vars(int nvars, char *const vars[], int flags);
+void env_set_default_vars(int nvars, char *const vars[], int flags);
 
 /**
  * env_load() - Load the environment from storage