os/kernel/task_prctl.c : Fix to check passed pid only when get/set_BYPID
Passed argument pid is used only when PR_GET/SET_NAME_BYPID.
For PR_GET/SET_NAME case, pid can be ignored, debug message can makes confusion if sched_gettcb() fails.
@@ -132,16 +132,13 @@ int prctl(int option, ...)
/* Get the prctl arguments */
FAR char *name = va_arg(ap, FAR char *);
- int pid = va_arg(ap, int);
FAR struct tcb_s *tcb;
if (option == PR_SET_NAME_BYPID || option == PR_GET_NAME_BYPID) {
+ int pid = va_arg(ap, int);
+
/* Get the TCB associated with the PID */
tcb = sched_gettcb((pid_t)pid);
- } else {
- /* Get the current running TCB */
- tcb = this_task();
- }
/* An invalid pid will be indicated by a NULL TCB returned from
* sched_gettcb()
@@ -152,6 +149,10 @@ int prctl(int option, ...)
err = ESRCH;
goto errout;
}
+ } else {
+ /* Get the current running TCB */
+ tcb = this_task();
+ }
/* A pointer to the task name storage must also be provided */
