fjpanag commented on a change in pull request #3050:
URL: https://github.com/apache/incubator-nuttx/pull/3050#discussion_r599576677



##########
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;
+
+      /* Is this an attempt to do SYSLOG output from an interrupt handler? */
 
-          return syslog_add_intbuffer(ch);
+      if (up_interrupt_context() || sched_idletask())
+        {
+#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.
+               */
+
+              return syslog_add_intbuffer(ch);
+            }
+          else
+#endif
+            {
+              /* Force the character to the SYSLOG device immediately
+               * (if possible).
+               * This means that the interrupt data may not be in
+               * synchronization with output data that may have been
+               * buffered by sc_putc().
+               */
+
+              DEBUGASSERT(g_syslog_channel[i]->sc_force != NULL);
+
+              g_syslog_channel[i]->sc_force(ch);
+            }
         }
       else
-#endif
         {
-          /* Force the character to the SYSLOG device immediately
-           * (if possible).
-           * This means that the interrupt data may not be in synchronization
-           * with output data that may have been buffered by sc_putc().
-           */
-
-          DEBUGASSERT(g_syslog_channel->sc_force != NULL);
-
-          return g_syslog_channel->sc_force(ch);
-        }
-    }
-  else
-    {
-      DEBUGASSERT(g_syslog_channel->sc_putc != NULL);
+          DEBUGASSERT(g_syslog_channel[i]->sc_putc != NULL);
 
 #ifdef CONFIG_SYSLOG_INTBUFFER
-      /* Flush any characters that may have been added to the interrupt
-       * buffer.
-       */
+          /* Flush any characters that may have been added to the interrupt
+           * buffer.
+           */
 
-      syslog_flush_intbuffer(g_syslog_channel, false);
+          syslog_flush_intbuffer(g_syslog_channel[i], false);

Review comment:
       fixed




-- 
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


Reply via email to