This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 9ed1519cea note: handle tcb is empty, so that it can also record 
before the driver initialization
9ed1519cea is described below

commit 9ed1519cea7f53cafc8e02095fc43ba1602caa2e
Author: yinshengkai <yinsheng...@xiaomi.com>
AuthorDate: Wed Feb 22 19:30:43 2023 +0800

    note: handle tcb is empty, so that it can also record before the driver 
initialization
    
    Signed-off-by: yinshengkai <yinsheng...@xiaomi.com>
---
 drivers/note/note_driver.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c
index d73bf506be..ec35d72653 100644
--- a/drivers/note/note_driver.c
+++ b/drivers/note/note_driver.c
@@ -237,11 +237,24 @@ static void note_common(FAR struct tcb_s *tcb,
 
   note->nc_length   = length;
   note->nc_type     = type;
-  note->nc_priority = tcb->sched_priority;
+
+  if (tcb == NULL)
+    {
+      note->nc_priority = CONFIG_INIT_PRIORITY;
 #ifdef CONFIG_SMP
-  note->nc_cpu      = tcb->cpu;
+      note->nc_cpu = 0;
 #endif
-  sched_note_flatten(note->nc_pid, &tcb->pid, sizeof(tcb->pid));
+      memset(note->nc_pid, 0, sizeof(tcb->pid));
+    }
+  else
+    {
+      note->nc_priority = tcb->sched_priority;
+#ifdef CONFIG_SMP
+      note->nc_cpu      = tcb->cpu;
+#endif
+      sched_note_flatten(note->nc_pid, &tcb->pid, sizeof(tcb->pid));
+    }
+
   sched_note_flatten(note->nc_systime_nsec, &ts.tv_nsec, sizeof(ts.tv_nsec));
   sched_note_flatten(note->nc_systime_sec, &ts.tv_sec, sizeof(ts.tv_sec));
 }

Reply via email to