syslog: Check sc_flush in't NULL before invocation
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
67b10fea09
commit
ac55fab44d
@ -72,7 +72,6 @@
|
|||||||
#ifdef NEED_LOWPUTC
|
#ifdef NEED_LOWPUTC
|
||||||
static int syslog_default_putc(int ch);
|
static int syslog_default_putc(int ch);
|
||||||
#endif
|
#endif
|
||||||
static int syslog_default_flush(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
@ -83,7 +82,6 @@ static const struct syslog_channel_s g_default_channel =
|
|||||||
{
|
{
|
||||||
ramlog_putc,
|
ramlog_putc,
|
||||||
ramlog_putc,
|
ramlog_putc,
|
||||||
syslog_default_flush
|
|
||||||
};
|
};
|
||||||
#elif defined(CONFIG_SYSLOG_RPMSG)
|
#elif defined(CONFIG_SYSLOG_RPMSG)
|
||||||
static const struct syslog_channel_s g_default_channel =
|
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,
|
||||||
up_putc,
|
up_putc,
|
||||||
syslog_default_flush
|
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
static const struct syslog_channel_s g_default_channel =
|
static const struct syslog_channel_s g_default_channel =
|
||||||
{
|
{
|
||||||
syslog_default_putc,
|
syslog_default_putc,
|
||||||
syslog_default_putc,
|
syslog_default_putc,
|
||||||
syslog_default_flush
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -132,11 +128,6 @@ static int syslog_default_putc(int ch)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int syslog_default_flush(void)
|
|
||||||
{
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -163,8 +154,7 @@ int syslog_channel(FAR const struct syslog_channel_s *channel)
|
|||||||
|
|
||||||
if (channel != NULL)
|
if (channel != NULL)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(channel->sc_putc != NULL && channel->sc_force != NULL &&
|
DEBUGASSERT(channel->sc_putc != NULL && channel->sc_force != NULL);
|
||||||
channel->sc_flush != NULL);
|
|
||||||
|
|
||||||
g_syslog_channel = channel;
|
g_syslog_channel = channel;
|
||||||
return OK;
|
return OK;
|
||||||
|
@ -91,6 +91,10 @@ int syslog_flush(void)
|
|||||||
|
|
||||||
/* Then flush all of the buffered output to the SYSLOG device */
|
/* Then flush all of the buffered output to the SYSLOG device */
|
||||||
|
|
||||||
DEBUGASSERT(g_syslog_channel->sc_flush != NULL);
|
if (g_syslog_channel->sc_flush != NULL)
|
||||||
return g_syslog_channel->sc_flush();
|
{
|
||||||
|
return g_syslog_channel->sc_flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user