xiaoxiang781216 commented on code in PR #7841:
URL: https://github.com/apache/nuttx/pull/7841#discussion_r1050578046


##########
drivers/note/note_driver.c:
##########
@@ -91,6 +139,13 @@ static unsigned int 
g_note_disabled_irq_nest[CONFIG_SMP_NCPUS];
 #endif
 #endif
 
+FAR struct note_driver_s *g_note_drivers[CONFIG_DRIVER_NOTE_MAX + 1] =

Review Comment:
   add static



##########
drivers/note/note_driver.c:
##########
@@ -811,38 +1095,53 @@ void sched_note_string(uintptr_t ip, FAR const char *buf)
   FAR struct note_string_s *note;
   uint8_t data[255];
   unsigned int length;
+  FAR struct note_driver_s **driver;
+  bool formatted = false;
   FAR struct tcb_s *tcb = this_task();
 
   if (!note_isenabled_dump())
     {
       return;
     }
 
-  note = (FAR struct note_string_s *)data;
-  length = SIZEOF_NOTE_STRING(strlen(buf));
-  if (length > sizeof(data))
+  for (driver = g_note_drivers; *driver; driver++)
     {
-      length = sizeof(data);
-    }
+      if (note_string(*driver, ip, buf))
+        {
+          continue;
+        }
 
-  /* Format the note */
+      note = (FAR struct note_string_s *)data;

Review Comment:
   move after line 1125



##########
drivers/note/note_driver.c:
##########
@@ -811,38 +1095,53 @@ void sched_note_string(uintptr_t ip, FAR const char *buf)
   FAR struct note_string_s *note;
   uint8_t data[255];
   unsigned int length;
+  FAR struct note_driver_s **driver;
+  bool formatted = false;
   FAR struct tcb_s *tcb = this_task();
 
   if (!note_isenabled_dump())
     {
       return;
     }
 
-  note = (FAR struct note_string_s *)data;
-  length = SIZEOF_NOTE_STRING(strlen(buf));
-  if (length > sizeof(data))
+  for (driver = g_note_drivers; *driver; driver++)
     {
-      length = sizeof(data);
-    }
+      if (note_string(*driver, ip, buf))
+        {
+          continue;
+        }
 
-  /* Format the note */
+      note = (FAR struct note_string_s *)data;
+      length = SIZEOF_NOTE_STRING(strlen(buf));
+      if (length > sizeof(data))
+        {
+          length = sizeof(data);
+        }
 
-  note_common(tcb, &note->nst_cmn, length,
-              NOTE_DUMP_STRING);
+      /* Format the note */
 
-  sched_note_flatten(note->nst_ip, &ip, sizeof(uintptr_t));
-  memcpy(note->nst_data, buf, length - sizeof(struct note_string_s));
-  data[length - 1] = '\0';
+      if (!formatted)
+        {
+          formatted = true;
+          note_common(tcb, &note->nst_cmn, length, NOTE_DUMP_STRING);
 
-  /* Add the note to circular buffer */
+          sched_note_flatten(note->nst_ip, &ip, sizeof(uintptr_t));
+          memcpy(note->nst_data, buf, length - sizeof(struct note_string_s));
+          data[length - 1] = '\0';
+        }
 
-  sched_note_add(note, length);
+      /* Add the note to circular buffer */
+
+      note_add(*driver, note, length);
+    }
 }
 
-void sched_note_dump(uintptr_t ip, uint8_t event,
-                     FAR const void *buf, size_t len)
+void sched_note_dump(uintptr_t ip, uint8_t event, FAR const void *buf,

Review Comment:
   why change



-- 
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-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to