patacongo commented on a change in pull request #2518:
URL: https://github.com/apache/incubator-nuttx/pull/2518#discussion_r540950040



##########
File path: sched/task/task_getpid.c
##########
@@ -95,11 +95,17 @@ pid_t getpid(void)
 
       if (rtcb->task_state == TSTATE_TASK_RUNNING)
         {
+#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
+          /* Yes.. Return the task ID from the main TCB */

Review comment:
       > 
   > 
   > Because the definition use the same 
condition(https://github.com/apache/incubator-nuttx/blob/master/include/nuttx/sched.h#L475):
   > 
   > ```
   > struct task_group_s
   > {
   > #if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_SCHED_HAVE_PARENT)
   >   pid_t tg_task;                    /* The ID of the task within the group 
     */
   > #endif
   > ```
   
   That is my point.  The definition should change. tg_task should be 
initialized and available in all configurations.  Otherwise, getpid() will 
return a bad value in some configurations.
   




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to