sched/env: Fix the return value of unsetenv()
If the environment variable does not exist, the function succeeds, as defined by POSIX.
This commit is contained in:
parent
cf91b403c9
commit
1b32fc1642
1 changed files with 4 additions and 5 deletions
|
@ -61,23 +61,22 @@ int unsetenv(FAR const char *name)
|
||||||
{
|
{
|
||||||
FAR struct tcb_s *rtcb = this_task();
|
FAR struct tcb_s *rtcb = this_task();
|
||||||
FAR struct task_group_s *group = rtcb->group;
|
FAR struct task_group_s *group = rtcb->group;
|
||||||
int ret = OK;
|
int idx;
|
||||||
|
|
||||||
DEBUGASSERT(name && group);
|
DEBUGASSERT(name && group);
|
||||||
|
|
||||||
/* Check if the variable exists */
|
/* Check if the variable exists */
|
||||||
|
|
||||||
sched_lock();
|
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. */
|
/* It does! Remove the name=value pair from the environment. */
|
||||||
|
|
||||||
env_removevar(group, ret);
|
env_removevar(group, idx);
|
||||||
ret = OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
return ret;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_DISABLE_ENVIRON */
|
#endif /* CONFIG_DISABLE_ENVIRON */
|
||||||
|
|
Loading…
Reference in a new issue