pkarashchenko commented on code in PR #6423:
URL: https://github.com/apache/incubator-nuttx/pull/6423#discussion_r895673222


##########
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;

Review Comment:
   https://pubs.opengroup.org/onlinepubs/9699919799/functions/unsetenv.html says
   ```
   The unsetenv() function shall remove an environment variable from the 
environment of the calling process.
   The name argument points to a string, which is the name of the variable to 
be removed. The named argument
   shall not contain an '=' character. If the named variable does not exist in 
the current environment, the environment
   shall be unchanged and the function is considered to have completed 
successfully.
   
   The unsetenv() function shall update the list of pointers to which environ 
points.
   
   The unsetenv() function need not be thread-safe.
   ```
   I do not see any contradiction. The `=` part is explicitly stated as `The 
named argument shall not contain an '=' character.` and to check this we need 
to check for an empty string as well :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to