drivers/syslog: syslog_force does not set errno so do not test against it. Some changes to comments.

This commit is contained in:
Juha Niskanen 2019-09-16 07:48:48 -06:00 committed by Gregory Nutt
parent 63c9c0c935
commit 8fa646f0e8
8 changed files with 38 additions and 47 deletions

View File

@ -162,7 +162,7 @@ SYSLOG Channels
Returned Value:
Zero (OK)is returned on success. A negated errno value is returned
Zero (OK) is returned on success. A negated errno value is returned
on any failure.
SYSLOG Channel Initialization
@ -244,14 +244,15 @@ SYSLOG Channels
SYSLOG output from interrupt level logic. In an embedded system, that is
often where the most critical operations are performed.
There are three conditions under which SYSLOG output generated from interrupt level processing can a included the SYSLOG output stream:
There are three conditions under which SYSLOG output generated from
interrupt level processing can a included the SYSLOG output stream:
1. Low-Level Serial Output
--------------------------
If you are using a SYSLOG console channel (CONFIG_SYSLOG_CONSOLE) with a
serial console (CONFIG_SYSLOG_SERIAL_CONSOLE) and if the underlying
architecture supports the low-level up_putc() interface
(CONFIG_ARCH_LOWPUTC), then the SYLOG logic will direct the output to
(CONFIG_ARCH_LOWPUTC), then the SYSLOG logic will direct the output to
up_putc() which is capable of generating the serial output within the
context of an interrupt handler.
@ -288,7 +289,7 @@ SYSLOG Channels
In this case, the interrupt level SYSLOG output will interrupt the
normal output stream and the interrupt level SYSLOG output will be
inserted into the correct position in the SYSLOG output when the next
normal SYLOG output is generated.
normal SYSLOG output is generated.
The SYSLOG interrupt buffer is enabled with CONFIG_SYSLOG_INTBUFFER. When
the interrupt buffer is enabled, you must also provide the size of the

View File

