You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/04/27 12:53:03 UTC
[incubator-nuttx] 02/02: syslog: Check sc_flush in't NULL before
invocation
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit ac55fab44d514355334e95dc18cbe5d3a3b2e0f6
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Apr 27 12:23:42 2020 +0800
syslog: Check sc_flush in't NULL before invocation
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
drivers/syslog/syslog_channel.c | 12 +-----------
drivers/syslog/syslog_flush.c | 8 ++++++--
2 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/syslog/syslog_channel.c b/drivers/syslog/syslog_channel.c
index c731aae..2a8fd1c 100644
--- a/drivers/syslog/syslog_channel.c
+++ b/drivers/syslog/syslog_channel.c
@@ -72,7 +72,6 @@
#ifdef NEED_LOWPUTC
static int syslog_default_putc(int ch);
#endif
-static int syslog_default_flush(void);
/****************************************************************************
* Public Data
@@ -83,7 +82,6 @@ static const struct syslog_channel_s g_default_channel =
{
ramlog_putc,
ramlog_putc,
- syslog_default_flush
};
#elif defined(CONFIG_SYSLOG_RPMSG)
static const struct syslog_channel_s g_default_channel =
@@ -98,14 +96,12 @@ static const struct syslog_channel_s g_default_channel =
{
up_putc,
up_putc,
- syslog_default_flush
};
#else
static const struct syslog_channel_s g_default_channel =
{
syslog_default_putc,
syslog_default_putc,
- syslog_default_flush
};
#endif
@@ -132,11 +128,6 @@ static int syslog_default_putc(int ch)
}
#endif
-static int syslog_default_flush(void)
-{
- return OK;
-}
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -163,8 +154,7 @@ int syslog_channel(FAR const struct syslog_channel_s *channel)
if (channel != NULL)
{
- DEBUGASSERT(channel->sc_putc != NULL && channel->sc_force != NULL &&
- channel->sc_flush != NULL);
+ DEBUGASSERT(channel->sc_putc != NULL && channel->sc_force != NULL);
g_syslog_channel = channel;
return OK;
diff --git a/drivers/syslog/syslog_flush.c b/drivers/syslog/syslog_flush.c
index 24e6f49..89e874f 100644
--- a/drivers/syslog/syslog_flush.c
+++ b/drivers/syslog/syslog_flush.c
@@ -91,6 +91,10 @@ int syslog_flush(void)
/* Then flush all of the buffered output to the SYSLOG device */
- DEBUGASSERT(g_syslog_channel->sc_flush != NULL);
- return g_syslog_channel->sc_flush();
+ if (g_syslog_channel->sc_flush != NULL)
+ {
+ return g_syslog_channel->sc_flush();
+ }
+
+ return OK;
}