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/03/18 08:10:50 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

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


   ## Summary
   prototype here: https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
   
   ## Impact
   
   ## Testing
   Pass CI
   


-- 
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 #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

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


   


-- 
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 pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#issuecomment-1072431895


   > @xiaoxiang781216 so the changes with `const` didn't work?
   
   Yes, the compiler report: can't modify const argv.


-- 
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 pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#issuecomment-1072407683


   @xiaoxiang781216 so the changes with `const` didn't work?


-- 
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 pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#issuecomment-1072447847


   > > @xiaoxiang781216 so the changes with `const` didn't work?
   > 
   > Yes, the compiler report: can't modify const argv.
   
   Maybe I put `const` in a wrong place. I think it should be `FAR const char **argv = NULL;` and not `FAR char * const *argv = NULL;` as I initially suggested. We need a pointer to a pointer that points a constant data and `FAR char * const *argv = NULL;` means that `argv[0] =` is illegal. My mistake


-- 
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 change in pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#discussion_r829775015



##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;

Review comment:
       ```suggestion
     FAR char * const *argv = NULL;
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));

Review comment:
       ```suggestion
     argv = (FAR char * const *)lib_malloc((nargs + 1) * sizeof(FAR char *));
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)

Review comment:
       ```suggestion
     if (argv == NULL)
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;

Review comment:
       ```suggestion
     argv[0] = arg0;
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;
 
-      va_start(ap, path);
-      for (argc = 0; argc < nargs; argc++)
-        {
-          argv[argc] = va_arg(ap, FAR char *);
-        }
+  /* Collect the arguments into the argv[] array */
 
-      argv[nargs] = NULL;
-      va_end(ap);
+  va_start(ap, arg0);
+  for (argc = 1; argc <= nargs; argc++)
+    {
+      argv[argc] = va_arg(ap, FAR char *);
     }
 
+  va_end(ap);
+
   /* Then let execv() do the real work */
 
   ret = execv(path, (FAR char * const *)argv);

Review comment:
       ```suggestion
     ret = execv(path, argv);
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;

Review comment:
       ```suggestion
     FAR const char *arg = arg0;
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;
 
-      va_start(ap, path);
-      for (argc = 0; argc < nargs; argc++)
-        {
-          argv[argc] = va_arg(ap, FAR char *);
-        }
+  /* Collect the arguments into the argv[] array */
 
-      argv[nargs] = NULL;
-      va_end(ap);
+  va_start(ap, arg0);
+  for (argc = 1; argc <= nargs; argc++)
+    {
+      argv[argc] = va_arg(ap, FAR char *);

Review comment:
       ```suggestion
         argv[argc] = va_arg(ap, FAR const char *);
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);

Review comment:
       ```suggestion
         arg = va_arg(ap, FAR const char *);
   ```




-- 
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 pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#issuecomment-1072455871


   > > > @xiaoxiang781216 so the changes with `const` didn't work?
   > > 
   > > 
   > > Yes, the compiler report: can't modify const argv.
   > 
   > Maybe I put `const` in a wrong place. I think it should be `FAR const char **argv = NULL;` and not `FAR char * const *argv = NULL;`
   
   If so, we require cast in two place: execv and lib_free.
   
   > as I initially suggested. We need a pointer to a pointer that points a constant data and `FAR char * const *argv = NULL;` means that `argv[0] =` is illegal. My mistake
   
   I has tried all possible combination(const char **, char * const *, const char * const), char ** is the best option since it require the less cast.
   


-- 
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 pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#issuecomment-1072431895






-- 
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 change in pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#discussion_r829967000



##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));

Review comment:
       Done.

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)

Review comment:
       Done.

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;

Review comment:
       Done.

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;

Review comment:
       Done.

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;
 
-      va_start(ap, path);
-      for (argc = 0; argc < nargs; argc++)
-        {
-          argv[argc] = va_arg(ap, FAR char *);
-        }
+  /* Collect the arguments into the argv[] array */
 
-      argv[nargs] = NULL;
-      va_end(ap);
+  va_start(ap, arg0);
+  for (argc = 1; argc <= nargs; argc++)
+    {
+      argv[argc] = va_arg(ap, FAR char *);
     }
 
+  va_end(ap);
+
   /* Then let execv() do the real work */
 
   ret = execv(path, (FAR char * const *)argv);

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] xiaoxiang781216 commented on a change in pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#discussion_r829966885



##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;

Review comment:
       Done.

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));

Review comment:
       Done.

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)

Review comment:
       Done.

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;

Review comment:
       Done.

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;

Review comment:
       Done.

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;
 
-      va_start(ap, path);
-      for (argc = 0; argc < nargs; argc++)
-        {
-          argv[argc] = va_arg(ap, FAR char *);
-        }
+  /* Collect the arguments into the argv[] array */
 
-      argv[nargs] = NULL;
-      va_end(ap);
+  va_start(ap, arg0);
+  for (argc = 1; argc <= nargs; argc++)
+    {
+      argv[argc] = va_arg(ap, FAR char *);
     }
 
+  va_end(ap);
+
   /* Then let execv() do the real work */
 
   ret = execv(path, (FAR char * const *)argv);

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] xiaoxiang781216 commented on a change in pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#discussion_r829966885



##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)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 commented on a change in pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#discussion_r829775015



##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;

Review comment:
       ```suggestion
     FAR char * const *argv = NULL;
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));