@ -148,7 +148,7 @@ static ssize_t note_read(FAR struct file *filep, FAR char *buffer,
*
* Description:
* Register a serial driver at /dev/note that can be used by an
* application to read data from the circular not buffer.
* application to read data from the circular note buffer.
*
* Input Parameters:
* None.

View File

@ -471,9 +471,8 @@ static ssize_t ramlog_write(FAR struct file *filep, FAR const char *buffer, size
ret = ramlog_addchar(priv, '\r');
if (ret < 0)
{
/* The buffer is full and nothing was saved. Break out of the
* loop to return the number of bytes written up to this point.
* The data to be written is dropped on the floor.
/* The buffer is full and nothing was saved. The remaining
* data to be written is dropped on the floor.
*/
break;
@ -486,9 +485,8 @@ static ssize_t ramlog_write(FAR struct file *filep, FAR const char *buffer, size
ret = ramlog_addchar(priv, ch);
if (ret < 0)
{
/* The buffer is full and nothing was saved. Break out of the
* loop to return the number of bytes written up to this point.
* The data to be written is dropped on the floor.
/* The buffer is full and nothing was saved. The remaining
* data to be written is dropped on the floor.
*/
break;
@ -524,7 +522,7 @@ static ssize_t ramlog_write(FAR struct file *filep, FAR const char *buffer, size
/* We always have to return the number of bytes requested and NOT the
* number of bytes that were actually written. Otherwise, callers
* will think that this is a short write and probably retry (causing
* probably retry, causing same error condition again.
*/
return len;
@ -561,7 +559,7 @@ int ramlog_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
if (setup)
{
/* This is a request to set up the poll. Find an available
* slot for the poll structure reference
* slot for the poll structure reference.
*/
for (i = 0; i < CONFIG_RAMLOG_NPOLLWAITERS; i++)
@ -787,7 +785,7 @@ int ramlog_putc(int ch)
ret = ramlog_addchar(priv, ch);
if (ret < 0)
{
/* ramlog_addchar() failed */
/* The buffer is full and 'ch' was not saved. */
return ret;
}

View File

@ -208,7 +208,7 @@ void syslog_register(void);
*
* Description:
* Add one more character to the interrupt buffer. In the event of
* buffer overlowed, the character will be dropped. The indication
* buffer overflowed, the character will be dropped. The indication
* "[truncated]\n" will be appended to the end of the interrupt buffer.
*
* Input Parameters:
@ -262,8 +262,8 @@ int syslog_flush_intbuffer(FAR const struct syslog_channel_s *channel,
* ch - The character to add to the SYSLOG (must be positive).
*
* Returned Value:
* On success, the character is echoed back to the caller. Minus one
* is returned on any failure with the errno set correctly.
* On success, the character is echoed back to the caller. A negated
* errno value is returned on any failure.
*
****************************************************************************/
@ -310,7 +310,7 @@ int syslog_force(int ch);
* Name: syslog_dev_write
*
* Description:
* This is the low-level, multile byte, system logging interface provided
* This is the low-level, multiple byte, system logging interface provided
* for the character driver interface.
*
* Input Parameters:

View File

@ -119,10 +119,6 @@ static const uint8_t g_syscrlf[2] =
/****************************************************************************
* Name: syslog_dev_takesem
*
* Description:
* Write to the syslog device
*
****************************************************************************/
static inline int syslog_dev_takesem(void)
@ -163,10 +159,6 @@ static inline int syslog_dev_takesem(void)
/****************************************************************************
* Name: syslog_dev_givesem
*
* Description:
* Write to the syslog device
*
****************************************************************************/
static inline void syslog_dev_givesem(void)
@ -207,15 +199,15 @@ static inline void syslog_dev_givesem(void)
* this case, we won't ever bother to try again (ever).
*
* NOTE: That the third case is different. It applies only to the thread
* that currently holds the sl_sem sempaphore. Other threads should wait.
* that currently holds the sl_sem semaphore. Other threads should wait.
* that is why that case is handled in syslog_semtake().
*
* Input Parameters:
* ch - The character to add to the SYSLOG (must be positive).
* None.
*
* Returned Value:
* On success, the character is echoed back to the caller. A negated
* errno value is returned on any failure.
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure.
*
****************************************************************************/
@ -259,7 +251,7 @@ static int syslog_dev_outputready(void)
*
* NOTE that the scheduler is locked. That is because we do not have
* fully initialized semaphore capability until the SYSLOG device is
* successfully initialized
* successfully initialized.
*/
sched_lock();
@ -326,7 +318,7 @@ int syslog_dev_initialize(FAR const char *devpath, int oflags, int mode)
int ret;
/* At this point, the only expected states are SYSLOG_UNINITIALIZED or
* SYSLOG_REOPEN.. Not SYSLOG_INITIALIZING, SYSLOG_FAILURE, SYSLOG_OPENED.
* SYSLOG_REOPEN. Not SYSLOG_INITIALIZING, SYSLOG_FAILURE, SYSLOG_OPENED.
*/
DEBUGASSERT(g_syslog_dev.sl_state == SYSLOG_UNINITIALIZED ||
@ -334,7 +326,7 @@ int syslog_dev_initialize(FAR const char *devpath, int oflags, int mode)
/* Save the path to the device in case we have to re-open it.
* If we get here and sl_devpath is not equal to NULL, that is a clue
* that we will are re-openingthe file.
* that we are re-opening the file.
*/
if (g_syslog_dev.sl_state == SYSLOG_REOPEN)
@ -443,7 +435,7 @@ int syslog_dev_uninitialize(void)
* Name: syslog_dev_write
*
* Description:
* This is the low-level, multile byte, system logging interface provided
* This is the low-level, multiple byte, system logging interface provided
* for the character driver interface.
*
* Input Parameters:
@ -585,8 +577,8 @@ errout_with_sem:
* ch - The character to add to the SYSLOG (must be positive).
*
* Returned Value:
* On success, the character is echoed back to the caller. Minus one
* is returned on any failure with the errno set correctly.
* On success, the character is echoed back to the caller. A negated errno
* value is returned on any failure.
*
****************************************************************************/

View File

@ -68,22 +68,22 @@ static void emergstream_putc(FAR struct lib_outstream_s *this, int ch)
do
{
/* Write the character to the supported logging device. On failure,
* syslog_putc returns EOF with the errno value set;
* syslog_force returns a negated errno value.
*/
ret = syslog_force(ch);
if (ret != EOF)
if (ret >= 0)
{
this->nput++;
return;
}
/* The special errno value -EINTR means that syslog_putc() was
/* The special return value -EINTR means that syslog_force() was
* awakened by a signal. This is not a real error and must be
* ignored in this context.
*/
}
while (errno == -EINTR);
while (ret == -EINTR);
}
/****************************************************************************

View File

@ -168,7 +168,7 @@ static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch)
do
{
/* Write the character to the supported logging device. On
* failure, syslog_putc returns EOF with the errno value set;
* failure, syslog_putc returns a negated errno value.
*/
ret = syslog_putc(ch);
@ -201,7 +201,7 @@ static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch)
*
* Input Parameters:
* stream - User allocated, uninitialized instance of struct
* lib_lowoutstream_s to be initialized.
* lib_syslogstream_s to be initialized.
*
* Returned Value:
* None (User allocated instance initialized).
@ -247,7 +247,7 @@ void syslogstream_create(FAR struct lib_syslogstream_s *stream)
*
* Input Parameters:
* stream - User allocated, uninitialized instance of struct
* lib_lowoutstream_s to be initialized.
* lib_syslogstream_s to be initialized.
*
* Returned Value:
* None (Resources freed).

View File

@ -315,7 +315,7 @@ void lib_rawsostream(FAR struct lib_rawsostream_s *outstream, int fd);
*
* Input Parameters:
* lowoutstream - User allocated, uninitialized instance of struct
* lib_lowoutstream_s to be initialized.
* lib_outstream_s to be initialized.
*
* Returned Value:
* None (User allocated instance initialized).
@ -365,7 +365,7 @@ void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream);
*
* Input Parameters:
* stream - User allocated, uninitialized instance of struct
* lib_lowoutstream_s to be initialized.
* lib_syslogstream_s to be initialized.
*
* Returned Value:
* None (User allocated instance initialized).
@ -382,7 +382,7 @@ void syslogstream_create(FAR struct lib_syslogstream_s *stream);
*
* Input Parameters:
* stream - User allocated, uninitialized instance of struct
* lib_lowoutstream_s to be initialized.
* lib_syslogstream_s to be initialized.
*
* Returned Value:
* None (Resources freed).
@ -404,7 +404,7 @@ void syslogstream_destroy(FAR struct lib_syslogstream_s *stream);
*
* Input Parameters:
* stream - User allocated, uninitialized instance of struct
* lib_lowoutstream_s to be initialized.
* lib_outstream_s to be initialized.
*
* Returned Value:
* None (User allocated instance initialized).