xiaoxiang781216 commented on a change in pull request #3050: URL: https://github.com/apache/incubator-nuttx/pull/3050#discussion_r593914487
########## File path: drivers/syslog/syslog_putc.c ########## @@ -55,48 +55,57 @@ int syslog_putc(int ch) { - DEBUGASSERT(g_syslog_channel != NULL); + int i; - /* Is this an attempt to do SYSLOG output from an interrupt handler? */ - - if (up_interrupt_context() || sched_idletask()) + for (i = 0; i < CONFIG_SYSLOG_MAX_CHANNELS; i++) { -#if defined(CONFIG_SYSLOG_INTBUFFER) - if (up_interrupt_context()) - { - /* Buffer the character in the interrupt buffer. - * The interrupt buffer will be flushed before the next normal, - * non-interrupt SYSLOG output. - */ + if (g_syslog_channel[i] == NULL) + break; Review comment: ditto ########## File path: drivers/syslog/syslog_force.c ########## @@ -55,18 +55,27 @@ int syslog_force(int ch) { - DEBUGASSERT(g_syslog_channel != NULL && - g_syslog_channel->sc_force != NULL); + int i; + + for (i = 0; i < CONFIG_SYSLOG_MAX_CHANNELS; i++) + { + if (g_syslog_channel[i] == NULL) + break; Review comment: need add {} around break ########## File path: drivers/syslog/syslog_write.c ########## @@ -56,37 +56,44 @@ static ssize_t syslog_default_write(FAR const char *buffer, size_t buflen) { - size_t nwritten; + int i; + size_t nwritten = 0; - if (up_interrupt_context() || sched_idletask()) + for (i = 0; i < CONFIG_SYSLOG_MAX_CHANNELS; i++) { - for (nwritten = 0; nwritten < buflen; nwritten++) + if (g_syslog_channel[i] == NULL) + break; Review comment: ditto ########## File path: drivers/syslog/syslog_channel.c ########## @@ -92,7 +92,11 @@ static const struct syslog_channel_s g_default_channel = /* This is the current syslog channel in use */ -FAR const struct syslog_channel_s *g_syslog_channel = &g_default_channel; +FAR const struct syslog_channel_s + *g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] = + { + &g_default_channel + }; Review comment: remove the extra space at the begin ########## File path: drivers/syslog/syslog_write.c ########## @@ -116,13 +123,21 @@ static ssize_t syslog_default_write(FAR const char *buffer, size_t buflen) ssize_t syslog_write(FAR const char *buffer, size_t buflen) { #ifdef CONFIG_SYSLOG_INTBUFFER + int i; + if (!up_interrupt_context() && !sched_idletask()) { /* Flush any characters that may have been added to the interrupt * buffer. */ - syslog_flush_intbuffer(g_syslog_channel, false); + for (i = 0; i < CONFIG_SYSLOG_MAX_CHANNELS; i++) + { + if (g_syslog_channel[i] == NULL) + break; Review comment: ditto ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org