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 2021/02/24 11:15:09 UTC

[GitHub] [incubator-nuttx] davids5 commented on a change in pull request #2904: unistd/getcwd: enhance getcwd when buf is NULL

davids5 commented on a change in pull request #2904:
URL: https://github.com/apache/incubator-nuttx/pull/2904#discussion_r581863926



##########
File path: libs/libc/unistd/lib_getcwd.c
##########
@@ -63,6 +63,12 @@
  *   symbolic links. The 'size' argument is the size in bytes of the
  *   character array pointed to by the 'buf' argument.
  *
+ *   As an extension to the POSIX.1-2001 standard, getcwd() allocates
+ *   the buffer dynamically using malloc if buf is NULL.  In this case,
+ *   the allocated buffer has the length size  unless size is zero, when buf

Review comment:
       missing comma?

##########
File path: libs/libc/unistd/lib_getcwd.c
##########
@@ -92,13 +98,18 @@ FAR char *getcwd(FAR char *buf, size_t size)
   /* Verify input parameters */
 
 #ifdef CONFIG_DEBUG_FEATURES
-  if (!buf || !size)
+  if (buf && !size)

Review comment:
       hmm why does is original code qualified by CONFIG_DEBUG_FEATURES?

##########
File path: libs/libc/unistd/lib_getcwd.c
##########
@@ -92,13 +98,18 @@ FAR char *getcwd(FAR char *buf, size_t size)
   /* Verify input parameters */
 
 #ifdef CONFIG_DEBUG_FEATURES
-  if (!buf || !size)
+  if (buf && !size)
     {
       set_errno(EINVAL);
       return NULL;
     }
 #endif
 
+  if (!size)

Review comment:
       ```suggestion
     if (size == 0)
   ```




----------------------------------------------------------------
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.

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