From 0c3cb0cb66924c5168911dce7f9807105e04e24f Mon Sep 17 00:00:00 2001 From: Jiuzhu Dong Date: Wed, 7 Jul 2021 21:58:21 +0800 Subject: [PATCH] syslog: optimize init logic for early buffer initialize N/A Change-Id: I3295803977fa51e8ed8dedf7f0966b9604f8204d Signed-off-by: Jiuzhu Dong --- drivers/syslog/syslog_rpmsg.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/syslog/syslog_rpmsg.c b/drivers/syslog/syslog_rpmsg.c index 168ea1bbed..e39e8dbe3f 100644 --- a/drivers/syslog/syslog_rpmsg.c +++ b/drivers/syslog/syslog_rpmsg.c @@ -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); } }