You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/04/17 14:24:57 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request, #6087: libc: Don't duplicate string in chdir and lib_restoredir

xiaoxiang781216 opened a new pull request, #6087:
URL: https://github.com/apache/incubator-nuttx/pull/6087

   ## Summary
   since the new layout doesn't reallocate the unchanged environ variable anymore
   
   ## Impact
   Minor
   
   ## Testing
   ostest in sim:asan
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6087: libc: Don't duplicate string in chdir and lib_restoredir

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6087:
URL: https://github.com/apache/incubator-nuttx/pull/6087#discussion_r851772005


##########
libs/libc/unistd/lib_chdir.c:
##########
@@ -98,42 +73,35 @@ static inline void _trimdir(char *path)
 int chdir(FAR const char *path)
 {
   struct stat buf;
-  char *oldpwd;
-  char *alloc;
-  char *abspath;
-  int errcode;
+  FAR char *oldpwd;
+  FAR char *abspath;
   int ret;
 
-  /* Verify the input parameters */
-
-  if (!path)
-    {
-      errcode = ENOENT;
-      goto errout;
-    }
-
   /* Verify that 'path' refers to a directory */
 
   ret = stat(path, &buf);
   if (ret < 0)
     {
-      errcode = ENOENT;
-      goto errout;
+      return ret;
     }
 
   /* Something exists here... is it a directory? */
 
   if (!S_ISDIR(buf.st_mode))
     {
-      errcode = ENOTDIR;
-      goto errout;
+      set_errno(ENOTDIR);
+      return ERROR;
     }
 
   /* Yes, it is a directory.
    * Remove any trailing '/' characters from the path
    */
 
-  _trimdir(path);
+  abspath = realpath(path, NULL);

Review Comment:
   I've checked `realpath` implementation and it does not set errno in case if memory allocation fails. Do we need to update it 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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6087: libc: Don't duplicate string in chdir and lib_restoredir

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6087:
URL: https://github.com/apache/incubator-nuttx/pull/6087#discussion_r851778615


##########
libs/libc/unistd/lib_chdir.c:
##########
@@ -98,42 +73,35 @@ static inline void _trimdir(char *path)
 int chdir(FAR const char *path)
 {
   struct stat buf;
-  char *oldpwd;
-  char *alloc;
-  char *abspath;
-  int errcode;
+  FAR char *oldpwd;
+  FAR char *abspath;
   int ret;
 
-  /* Verify the input parameters */
-
-  if (!path)
-    {
-      errcode = ENOENT;
-      goto errout;
-    }
-
   /* Verify that 'path' refers to a directory */
 
   ret = stat(path, &buf);
   if (ret < 0)
     {
-      errcode = ENOENT;
-      goto errout;
+      return ret;
     }
 
   /* Something exists here... is it a directory? */
 
   if (!S_ISDIR(buf.st_mode))
     {
-      errcode = ENOTDIR;
-      goto errout;
+      set_errno(ENOTDIR);
+      return ERROR;
     }
 
   /* Yes, it is a directory.
    * Remove any trailing '/' characters from the path
    */
 
-  _trimdir(path);
+  abspath = realpath(path, NULL);

Review Comment:
   Done.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko merged pull request #6087: libc: Don't duplicate string in chdir and lib_restoredir

Posted by GitBox <gi...@apache.org>.
pkarashchenko merged PR #6087:
URL: https://github.com/apache/incubator-nuttx/pull/6087


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org