aboutsummaryrefslogtreecommitdiff
path: root/include/env.h
diff options
context:
space:
mode:
authorMarek BehĂșn <marek.behun@nic.cz>2021-10-17 17:36:35 +0200
committerSimon Glass <sjg@chromium.org>2021-10-21 12:50:48 -0600
commit3112ce0ce8195880aec5e9373434a85e21c3e1af (patch)
treee7527ddf9d7a128ed80c75a27a58ab5fc2e19a65 /include/env.h
parent6b6e3eeba9f96b5d908a9b46b7bb25e76109a0c7 (diff)
downloadu-boot-3112ce0ce8195880aec5e9373434a85e21c3e1af.zip
u-boot-3112ce0ce8195880aec5e9373434a85e21c3e1af.tar.gz
u-boot-3112ce0ce8195880aec5e9373434a85e21c3e1af.tar.bz2
env: Make return value of env_get_f() behave like sprintf() on success
Currently the env_get_f() function's return value behaves weirdly: it returns the number of bytes written into `buf`, but whether this is excluding the terminating NULL-byte or including it depends on whether there was enough space in `buf`. Change the function to always return the actual length of the value of the environment variable (excluding the terminating NULL-byte) on success. This makes it behave like sprintf(). All users of this function in U-Boot are compatible with this change. Signed-off-by: Marek BehĂșn <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/env.h')
-rw-r--r--include/env.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/include/env.h b/include/env.h
index 220ab97..ee5e30d 100644
--- a/include/env.h
+++ b/include/env.h
@@ -120,10 +120,8 @@ char *from_env(const char *envvar);
* support reading the value (slowly) and some will not.
*
* @varname: Variable to look up
- * @return number of bytes written into @buf, excluding the terminating
- * NULL-byte if there was enough space in @buf, and including the
- * terminating NULL-byte if there wasn't enough space, or -1 if the
- * variable is not found
+ * @return actual length of the variable value excluding the terminating
+ * NULL-byte, or -1 if the variable is not found
*/
int env_get_f(const char *name, char *buf, unsigned int len);