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

Marek Behún kabel at kernel.org
Thu Nov 4 00:23:29 CET 2021


From: Marek Behún <marek.behun at 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 at nic.cz>
---
 env/common.c  | 9 ++++++---
 include/env.h | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

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);
 
-- 
2.32.0



More information about the U-Boot mailing list