syslog: optimize init logic for early buffer initialize

N/A

Change-Id: I3295803977fa51e8ed8dedf7f0966b9604f8204d
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2021-07-07 21:58:21 +08:00 committed by Xiang Xiao
parent 4bb48892d0
commit 0c3cb0cb66
1 changed files with 6 additions and 8 deletions

View File

@ -347,7 +347,8 @@ ssize_t syslog_rpmsg_write(FAR struct syslog_channel_s *channel,
void syslog_rpmsg_init_early(FAR void *buffer, size_t size)
{
FAR struct syslog_rpmsg_s *priv = &g_syslog_rpmsg;
char prev, cur;
char prev;
char cur;
size_t i;
size_t j;
@ -364,15 +365,14 @@ void syslog_rpmsg_init_early(FAR void *buffer, size_t size)
if (!isascii(cur))
{
goto out;
memset(priv->buffer, 0, size);
break;
}
if (prev && !cur)
else if (prev && !cur)
{
priv->head = C2B(i) + j;
}
if (!prev && cur)
else if (!prev && cur)
{
priv->tail = i;
}
@ -381,11 +381,9 @@ void syslog_rpmsg_init_early(FAR void *buffer, size_t size)
}
}
out:
if (i != size)
{
priv->head = priv->tail = 0;
memset(priv->buffer, 0, size);
}
}