diff mbox series

[v2,09/12] env: Change return behaviour of env_set_default_vars()

Message ID 20211103232332.2737-10-kabel@kernel.org
State Changes Requested
Delegated to: Simon Glass
Headers show
Series Board specific runtime determined default env | expand

Commit Message

Marek Behún Nov. 3, 2021, 11:23 p.m. UTC
From: Marek Behún <marek.behun@nic.cz>

The env_set_default_vars() function does not document return value and
behaves differently from other env_* functions.

Change the return value to return 0 on success and -ve on error.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 env/common.c  | 9 ++++++---
 include/env.h | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Simon Glass Nov. 5, 2021, 2:02 a.m. UTC | #1
On Wed, 3 Nov 2021 at 17:23, Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> The env_set_default_vars() function does not document return value and
> behaves differently from other env_* functions.
>
> Change the return value to return 0 on success and -ve on error.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  env/common.c  | 9 ++++++---
>  include/env.h | 1 +
>  2 files changed, 7 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/env/common.c b/env/common.c
index 208e2adaa0..cefe58561b 100644
--- a/env/common.c
+++ b/env/common.c
@@ -283,9 +283,12 @@  int env_set_default_vars(int nvars, char * const vars[], int flags)
 	 * (and use \0 as a separator)
 	 */
 	flags |= H_NOCLEAR | H_DEFAULT;
-	return himport_r(&env_htab, default_environment,
-				sizeof(default_environment), '\0',
-				flags, 0, nvars, vars);
+	if (!himport_r(&env_htab, default_environment,
+		       sizeof(default_environment), '\0', flags, 0, nvars,
+		       vars))
+		return -errno;
+
+	return 0;
 }
 
 /*
diff --git a/include/env.h b/include/env.h
index ee5e30d036..d0b95a498d 100644
--- a/include/env.h
+++ b/include/env.h
@@ -245,6 +245,7 @@  void env_fix_drivers(void);
  * @nvars: Number of variables to set/reset
  * @vars: List of variables to set/reset
  * @flags: Flags controlling matching (H_... - see search.h)
+ * @return 0 if OK, -ve on error
  */
 int env_set_default_vars(int nvars, char *const vars[], int flags);