This is an automated email from the ASF dual-hosted git repository. pkarashchenko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 1b32fc1642a163b6860c7b2eb9c5a8f60a3b9963 Author: Ville Juven <[email protected]> AuthorDate: Mon Jun 13 15:00:44 2022 +0300 sched/env: Fix the return value of unsetenv() If the environment variable does not exist, the function succeeds, as defined by POSIX. --- sched/environ/env_unsetenv.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sched/environ/env_unsetenv.c b/sched/environ/env_unsetenv.c index 6d227d0d37..be491474c4 100644 --- a/sched/environ/env_unsetenv.c +++ b/sched/environ/env_unsetenv.c @@ -61,23 +61,22 @@ int unsetenv(FAR const char *name) { FAR struct tcb_s *rtcb = this_task(); FAR struct task_group_s *group = rtcb->group; - int ret = OK; + int idx; DEBUGASSERT(name && group); /* Check if the variable exists */ sched_lock(); - if (group && (ret = env_findvar(group, name)) >= 0) + if (group && (idx = env_findvar(group, name)) >= 0) { /* It does! Remove the name=value pair from the environment. */ - env_removevar(group, ret); - ret = OK; + env_removevar(group, idx); } sched_unlock(); - return ret; + return OK; } #endif /* CONFIG_DISABLE_ENVIRON */
