Skip to content

Commit

Permalink
task_setup() no longer depends on CONFIG_MAX_TASK_ARGS
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-nutt committed Nov 13, 2014
1 parent 5979994 commit ffbd6cf
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions sched/task/task_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* This is an artificial limit to detect error conditions where an argv[]
* list is not properly terminated.
*/

#define MAX_STACK_ARGS 256

/****************************************************************************
* Private Type Declarations
Expand Down Expand Up @@ -481,18 +486,24 @@ static inline int task_stackargsetup(FAR struct task_tcb_s *tcb,
argc = 0;
if (argv)
{
for (; argc <= CONFIG_MAX_TASK_ARGS; argc++)
{
/* A NULL argument terminates the list */

if (!argv[argc])
{
break;
}
/* A NULL argument terminates the list */

while (argv[argc])
{
/* Add the size of this argument (with NUL terminator) */

strtablen += (strlen(argv[argc]) + 1);

/* Increment the number of args. Here is a sanity check to
* prevent running away with an unterminated argv[] list.
* MAX_STACK_ARGS should be sufficiently large that this never
* happens in normal usage.
*/

if (++argc > MAX_STACK_ARGS)
{
return -E2BIG;
}
}
}

Expand Down

0 comments on commit ffbd6cf

Please sign in to comment.