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 <dulibo1@xiaomi.com>
This commit is contained in:
dulibo1 2024-03-20 14:31:57 +08:00 committed by Xiang Xiao
parent e5e4e3030e
commit 98482d429b
1 changed files with 2 additions and 2 deletions

View File

@ -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;