Review comment:
       ```suggestion
     argv = (FAR char * const *)lib_malloc((nargs + 1) * sizeof(FAR char *));
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)

Review comment:
       ```suggestion
     if (argv == NULL)
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;

Review comment:
       ```suggestion
     argv[0] = arg0;
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;
 
-      va_start(ap, path);
-      for (argc = 0; argc < nargs; argc++)
-        {
-          argv[argc] = va_arg(ap, FAR char *);
-        }
+  /* Collect the arguments into the argv[] array */
 
-      argv[nargs] = NULL;
-      va_end(ap);
+  va_start(ap, arg0);
+  for (argc = 1; argc <= nargs; argc++)
+    {
+      argv[argc] = va_arg(ap, FAR char *);
     }
 
+  va_end(ap);
+
   /* Then let execv() do the real work */
 
   ret = execv(path, (FAR char * const *)argv);

Review comment:
       ```suggestion
     ret = execv(path, argv);
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;

Review comment:
       ```suggestion
     FAR const char *arg = arg0;
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);
     }
-  while (arg);
 
   va_end(ap);
 
   /* Allocate a temporary argv[] array */
 
-  if (nargs > 0)
+  argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
+  if (argv == (FAR char **)NULL)
     {
-      argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *));
-      if (argv == (FAR char **)NULL)
-        {
-          set_errno(ENOMEM);
-          return ERROR;
-        }
+      set_errno(ENOMEM);
+      return ERROR;
+    }
 
-      /* Collect the arguments into the argv[] array */
+  argv[0] = (FAR char *)arg0;
 
-      va_start(ap, path);
-      for (argc = 0; argc < nargs; argc++)
-        {
-          argv[argc] = va_arg(ap, FAR char *);
-        }
+  /* Collect the arguments into the argv[] array */
 
-      argv[nargs] = NULL;
-      va_end(ap);
+  va_start(ap, arg0);
+  for (argc = 1; argc <= nargs; argc++)
+    {
+      argv[argc] = va_arg(ap, FAR char *);

Review comment:
       ```suggestion
         argv[argc] = va_arg(ap, FAR const char *);
   ```

##########
File path: libs/libc/unistd/lib_execl.c
##########
@@ -113,67 +113,61 @@
  *
  ****************************************************************************/
 
-int execl(FAR const char *path, ...)
+int execl(FAR const char *path, FAR const char *arg0, ...)
 {
   FAR char **argv = (FAR char **)NULL;
-  FAR char *arg;
+  FAR char *arg = (FAR char *)arg0;
   size_t nargs;
   va_list ap;
   int argc;
   int ret;
 
   /* Count the number of arguments */
 
-  va_start(ap, path);
+  va_start(ap, arg0);
   nargs = 0;
-  do
+
+  while (arg != NULL)
     {
-      /* Check if the next argument is present */
+      /* Yes.. increment the number of arguments.  Here is a sanity
+       * check to prevent running away with an unterminated argv[] list.
+       * MAX_EXECL_ARGS should be sufficiently large that this never
+       * happens in normal usage.
+       */
 
-      arg = va_arg(ap, FAR char *);
-      if (arg)
+      if (++nargs > MAX_EXECL_ARGS)
         {
-          /* Yes.. increment the number of arguments.  Here is a sanity
-           * check to prevent running away with an unterminated argv[] list.
-           * MAX_EXECL_ARGS should be sufficiently large that this never
-           * happens in normal usage.
-           */
-
-          if (++nargs > MAX_EXECL_ARGS)
-            {
-              set_errno(E2BIG);
-              va_end(ap);
-              return ERROR;
-            }
+          set_errno(E2BIG);
+          va_end(ap);
+          return ERROR;
         }
+
+      arg = va_arg(ap, FAR char *);

Review comment:
       ```suggestion
         arg = va_arg(ap, FAR const char *);
   ```




-- 
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 pull request #5779: Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on pull request #5779:
URL: https://github.com/apache/incubator-nuttx/pull/5779#issuecomment-1072407683






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