driver/syslog: reset syslog buffer when syslog buffer include invalid data

When the machine is cold started, the psram area where the syslog
buffer is located contains some random values, so it will cause
loss of valid log.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1 2023-08-25 15:14:39 +08:00 committed by Petro Karashchenko
parent 7115b6adad
commit bfb0095ec7
2 changed files with 5 additions and 3 deletions

View File

@ -257,9 +257,10 @@ static void ramlog_initbuf(void)
{
cur = priv->rl_buffer[i];
if (!isascii(cur))
if (!isprint(cur) && !isspace(cur) && cur != '\0')
{
memset(priv->rl_buffer, 0, priv->rl_bufsize);
is_empty = true;
break;
}
else if (prev && !cur)

View File

@ -418,9 +418,10 @@ void syslog_rpmsg_init_early(FAR void *buffer, size_t size)
{
cur = priv->buffer[i];
if (!isascii(cur))
if (!isprint(cur) && !isspace(cur) && cur != '\0')
{
memset(priv->buffer, 0, size);
memset(buffer, 0, size);
is_empty = true;
break;
}
else if (prev && !cur)