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

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

commit ca989b5101d60ae78def8f869b85f36fb79d7b6b
Author: dulibo1 <duli...@xiaomi.com>
AuthorDate: Wed Mar 20 14:31:57 2024 +0800

    noteram:overflow may discard all the trace message
    
    noteram_add may cause head = tail when remain == NOTE_ALIGN(notelen)
    log:
    nsh_main-14  [0]   2.132127493: tracing_mark_write: B|14|trace dump -c
    
    nsh_main-14  [0]   2.143322780: tracing_mark_write: E|14|trace dump -c
    
    nsh_main-14  [0]   2.513023895: tracing_mark_write: B|14|trace dump -c
    
    nsh_main-14  [0]   2.524060048: tracing_mark_write: E|14|trace dump -c
    
    nsh_main-14  [0]   2.897055341: tracing_mark_write: B|14|trace dump -c
    
    ap> trace dump -c
    nsh_main-14  [0]   3.270037241: tracing_mark_write: B|14|trace dump -c
    
    ap> trace dump -c
    
    Signed-off-by: dulibo1 <duli...@xiaomi.com>
---
 drivers/note/noteram_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c
index 22aa6ac6d3..f6db8ee064 100644
--- a/drivers/note/noteram_driver.c
+++ b/drivers/note/noteram_driver.c
@@ -567,7 +567,7 @@ static void noteram_add(FAR struct note_driver_s *driver,
   DEBUGASSERT(note != NULL && notelen < drv->ni_bufsize);
   remain = drv->ni_bufsize - noteram_length(drv);
 
-  if (remain < notelen)
+  if (remain <= NOTE_ALIGN(notelen))
     {
       if (drv->ni_overwrite == NOTERAM_MODE_OVERWRITE_DISABLE)
         {
@@ -586,7 +586,7 @@ static void noteram_add(FAR struct note_driver_s *driver,
           noteram_remove(drv);
           remain = drv->ni_bufsize - noteram_length(drv);
         }
-      while (remain < notelen);
+      while (remain <= NOTE_ALIGN(notelen));
     }
 
   head = drv->ni_head;

Reply via email to